# Weird resizing of window

**URL:** <https://discourse.glfw.org/t/weird-resizing-of-window/1614>\
**Category:** support\
**Created:** [July 18, 2020, 7:23pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614 "2020-07-18T19:23:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pulzer](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Pulzer](https://discourse.glfw.org/u/Pulzer)\
**Post date:** [July 18, 2020, 7:23pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/1 "2020-07-18T19:23:17Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/65b3e0c05f3457f04e57912c9acae4bd7a7a6805.png) 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](https://hatebin.com/khunstajqk)  
I will be really happy for all your help. Thank you.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 18, 2020, 7:53pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/2 "2020-07-18T19:53:59Z")

</div>

Hi @Pulzer,

Welcome to the GLFW forums.

It looks like you forgot to set the [glViewport](https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glViewport.xml). 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.

---

<div class="post-metadata">

**Author:** ![Pulzer](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Pulzer](https://discourse.glfw.org/u/Pulzer)\
**Post date:** [July 19, 2020, 11:55am UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/3 "2020-07-19T11:55:48Z")

</div>

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;
}
```

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 19, 2020, 3:49pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/4 "2020-07-19T15:49:52Z")

</div>

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](https://github.com/ocornut/imgui/blob/master/examples/imgui_impl_glfw.cpp#L353-L357).

---

<div class="post-metadata">

**Author:** ![Pulzer](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Pulzer](https://discourse.glfw.org/u/Pulzer)\
**Post date:** [July 21, 2020, 1:57pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/5 "2020-07-21T13:57:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 21, 2020, 2:54pm UTC](https://discourse.glfw.org/t/weird-resizing-of-window/1614/6 "2020-07-21T14:54:21Z")

</div>

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.
