Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty command list when imgui.ini present #33

Closed
lwjglgamedev opened this issue Mar 12, 2021 · 2 comments
Closed

Empty command list when imgui.ini present #33

lwjglgamedev opened this issue Mar 12, 2021 · 2 comments

Comments

@lwjglgamedev
Copy link

Hi,

I'm facing a strange issue with this library. I'm doing some tests, and it seems that once the imgui.ini file is created, the commands list is always 0 and the buffers are not populated. I've tried to create a simple sample to show this. The folloing code just initializes Imgui, creates the demo window, renders it and then tries to get the commands list.

package org.vulkanb;

import imgui.*;
import imgui.type.ImInt;

public class TestImGui {
    public static void main(String[] args) {
        try {
            ImGui.createContext();

            ImGuiIO imGuiIO = ImGui.getIO();
            imGuiIO.setDisplaySize(1280, 720);
            imGuiIO.setDisplayFramebufferScale(1.0f, 1.0f);

            ImInt outWidth = new ImInt();
            ImInt outHeight = new ImInt();
            imGuiIO.getFonts().getTexDataAsAlpha8(outWidth, outHeight);

            ImGui.newFrame();
            ImGui.showDemoWindow();
            ImGui.render();

            ImDrawData imDrawData = ImGui.getDrawData();

            System.out.println("Cmd Lists=" + imDrawData.getCmdListsCount());
            System.out.println("Total vertices count=" + imDrawData.getTotalVtxCount());
            System.out.println("Total indices count=" + imDrawData.getTotalIdxCount());
            System.out.println("Draw data valid=" + imDrawData.getValid());

            ImGui.destroyContext();
        } catch (Exception excp) {
            excp.printStackTrace();
        }
    }
}

The first time it ies ececuted, no imgui.ini file is present, I get the following result:

Cmd Lists=1
Total vertices count=814
Total indices count=1365
Draw data valid=true

However, if I execute the example again, the imgui.ini is present, I get the following output:

Cmd Lists=0
Total vertices count=0
Total indices count=0
Draw data valid=true

I'm using openjdk 15.0.2 2021-01-19 and version 1.81.2 of the imgui-java library.

Any idea of what I am missing? In addition to that, it seems to mee that the vertex coordinates have quite small values (the display size seems not to be applied). I don't know if this related to this issue or not.

Any guidance is very much appreciated.

@SpaiR
Copy link
Owner

SpaiR commented Mar 12, 2021

Hi. Thanks for your detailed explanation and code example. I've didn't meet such problem. I never tried to experiment with things in such way though.

It seems you have the same issue described here: ocornut/imgui#1905
Specificaly, in another issue there is a comment: ocornut/imgui#1893 (comment)

I see. Dear ImGui can't give you guarantee that things will appear on the first frame unless you explicitly size them. If you want to hold on a pre-recorded command buffer (which seems a little odd) maybe you can call the imgui NewFrame/Render set twice before turning the ImDrawData structure into a command buffer?

Is it related?

@lwjglgamedev
Copy link
Author

Thanks a lot!

Thanks to your comments, I've first being able to disable imgui.ini file generation (I don't want this), and the first problema solved. Woth the #1893 issue, I now set the size and the values of the vertex buffer start to make sense. Now I hope to start seeing something in Vulkan.

I will close the issue. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants