重新启用自动DPI感知,并提供get_dpi_scale()函数

This commit is contained in:
Nanako 2024-07-10 22:18:39 +08:00
parent 84fcabdd55
commit 329ba6af41
3 changed files with 10 additions and 1 deletions

View File

@ -67,6 +67,10 @@ void shutdown_imgui() {
glfwTerminate();
}
float get_dpi_scale() {
return 1.0f;
}
void run_imgui() {
init_imgui();

View File

@ -9,6 +9,7 @@ extern bool imgui_new_frame();
extern void draw_imgui(float delta_time);
extern void render_imgui();
extern void shutdown_imgui();
extern float get_dpi_scale();
extern void tick_imgui(float delta_time);

View File

@ -27,7 +27,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
// Main code
int init_imgui() {
// Create application window
// ImGui_ImplWin32_EnableDpiAwareness();
ImGui_ImplWin32_EnableDpiAwareness();
wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"Arona", nullptr };
::RegisterClassExW(&wc);
std::string window_title = get_window_title();
@ -133,6 +133,10 @@ void shutdown_imgui() {
::UnregisterClassW(wc.lpszClassName, wc.hInstance);
}
float get_dpi_scale() {
return ImGui_ImplWin32_GetDpiScaleForHwnd(hwnd);
}
void run_imgui() {
init_imgui();
while (true) {