mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
Set dpi scaling to solve display errot when using high dpi displayer
This commit is contained in:
@@ -4,15 +4,10 @@ int Render::MainWindow() {
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(main_window_width_, main_window_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("Render", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar);
|
||||
|
||||
MenuWindow();
|
||||
LocalWindow();
|
||||
RemoteWindow();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -241,6 +241,15 @@ int Render::Run() {
|
||||
|
||||
io.Fonts->Build();
|
||||
|
||||
SDL_GL_GetDrawableSize(main_window_, &main_window_width_real_,
|
||||
&main_window_height_real_);
|
||||
dpi_scaling_w_ = (float)main_window_width_real_ / (float)main_window_width_;
|
||||
dpi_scaling_h_ = (float)main_window_width_real_ / (float)main_window_width_;
|
||||
|
||||
LOG_INFO("Use dpi scaling [{}x{}]", dpi_scaling_w_, dpi_scaling_h_);
|
||||
|
||||
SDL_RenderSetScale(main_renderer_, dpi_scaling_w_, dpi_scaling_h_);
|
||||
|
||||
// Setup Dear ImGui style
|
||||
// ImGui::StyleColorsDark();
|
||||
ImGui::StyleColorsLight();
|
||||
|
||||
@@ -124,6 +124,11 @@ class Render {
|
||||
int menu_window_height_ = 30;
|
||||
int local_window_width_ = 350;
|
||||
|
||||
int main_window_width_real_ = 960;
|
||||
int main_window_height_real_ = 540;
|
||||
float dpi_scaling_w_ = 1.0f;
|
||||
float dpi_scaling_h_ = 1.0f;
|
||||
|
||||
int texture_width_ = 1280;
|
||||
int texture_height_ = 720;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user