Mercurial > hg > orthanc-stone
comparison Applications/Sdl/SdlWindow.cpp @ 656:002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
might also be needed on macos and GNU/Linux ?) + fixed text info overlay pos
for angle measure (this requires the app to be aware of the compositor)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 14 May 2019 16:54:13 +0200 |
parents | b70e9be013e4 |
children | 794278160a3f |
comparison
equal
deleted
inserted
replaced
655:1e26bb5f2a02 | 656:002d9562c8f5 |
---|---|
24 #if ORTHANC_ENABLE_SDL == 1 | 24 #if ORTHANC_ENABLE_SDL == 1 |
25 | 25 |
26 #include <Core/Logging.h> | 26 #include <Core/Logging.h> |
27 #include <Core/OrthancException.h> | 27 #include <Core/OrthancException.h> |
28 | 28 |
29 #ifdef WIN32 | |
30 #include <windows.h> // for SetProcessDpiAware | |
31 #endif | |
32 // WIN32 | |
33 | |
29 #include <SDL.h> | 34 #include <SDL.h> |
30 | 35 |
31 namespace OrthancStone | 36 namespace OrthancStone |
32 { | 37 { |
33 SdlWindow::SdlWindow(const char* title, | 38 SdlWindow::SdlWindow(const char* title, |
34 unsigned int width, | 39 unsigned int width, |
35 unsigned int height, | 40 unsigned int height, |
36 bool enableOpenGl) : | 41 bool enableOpenGl, |
42 bool allowDpiScaling) : | |
37 maximized_(false) | 43 maximized_(false) |
38 { | 44 { |
39 // TODO Understand why, with SDL_WINDOW_OPENGL + MinGW32 + Release | 45 // TODO Understand why, with SDL_WINDOW_OPENGL + MinGW32 + Release |
40 // build mode, the application crashes whenever the SDL window is | 46 // build mode, the application crashes whenever the SDL window is |
41 // resized or maximized | 47 // resized or maximized |
49 else | 55 else |
50 { | 56 { |
51 windowFlags = SDL_WINDOW_RESIZABLE; | 57 windowFlags = SDL_WINDOW_RESIZABLE; |
52 rendererFlags = SDL_RENDERER_SOFTWARE; | 58 rendererFlags = SDL_RENDERER_SOFTWARE; |
53 } | 59 } |
60 | |
61 // TODO: probably required on MacOS X, too | |
62 #ifdef WIN32 | |
63 if (!allowDpiScaling) | |
64 { | |
65 // if we do NOT allow DPI scaling, it means an SDL pixel will be a real | |
66 // monitor pixel. This is needed for high-DPI applications | |
67 | |
68 // Enable high-DPI support on Windows | |
69 | |
70 // THE FOLLOWING HAS BEEN COMMENTED OUT BECAUSE IT WILL CRASH UNDER | |
71 // OLD WINDOWS VERSIONS | |
72 // ADD THIS AT THE TOP TO ENABLE IT: | |
73 // | |
74 //#pragma comment(lib, "Shcore.lib") THIS IS ONLY REQUIRED FOR SetProcessDpiAwareness | |
75 //#include <windows.h> | |
76 //#include <ShellScalingAPI.h> THIS IS ONLY REQUIRED FOR SetProcessDpiAwareness | |
77 //#include <comdef.h> THIS IS ONLY REQUIRED FOR SetProcessDpiAwareness | |
78 // SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); | |
79 | |
80 // This is supported on Vista+ | |
81 SetProcessDPIAware(); | |
82 | |
83 windowFlags |= SDL_WINDOW_ALLOW_HIGHDPI; | |
84 } | |
85 #endif | |
86 // WIN32 | |
54 | 87 |
55 window_ = SDL_CreateWindow(title, | 88 window_ = SDL_CreateWindow(title, |
56 SDL_WINDOWPOS_UNDEFINED, | 89 SDL_WINDOWPOS_UNDEFINED, |
57 SDL_WINDOWPOS_UNDEFINED, | 90 SDL_WINDOWPOS_UNDEFINED, |
58 width, height, windowFlags); | 91 width, height, windowFlags); |