part 1: new cfg data structure & caches to replace rd_entity, rd_window, rd_panel, rd_view, etc.

This commit is contained in:
Ryan Fleury
2025-01-09 17:31:02 -08:00
parent 5b7c366234
commit 6ce8046029
9 changed files with 1273 additions and 1664 deletions
+6
View File
@@ -283,6 +283,12 @@ os_dim_from_monitor(OS_Handle monitor)
return v2f32(0, 0);
}
internal F32
os_dpi_from_monitor(OS_Handle monitor)
{
return 96.f;
}
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
+1
View File
@@ -168,6 +168,7 @@ internal OS_Handle os_primary_monitor(void);
internal OS_Handle os_monitor_from_window(OS_Handle window);
internal String8 os_name_from_monitor(Arena *arena, OS_Handle monitor);
internal Vec2F32 os_dim_from_monitor(OS_Handle monitor);
internal F32 os_dpi_from_monitor(OS_Handle monitor);
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
+6
View File
@@ -181,6 +181,12 @@ os_dim_from_monitor(OS_Handle monitor)
return v;
}
internal F32
os_dpi_from_monitor(OS_Handle monitor)
{
return 96.f;
}
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
+18
View File
@@ -8,9 +8,11 @@
typedef BOOL w32_SetProcessDpiAwarenessContext_Type(void* value);
typedef UINT w32_GetDpiForWindow_Type(HWND hwnd);
typedef HRESULT w32_GetDpiForMonitor_Type(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY);
typedef int w32_GetSystemMetricsForDpi_Type(int nIndex, UINT dpi);
#define w32_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((void*)-4)
global w32_GetDpiForWindow_Type *w32_GetDpiForWindow_func = 0;
global w32_GetDpiForMonitor_Type *w32_GetDpiForMonitor_func = 0;
global w32_GetSystemMetricsForDpi_Type *w32_GetSystemMetricsForDpi_func = 0;
////////////////////////////////
@@ -811,6 +813,7 @@ os_gfx_init(void)
(w32_SetProcessDpiAwarenessContext_Type*)GetProcAddress(module, "SetProcessDpiAwarenessContext");
w32_GetDpiForWindow_func =
(w32_GetDpiForWindow_Type*)GetProcAddress(module, "GetDpiForWindow");
w32_GetDpiForMonitor_func = (w32_GetDpiForMonitor_Type *)GetProcAddress(module, "GetDpiForMonitor");
w32_GetSystemMetricsForDpi_func = (w32_GetSystemMetricsForDpi_Type *)GetProcAddress(module, "GetSystemMetricsForDpi");
FreeLibrary(module);
}
@@ -1385,6 +1388,21 @@ os_dim_from_monitor(OS_Handle monitor)
return result;
}
internal F32
os_dpi_from_monitor(OS_Handle monitor)
{
F32 result = 96.f;
HMONITOR monitor_handle = (HMONITOR)monitor.u64[0];
if(w32_GetDpiForMonitor_func != 0)
{
UINT dpi_x = 0;
UINT dpi_y = 0;
HRESULT hr = w32_GetDpiForMonitor_func(monitor_handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y);
result = (F32)dpi_x;
}
return result;
}
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)