# SDL2 HiDPI problem

**URL:** <https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943>\
**Category:** SDL Development\
**Created:** [August 17, 2017, 5:07pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943 "2017-08-17T17:07:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![whatever](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/w/b3f665/32.png) [@whatever](https://discourse.libsdl.org/u/whatever)\
**Post date:** [August 17, 2017, 5:07pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943/1 "2017-08-17T17:07:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![whatever](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/w/b3f665/32.png) [@whatever](https://discourse.libsdl.org/u/whatever)\
**Post date:** [August 17, 2017, 6:48pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943/2 "2017-08-17T18:48:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Eric\_Wasylishen](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/ce73a5/32.png) [@Eric\_Wasylishen](https://discourse.libsdl.org/u/Eric_Wasylishen)\
**Post date:** [August 17, 2017, 9:35pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943/3 "2017-08-17T21:35:04Z")

</div>

Yep, proper highdpi support on Windows is in the works but it’s not in SDL2 yet.  
[https://bugzilla.libsdl.org/show\_bug.cgi?id=3281](https://bugzilla.libsdl.org/show_bug.cgi?id=3281)

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [August 17, 2017, 10:02pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943/4 "2017-08-17T22:02:39Z")

</div>

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):

> [@SDL\_GetDesktopDisplayMode resolution reported in Windows 10 when using app scaling](https://discourse.libsdl.org/t/sdl-getdesktopdisplaymode-resolution-reported-in-windows-10-when-using-app-scaling/22389/4):
>
> I think you have to set WINVER to the Windows 8.1 constant to call SetProcessDpiAwareness directly, but then the app will be windows 8.1+ only. Here’s a snippet to load them at runtime: typedef enum PROCESS\_DPI\_AWARENESS { PROCESS\_DPI\_UNAWARE = 0, PROCESS\_SYSTEM\_DPI\_AWARE = 1, PROCESS\_PER\_MONITOR\_DPI\_AWARE = 2 } PROCESS\_DPI\_AWARENESS; void\* userDLL; BOOL(WINAPI \*SetProcessDPIAware)(void); // Vista and later void\* shcoreDLL; HRESULT(WINAPI \*SetProcessDpiAwareness)(PROCESS\_DPI\_AWARE…

Cheers,  
Daniel

---

<div class="post-metadata">

**Author:** ![whatever](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/w/b3f665/32.png) [@whatever](https://discourse.libsdl.org/u/whatever)\
**Post date:** [August 18, 2017, 2:07pm UTC](https://discourse.libsdl.org/t/sdl2-hidpi-problem/22943/5 "2017-08-18T14:07:09Z")

</div>

Thanks everyone for help!
