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

AlwaysAutoResize window not resized on first call. #1893

Closed
sc00ter opened this issue Jun 21, 2018 · 6 comments
Closed

AlwaysAutoResize window not resized on first call. #1893

sc00ter opened this issue Jun 21, 2018 · 6 comments

Comments

@sc00ter
Copy link

sc00ter commented Jun 21, 2018

master branch

Nothing is drawn the first time this is called, unless ImGui::SetNextWindowSize(...) is called prior to Begin().

ImGui::NewFrame();
ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_Always);
ImGui::Begin("", nullptr,  
  ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoTitleBar
  |ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize
  |ImGuiWindowFlags_NoSavedSettings
  |ImGuiWindowFlags_NoFocusOnAppearing
  |ImGuiWindowFlags_NoNav); 
ImGui::Text("%s", text);
ImGui::End();
ImGui::EndFrame();
ImGui::Render();
auto dd = ImGui::GetDrawData();

assert(dd->TotalVtxCount > 0); // will fail on first run.

Cheers.

@ocornut
Copy link
Owner

ocornut commented Jun 21, 2018

That's intentional, we need to compute the contents size on the first frame so the window can have a size on the next frame.

What's the issue with it?

@sc00ter
Copy link
Author

sc00ter commented Jun 21, 2018

It's not a huge deal, but it is showing up as an error on a vulkan based render test case.
Basically vulkan is recording a command buffer which is using imgui to draw some text overlays.
As the command buffers only get created once upfront, and not for each frame, it will always fail.

@ocornut
Copy link
Owner

ocornut commented Jun 21, 2018

it is showing up as an error on a vulkan based render test case.

If there is an error in the Vulkan example could you clarify what/where the error is?

I can't seem to reproduce any error even when taking this early return path in ImGui_ImplVulkan_RenderDrawData():

void ImGui_ImplVulkan_RenderDrawData(VkCommandBuffer command_buffer, ImDrawData* draw_data)
{
    VkResult err;
    if (draw_data->TotalVtxCount == 0)
        return;

@ocornut ocornut added the vulkan label Jun 21, 2018
@sc00ter
Copy link
Author

sc00ter commented Jun 21, 2018

Sorry, I don't mean in the Vulkan example in imgui. I'm referring to a vulkan project I am working on.

To clarify, in this particular case, the command buffer is pre-recorded once, but submitted to vulkan's render queue each frame, rather than being re-recorded each frame. So in the case where no window size is given, the above issue occurs.

Perhaps this use case, albeit a common vulkan scenario, is a little outside the scope of imgui's general design.

@ocornut
Copy link
Owner

ocornut commented Jun 21, 2018

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?

@sc00ter
Copy link
Author

sc00ter commented Jun 21, 2018

sure, thanks for the help.

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

No branches or pull requests

2 participants