From fd4661088a44b61b183811a95fabae3793583ddf Mon Sep 17 00:00:00 2001 From: redstrate Date: Tue, 12 Oct 2021 11:42:10 -0400 Subject: [PATCH] Fix HiDPI support --- engine/core/src/engine.cpp | 1 - platforms/sdl/main.cpp.in | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index 1df52ef..585a5b0 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -401,7 +401,6 @@ void engine::add_window(void* native_handle, const platform::window_ptr window_p gfx->initialize_view(native_handle, window_ptr, drawable_extent.width, drawable_extent.height); - window->extent = extent; window->render_target = current_renderer->allocate_render_target(drawable_extent); diff --git a/platforms/sdl/main.cpp.in b/platforms/sdl/main.cpp.in index 6a62417..aeed1ed 100644 --- a/platforms/sdl/main.cpp.in +++ b/platforms/sdl/main.cpp.in @@ -91,19 +91,19 @@ platform::window_ptr platform::open_window(const std::string_view title, const p int real_x = rect.offset.x; int real_y = rect.offset.y; - if(rect.offset.x <= -1 || rect.offset.x >= resolution.extent.width) + if(rect.offset.x <= -1 || rect.offset.x > resolution.extent.width) real_x = SDL_WINDOWPOS_CENTERED; - if(rect.offset.y <= -1 || rect.offset.x >= resolution.extent.height) + if(rect.offset.y <= -1 || rect.offset.x > resolution.extent.height) real_y = SDL_WINDOWPOS_CENTERED; int real_width = rect.extent.width; int real_height = rect.extent.height; - if(rect.extent.width <= -1 || rect.extent.width >= resolution.extent.width) + if(rect.extent.width <= -1 || rect.extent.width > resolution.extent.width) real_width = 640; - if(rect.extent.height <= -1 || rect.extent.height >= resolution.extent.height) + if(rect.extent.height <= -1 || rect.extent.height > resolution.extent.height) real_height = 480; win = SDL_CreateWindow(title.data(), real_x, real_y, real_width, real_height, sdl_flags); @@ -111,7 +111,7 @@ platform::window_ptr platform::open_window(const std::string_view title, const p if(windows.size() == 1) main_window = win; - engine->add_window((void*)win, win, rect.extent); + engine->add_window((void*)win, win, {static_cast(real_width), static_cast(real_height)}); app->initialize_render(); return win; @@ -147,14 +147,14 @@ prism::Rectangle platform::get_monitor_resolution() { SDL_Rect r; SDL_GetDisplayBounds(0, &r); - return {r.x, r.y, r.w, r.h}; + return {r.x, r.y, static_cast(r.w), static_cast(r.h)}; } prism::Rectangle platform::get_monitor_work_area() { SDL_Rect r = {}; SDL_GetDisplayUsableBounds(0, &r); - return {r.x, r.y, r.w, r.h}; + return {r.x, r.y, static_cast(r.w), static_cast(r.h)}; } prism::Offset platform::get_window_position(const platform::window_ptr index) { @@ -179,7 +179,7 @@ prism::Extent platform::get_window_drawable_size(const platform::window_ptr inde auto window = get_window(index); int width, height; - SDL_GetWindowSize(window, &width, &height); + SDL_Vulkan_GetDrawableSize(window, &width, &height); return {(uint32_t)width, (uint32_t)height}; }