HiDPI support on SDL2 (#351)
linux: works only with wayland backend, can be used with SDL_VIDEODRIVER=wayland enviroment variable set. It's possible that it works also on other platforms when using the SDL backend.
This commit is contained in:
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
"Wicked Engine Editor",
|
||||
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
w, h,
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (!window) {
|
||||
throw sdl2::SDLError("Error creating window");
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
"Wicked Engine Tests",
|
||||
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
1280, 800,
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (!window) {
|
||||
throw sdl2::SDLError("Error creating window");
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef void* HMODULE;
|
||||
|
||||
#ifdef SDL2
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
#include "sdl2.h"
|
||||
#endif
|
||||
|
||||
@@ -94,8 +95,10 @@ namespace wiPlatform
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
dest->dpi = 96; // todo
|
||||
SDL_GetWindowSize(window, &dest->width, &dest->height);
|
||||
int window_width, window_height;
|
||||
SDL_GetWindowSize(window, &window_width, &window_height);
|
||||
SDL_Vulkan_GetDrawableSize(window, &dest->width, &dest->height);
|
||||
dest->dpi = ((float) dest->width / (float) window_width) * 96.0;
|
||||
#endif // PLATFORM_LINUX
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user