I am working on an OpenGL application. I use a high-dpi screen, and the Windows GUI is scaled to 125%, to make the programs look like on a regular screen.
If I create a 800*600 window using SDL2, it appears the same size as in a regular screen, but it is 1000*750 px. Since I use deferred rendering, I have to create buffers with the same size as the drawable area, so I would like to find out the real size of the window in pixels
If I call SDL_GL_GetDrawableSize
I incorrectly get 800*600 instead of 1000*750.
I added the flag SDL_WINDOW_ALLOW_HIGHDPI
on window creation.
What do I wrong?
Edit:
If I change DPI Awareness in Visual Studio to Per Monitor High DPI Aware then the window is really 800*600, but it looks small. It should be 1000*750 because the scaling factor in the Windows settings is 125%
Your post is from Dec 2017 and your SDL version (2.0.7) comment from Jan 2018. Your bounty is up to date, but without newer information.
The main problem is, SDL2.0.7 didn't support HighDPI correctly on windows. In May 2017, they prepared a bigger patch, but it was merged on Feb. 2018, so after the version of SDL2.0.7. As far as I see it, it was introduced in SDL2.0.8. The primary changes were made in the file src/video/windows/SDL_windowswindow.c
. I compared the sources and the changelog. It's definitively upstream, but someone forgot to write it down in the WhatIsNew.txt, which is very annoying.
I strongly suggest upgrade SDL to at least 2.0.8, better 2.0.10.
Btw. the author of the patch is mentioning, you need to use the new hint SDL_HINT_VIDEO_HIGHDPI_ENABLED
.
In the worst case, if you have still trouble, you can use GLFW instead of SDL.
EDIT: The Questioner provided new informations today.
You can query DPI value per Monitor on windows via GetDpiForMonitor and calculate from that the size.
Since you're using OpenGL with deferred shading: Ensure you're setting glViewPort
correctly for every render pass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With