Fix high-DPI window size in Studio.
PiperOrigin-RevId: 907585586 Change-Id: Ie7db20f5242d89926a4a34ffed3a6e39698defd3
This commit is contained in:
committed by
Copybara-Service
parent
a2cd7aa52f
commit
52e90bf55d
@@ -16,8 +16,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -121,10 +119,13 @@ Window::Window(std::string_view title, int width, int height, Config config)
|
||||
mju_error("Unsupported window config: %d", config_.gfx_mode);
|
||||
}
|
||||
|
||||
const float content_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||
const float content_scale =
|
||||
std::max(1.0f, ImGui_ImplSDL2_GetContentScaleForDisplay(0));
|
||||
width_ = width * content_scale;
|
||||
height_ = height * content_scale;
|
||||
sdl_window_ =
|
||||
SDL_CreateWindow(title.data(), SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED, width, height, window_flags);
|
||||
SDL_WINDOWPOS_UNDEFINED, width_, height_, window_flags);
|
||||
if (!sdl_window_) {
|
||||
mju_error("Error creating window: %s", SDL_GetError());
|
||||
}
|
||||
@@ -160,8 +161,8 @@ Window::Window(std::string_view title, int width, int height, Config config)
|
||||
#endif
|
||||
}
|
||||
|
||||
int drawable_width = width;
|
||||
int drawable_height = height;
|
||||
int drawable_width = width_;
|
||||
int drawable_height = height_;
|
||||
SDL_GL_GetDrawableSize(sdl_window_, &drawable_width, &drawable_height);
|
||||
scale_ = (float)drawable_width / (float)width_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user