SDL2 HiDPI problem

Hello everybody. I have been using SDL2 for some time now and I really like the library both for 2D and OpenGL programming. However I ecountered one problem with it. On Linux everything works fine, however on Windows window size is higher than I specified. It happens due to HiDPI Windows scaling. Is there any way to force SDL to create window that has exact size I want? I tried allow hidpi flag, but that doesn’t make difference. I’m sure that is possible since GLFW does that, but I prefer to stick to SDL.

Thanks in advance.

Actually I was testing VS settings and I figured out fix for it. You need to go to properties, manifest, input and output and set DPI awarness to HiDPI aware. That solves problem.

Yep, proper highdpi support on Windows is in the works but it’s not in SDL2 yet.

1 Like

This can also be worked around in code (helpful especially when not
using MSVC but mingw, I guess - or maybe if you generate the solution
with cmake or premake or whatever and don’t know how to get that setting
into it that way), by executing this snippet of code on startup (before
creating windows):


1 Like

Thanks everyone for help!