Weird resizing of window

Hello, I’m currently making my own game engine, and at ImGui events I got pretty suprised…
This is how my resizing looks like:

the ImGui is a lot more wider, same for smaller if I resize it to smaller width/height. After completing the resize, it goes to normal scale.
This is my code:https://hatebin.com/khunstajqk
I will be really happy for all your help. Thank you.

Hi @Pulzer,

Welcome to the GLFW forums.

It looks like you forgot to set the glViewport. You need to set this to the framebuffer size.

EDIT: looking at the code further it appears you’ve not given enough of the code to know what’s going on, so it may not be the viewport size. Indeed that would normally show up as only part of the screen being rendered, so I’m not sure what’s going on here.

Cheers,

Doug.

Viewport is being set at ImGui resize event for now, and it should work correctly still can’t get where’s the problem, there’s the function, that should be all you need:

bool ImGuiLayer::OnWindowResizeEvent(WindowResizeEvent& e)
{
    ImGuiIO& io = ImGui::GetIO();
    io.DisplaySize = ImVec2(e.GetWidth(), e.GetHeight());
    io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
    glViewport(0, 0, e.GetWidth(), e.GetHeight());

    return false;
}

Re-reading your question I notice that you mention that the problem occurs DURING resizing.

This might simply be the OS resizing the app and rescaling the content prior to resize - the behaviour during re-sizing depends on the OS (and on Linux the window manager).

Note that glViewport should be set using the framebuffer size to handle operating systems which have different window coordinates to pixel scales. Dear ImGui handles this by using the DisplayFramebufferScale set to FrameBufferSize/ WindowSize.

Sorry for responding late, so there is nothing to do with it? It kinda annoys me

Whether you can alter this depends.

If your rendering can still run whilst the app is resizing you might find that polling glfwGetFramebufferSize at the start of your frame rather than using the callback will help resolve this.