Fix HiDPI support
This commit is contained in:
parent
1dfe03dc0b
commit
fd4661088a
2 changed files with 8 additions and 9 deletions
|
@ -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);
|
gfx->initialize_view(native_handle, window_ptr, drawable_extent.width, drawable_extent.height);
|
||||||
|
|
||||||
|
|
||||||
window->extent = extent;
|
window->extent = extent;
|
||||||
window->render_target = current_renderer->allocate_render_target(drawable_extent);
|
window->render_target = current_renderer->allocate_render_target(drawable_extent);
|
||||||
|
|
||||||
|
|
|
@ -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_x = rect.offset.x;
|
||||||
int real_y = rect.offset.y;
|
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;
|
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;
|
real_y = SDL_WINDOWPOS_CENTERED;
|
||||||
|
|
||||||
int real_width = rect.extent.width;
|
int real_width = rect.extent.width;
|
||||||
int real_height = rect.extent.height;
|
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;
|
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;
|
real_height = 480;
|
||||||
|
|
||||||
win = SDL_CreateWindow(title.data(), real_x, real_y, real_width, real_height, sdl_flags);
|
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)
|
if(windows.size() == 1)
|
||||||
main_window = win;
|
main_window = win;
|
||||||
|
|
||||||
engine->add_window((void*)win, win, rect.extent);
|
engine->add_window((void*)win, win, {static_cast<uint32_t>(real_width), static_cast<uint32_t>(real_height)});
|
||||||
app->initialize_render();
|
app->initialize_render();
|
||||||
|
|
||||||
return win;
|
return win;
|
||||||
|
@ -147,14 +147,14 @@ prism::Rectangle platform::get_monitor_resolution() {
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
SDL_GetDisplayBounds(0, &r);
|
SDL_GetDisplayBounds(0, &r);
|
||||||
|
|
||||||
return {r.x, r.y, r.w, r.h};
|
return {r.x, r.y, static_cast<uint32_t>(r.w), static_cast<uint32_t>(r.h)};
|
||||||
}
|
}
|
||||||
|
|
||||||
prism::Rectangle platform::get_monitor_work_area() {
|
prism::Rectangle platform::get_monitor_work_area() {
|
||||||
SDL_Rect r = {};
|
SDL_Rect r = {};
|
||||||
SDL_GetDisplayUsableBounds(0, &r);
|
SDL_GetDisplayUsableBounds(0, &r);
|
||||||
|
|
||||||
return {r.x, r.y, r.w, r.h};
|
return {r.x, r.y, static_cast<uint32_t>(r.w), static_cast<uint32_t>(r.h)};
|
||||||
}
|
}
|
||||||
|
|
||||||
prism::Offset platform::get_window_position(const platform::window_ptr index) {
|
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);
|
auto window = get_window(index);
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
SDL_GetWindowSize(window, &width, &height);
|
SDL_Vulkan_GetDrawableSize(window, &width, &height);
|
||||||
|
|
||||||
return {(uint32_t)width, (uint32_t)height};
|
return {(uint32_t)width, (uint32_t)height};
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue