From e7ae3cffc6e569da427a77cd215ab87d646686c2 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Wed, 28 Sep 2022 09:36:10 +0200 Subject: [PATCH] Fix DPI --- examples/raymarcher.kl | 4 +++- modules/user32.kl | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/raymarcher.kl b/examples/raymarcher.kl index 5c5e6eb..e4e9cd1 100644 --- a/examples/raymarcher.kl +++ b/examples/raymarcher.kl @@ -14,7 +14,6 @@ Raymarcher_Update :: () forward := Vec3{0, 0, -1} side := Vec3_Normalize(Vec3_Cross(forward, up)) - bug := Vec3_Dot(side, forward, d, e) Xf := 1 / X->F32 Yf := 1 / Y->F32 ratio := X->F32 / Y->F32 @@ -103,6 +102,9 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS if good_scheduling := false, timeBeginPeriod(1) == TIMERR_NOERROR good_scheduling = true + dpi_aware_set := SetProcessDPIAware() + Assert(dpi_aware_set != 0) + arena: Arena window_name := StringToString16(&arena, "Have a wonderful day! 你好世界 ") diff --git a/modules/user32.kl b/modules/user32.kl index b256366..4447694 100644 --- a/modules/user32.kl +++ b/modules/user32.kl @@ -5,16 +5,17 @@ MSG :: struct;; hwnd: HWND; message: UINT; wParam: WPARAM; lParam: L POINT :: struct;; x: LONG; y: LONG LPMSG :: *MSG -PostQuitMessage :: #foreign (nExitCode: int) -DefWindowProcW :: #foreign (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT -GetDC :: #foreign (hWnd: HWND): HDC -CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND -CreateWindowExW :: #foreign (dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID): HWND -RegisterClassW :: #foreign (lpWndClass: *WNDCLASSW): ATOM -ShowWindow :: #foreign (hWnd: HWND, nCmdShow: int): BOOL -PeekMessageW :: #foreign (lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMs: UINT):BOOL -TranslateMessage:: #foreign (lpMsg: *MSG): BOOL -DispatchMessageW:: #foreign (lpMsg: *MSG): LRESULT +PostQuitMessage :: #foreign (nExitCode: int) +DefWindowProcW :: #foreign (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT +GetDC :: #foreign (hWnd: HWND): HDC +CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND +CreateWindowExW :: #foreign (dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID): HWND +RegisterClassW :: #foreign (lpWndClass: *WNDCLASSW): ATOM +ShowWindow :: #foreign (hWnd: HWND, nCmdShow: int): BOOL +PeekMessageW :: #foreign (lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMs: UINT):BOOL +TranslateMessage :: #foreign (lpMsg: *MSG): BOOL +DispatchMessageW :: #foreign (lpMsg: *MSG): LRESULT +SetProcessDPIAware:: #foreign (): BOOL WM_NULL :: 0x0000; WM_CREATE :: 0x0001; WM_DESTROY :: 0x0002; WM_MOVE :: 0x0003; WM_SIZE :: 0x0005