TheCherno/OpenGL

Maximize the window only shows the lower left image, a quarter of the screen

zaichenhu opened this issue · 2 comments

I have resolved this problem, beacuse when the window was resized, glfwSetWindowSizeCallback function didn't set the glViewport as (0, 0, width, height). hope you could fix this bug. thank you.

@skyohorizon Are you running a high-dpi screen?

https://www.glfw.org/docs/3.3/window_guide.html#window_size mentions this possible issue. If you run normal monitor it will have a screen / pixel mapping of 1:1, 4k screens (retina mac) have a 1:2 mapping.

When you give glViewPort(0,0, 1080, 768) while the monitor is actually using 2px per 1 screen pixels and thus you should multiply them by 2.

However you can also get these values using the mentioned method in the documentation

int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);

I have had a similar issue and used the framebuffer size method without any issues.