|
@@ -30,11 +30,14 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
// Main code
|
|
|
int main(int, char**)
|
|
|
{
|
|
|
+ // Make process DPI aware and obtain main monitor scale
|
|
|
+ ImGui_ImplWin32_EnableDpiAwareness();
|
|
|
+ float main_scale = ImGui_ImplWin32_GetDpiScaleForMonitor(::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
|
|
|
+
|
|
|
// Create application window
|
|
|
- //ImGui_ImplWin32_EnableDpiAwareness();
|
|
|
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
|
|
::RegisterClassExW(&wc);
|
|
|
- HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX11 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr);
|
|
|
+ HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX11 Example", WS_OVERLAPPEDWINDOW, 100, 100, (int)(1280 * main_scale), (int)(800 * main_scale), nullptr, nullptr, wc.hInstance, nullptr);
|
|
|
|
|
|
// Initialize Direct3D
|
|
|
if (!CreateDeviceD3D(hwnd))
|
|
@@ -59,6 +62,11 @@ int main(int, char**)
|
|
|
ImGui::StyleColorsDark();
|
|
|
//ImGui::StyleColorsLight();
|
|
|
|
|
|
+ // Setup scaling
|
|
|
+ ImGuiStyle& style = ImGui::GetStyle();
|
|
|
+ style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
|
|
+ style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
|
|
+
|
|
|
// Setup Platform/Renderer backends
|
|
|
ImGui_ImplWin32_Init(hwnd);
|
|
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|