Fixed full screen mode for resolutions different than current desktop size

This commit is contained in:
Sascha Willems 2020-08-24 20:04:46 +02:00
parent d32663d569
commit 236a424955

View file

@ -1002,17 +1002,16 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
if (settings.fullscreen)
{
if ((width != (uint32_t)screenWidth) && (height != (uint32_t)screenHeight))
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = screenWidth;
dmScreenSettings.dmPelsHeight = screenHeight;
dmScreenSettings.dmPelsWidth = width;
dmScreenSettings.dmPelsHeight = height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if ((width != (uint32_t)screenWidth) && (height != (uint32_t)screenHeight))
{
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL, "Fullscreen Mode not supported!\n Switch to window mode?", "Error", MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
@ -1024,6 +1023,8 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
return nullptr;
}
}
screenWidth = width;
screenHeight = height;
}
}