mirror of
https://github.com/gopher64/gopher64.git
synced 2026-10-31 19:47:19 +01:00
High DPI scaling fixes (#1215)
* dpi fixes * fonts * more fonts * resizeable * more * more * more
This commit is contained in:
1 parent
5de5f1179f
commit
0bb9fbba63
3 files changed
+24
-7
No files matched your search
@@ -122,6 +122,9 @@ static uint64_t sync_signal;
|
||||
static TTF_Font *message_font;
|
||||
static std::queue<Message> messages;
|
||||
|
||||
static float message_font_size = 25.0;
|
||||
static float achievement_challenge_indicator_font_size = 12.0;
|
||||
|
||||
static TTF_Font *achievement_challenge_indicator_font;
|
||||
static std::vector<const char *> achievement_challenge_indicators;
|
||||
static Vulkan::ImageHandle achievement_challenge_indicator_image;
|
||||
@@ -155,8 +158,19 @@ bool sdl_event_filter(void *userdata, SDL_Event *event) {
|
||||
if (event->type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) {
|
||||
callback.paused = false;
|
||||
callback.emu_running = false;
|
||||
} else if (event->type == SDL_EVENT_WINDOW_RESIZED && callback.emu_running) {
|
||||
} else if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED &&
|
||||
callback.emu_running) {
|
||||
wsi_platform->do_resize();
|
||||
|
||||
if (message_font) {
|
||||
TTF_SetFontSize(message_font,
|
||||
message_font_size * SDL_GetWindowDisplayScale(window));
|
||||
}
|
||||
if (achievement_challenge_indicator_font) {
|
||||
TTF_SetFontSize(achievement_challenge_indicator_font,
|
||||
achievement_challenge_indicator_font_size *
|
||||
SDL_GetWindowDisplayScale(window));
|
||||
}
|
||||
} else if (event->type == SDL_EVENT_WINDOW_MINIMIZED) {
|
||||
callback.paused = true;
|
||||
} else if (event->type == SDL_EVENT_WINDOW_RESTORED) {
|
||||
@@ -432,9 +446,12 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font,
|
||||
}
|
||||
|
||||
message_font =
|
||||
TTF_OpenFontIO(SDL_IOFromConstMem(font, font_size), true, 25.0);
|
||||
TTF_OpenFontIO(SDL_IOFromConstMem(font, font_size), true,
|
||||
message_font_size * SDL_GetWindowDisplayScale(window));
|
||||
achievement_challenge_indicator_font =
|
||||
TTF_OpenFontIO(SDL_IOFromConstMem(font, font_size), true, 12.0);
|
||||
TTF_OpenFontIO(SDL_IOFromConstMem(font, font_size), true,
|
||||
achievement_challenge_indicator_font_size *
|
||||
SDL_GetWindowDisplayScale(window));
|
||||
if (!message_font || !achievement_challenge_indicator_font) {
|
||||
rdp_close();
|
||||
return;
|
||||
@@ -503,7 +520,7 @@ static void calculate_viewport(float *x, float *y, float *width, float *height,
|
||||
gfx_info.widescreen ? display_height * 16 / 9 : display_height * 4 / 3;
|
||||
|
||||
int w, h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
|
||||
if (gfx_info.integer_scaling) {
|
||||
// Integer scaling path
|
||||
|
||||
@@ -34,13 +34,13 @@ std::vector<const char *> SDL_WSIPlatform::get_instance_extensions() {
|
||||
|
||||
uint32_t SDL_WSIPlatform::get_surface_width() {
|
||||
int w, h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
uint32_t SDL_WSIPlatform::get_surface_height() {
|
||||
int w, h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn configure_input_profile(
|
||||
#[cfg(target_os = "android")]
|
||||
let window_flags = sdl3_sys::video::SDL_WINDOW_FULLSCREEN;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
let window_flags = sdl3_sys::video::SDL_WindowFlags(0);
|
||||
let window_flags = sdl3_sys::video::SDL_WINDOW_RESIZABLE;
|
||||
if !unsafe {
|
||||
sdl3_sys::render::SDL_CreateWindowAndRenderer(
|
||||
title.as_ptr(),
|
||||
|
||||
Reference in new issue
Block a user