I am well aware this is a highly suboptimal circumstance to be asking for support in. I can’t post any substantial code as the project is proprietary, all the GUI stuff was written by a team member who is no longer with us, the actual OpenGL rendering for ImGUI was written by this team member and is heavily integrated into our graphics stuff so I couldn’t separate it out even if I was at liberty to post all the code, and I neither understand how that code works nor how ImGUI can possibly make a GUI without persistent objects representing each window, button, etc. Oh, did I mention we’re on a two-year-old version of ImGUI (1.53) because all our external dependencies are tied to specific Git versions and if I update there’s a good chance the whole thing will stop working? (I promise I’m a professional, really! )
So I completely understand if the answer is “it’s your bug, not ImGUI’s”. I just want to make sure of this before I spend any more time trying to pull apart this codebase. Now that that’s out of the way…
I’m creating a window like this:
ImGui::SetNextWindowPos(ImVec2(20,20), ImGuiCond_Always);
ImGui::Begin(“Performance”, &windowOpen, ImGuiWindowFlags_AlwaysAutoResize
| ImGuiWindowFlags_NoSavedSettings
| ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoInputs
| ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoScrollbar);
ImGui::Text(“hello world”);
ImGui::End();
ImGui::Render();
The window is positioned at (20,20) from the upper left corner and renders just fine (it’s really running every frame, we’re updating the contents, it’s not actually “hello world”).
However, when I resize the application window, the ImGUI window remains at the position it currently is relative to the lower left corner. It’s as if the ImGUI origin separates from the upper left corner and moves up or down along the left edge of the application window, so that it’s in a constant position relative to the lower left corner. I would expect that if (20,20) is 20 pixels in X and Y from the upper left corner once, then it’ll be 20 pixels in X and Y from the upper left corner regardless of how the window is resized (the origin will stay in the upper left corner).
Is this expected behavior? Is this a well-known bug in this older version of ImGUI? Or have you never seen anything like this and it’s probably a bug in our renderer?
Thanks!
Edit: Window size changes in (w, h) here are being reported to ImGUI as follows:
auto io = ImGui::GetIO();
io.DisplaySize = ImVec2(w, h);
int display_w, display_h; //width/height including DPI, useful for Retina displays
glfwGetFramebufferSize(window, &display_w, &display_h);
io.DisplayFramebufferScale = ImVec2(
w > 0 ? ((float)display_w / w) : 0,
h > 0 ? ((float)display_h / h) : 0);
std::cout << "ImGUI new window size: " << io.DisplaySize.x << ", " << io.DisplaySize.y << “\n”;
std::cout << " scale: " << io.DisplayFramebufferScale.x << ", " << io.DisplayFramebufferScale.y << “\n”;
The printed outputs are the correct window size, and the scales are nearly always 1 though occasionally floating-point numbers like 1.0001f and 0.999f.