OfxImGui / ImGui::SetNextWindowSize has no effect

Hi there ! I’ve discovered ImGui addon for Of and this is great ! Really !
I’ve made some tries to discover the way Imgui’s API works and so far having this small problem : I can’t resize my main window. WindowPos works, WindowSize does not…
ImGui::SetNextWindowPos(ImVec2(0,0)); ImGui::SetNextWindowSize(ImVec2(1400,800), ImGuiSetCond_FirstUseEver); im_gui.begin(); render_main_buttons(); render_scenes_list(); im_gui.end();

From doc
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()

Should be trivial… What’s wrong ?

@jvcleave ? Any idea ?

I actually haven’t used that before but try ImGuiSetCond_Once instead of ImGuiSetCond_FirstUseEver

Nope, same behaviour it’s like if SetNextWindowSize call is completely ignored…

OfxImGui begin() calls ImGui::NewFrame(), and looking inside NewFrame code I found
// Create implicit window - we will only render it if the user has added something to it. ImGui::SetNextWindowSize(ImVec2(400,400), ImGuiSetCond_FirstUseEver);
at line 2269

Disabling this line solve the problem… But I don’t understand the reason why this line of code is here

ImGui creates a default “Debug” window.

You should call SetNextWindowSize() before calling Begin();
It’s unclear what those lines are doing

im_gui.begin();
render_main_buttons();
render_scenes_list();
im_gui.end();

If that’s your code or if im_gui.begin() is ofx wrapping that decided to not follow the standard NewFrame naming convention. If your code starts in render_main_buttons() then call SetNextWindowSize() before your Begin call.

I wrongly supposed that the begin() and end() methods of OfxImGui were related with ImGui::Begin and ImGui::End methods which is not the case…

The right calling sequence is
im_gui.begin(); // Addon begin ImGui::SetNextWindowPos(ImVec2(0,0)); ImGui::SetNextWindowSize(ImVec2(1200,800), ImGuiSetCond_Once); ImGui::Begin("Funky Window"); /* Here your ImGui stuff */ ImGui::End(); im_gui.end(); // Addon end

And everything works as expected !

3 Likes