OpenGL icon indicating copy to clipboard operation
OpenGL copied to clipboard

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

Open zaichenhu opened this issue 5 years ago • 2 comments

Desktop Screenshot 2020 09 13 - 11 41 22 49 (2)

zaichenhu avatar Sep 13 '20 03:09 zaichenhu

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.

zaichenhu avatar Sep 14 '20 07:09 zaichenhu

@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.

Douglasdc3 avatar Jan 02 '21 10:01 Douglasdc3