[gpu] Add fullscreen toggle (F key) to D3D11 demo

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.6 committed 2026-03-29 22:25:06 -06:00
1 parent 94e2b88570
commit 66ce800631
1 file changed
+36
+36
View File
@@ -185,6 +185,37 @@ static ID3D11BlendState *blend;
static HWND hwnd;
static int win_w = 1024, win_h = 768;
static bool fullscreen = false;
static RECT saved_rect;
static LONG saved_style;
static void
toggle_fullscreen ()
{
fullscreen = !fullscreen;
if (fullscreen)
{
saved_style = GetWindowLong (hwnd, GWL_STYLE);
GetWindowRect (hwnd, &saved_rect);
SetWindowLong (hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
MONITORINFO mi = {sizeof (mi)};
GetMonitorInfo (MonitorFromWindow (hwnd, MONITOR_DEFAULTTONEAREST), &mi);
SetWindowPos (hwnd, HWND_TOP,
mi.rcMonitor.left, mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
SWP_FRAMECHANGED);
}
else
{
SetWindowLong (hwnd, GWL_STYLE, saved_style);
SetWindowPos (hwnd, nullptr,
saved_rect.left, saved_rect.top,
saved_rect.right - saved_rect.left,
saved_rect.bottom - saved_rect.top,
SWP_FRAMECHANGED);
}
}
/* ---- Demo state ---- */
@@ -359,6 +390,11 @@ wnd_proc (HWND h, UINT msg, WPARAM wp, LPARAM lp)
DestroyWindow (h);
return 0;
}
if (wp == 'F')
{
toggle_fullscreen ();
return 0;
}
int key = VK_TO_GLFW_KEY ((int) wp);
if (key)
demo_view_key_func (vu, key, 0, 1 /* GLFW_PRESS */, 0);