mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
automatic stretching/window mode for invalid resolutions
This commit is contained in:
parent
d0cf60b618
commit
8b34ec65ad
8
ddraw.rc
8
ddraw.rc
@ -1,6 +1,6 @@
|
|||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 1,1,2,0
|
FILEVERSION 1,1,3,0
|
||||||
PRODUCTVERSION 1,1,2,0
|
PRODUCTVERSION 1,1,3,0
|
||||||
{
|
{
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
{
|
{
|
||||||
@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,2,0
|
|||||||
{
|
{
|
||||||
VALUE "CompanyName", "cncnet.org"
|
VALUE "CompanyName", "cncnet.org"
|
||||||
VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert"
|
VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert"
|
||||||
VALUE "FileVersion", "1.1.2.0"
|
VALUE "FileVersion", "1.1.3.0"
|
||||||
VALUE "InternalName", "ddraw"
|
VALUE "InternalName", "ddraw"
|
||||||
VALUE "LegalCopyright", "Copyright (c) 2010-2017"
|
VALUE "LegalCopyright", "Copyright (c) 2010-2017"
|
||||||
VALUE "LegalTrademarks", ""
|
VALUE "LegalTrademarks", ""
|
||||||
VALUE "OriginalFileName", "ddraw.dll"
|
VALUE "OriginalFileName", "ddraw.dll"
|
||||||
VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert"
|
VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert"
|
||||||
VALUE "ProductVersion", "1.1.2.0"
|
VALUE "ProductVersion", "1.1.3.0"
|
||||||
VALUE "Comments", "https://cncnet.org"
|
VALUE "Comments", "https://cncnet.org"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
src/main.c
51
src/main.c
@ -276,6 +276,57 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
|||||||
This->render.mode.dmBitsPerPel = This->render.bpp;
|
This->render.mode.dmBitsPerPel = This->render.bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!This->windowed)
|
||||||
|
{
|
||||||
|
// Making sure the chosen resolution is valid
|
||||||
|
if(!This->devmode)
|
||||||
|
{
|
||||||
|
int width = This->render.width;
|
||||||
|
int height = This->render.height;
|
||||||
|
|
||||||
|
if (ChangeDisplaySettings(&This->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
// fail... compare resolutions
|
||||||
|
if (This->render.width > This->mode.dmPelsWidth || This->render.height > This->mode.dmPelsHeight)
|
||||||
|
{
|
||||||
|
// chosen game resolution higher than current resolution, use window mode for this case
|
||||||
|
This->windowed = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Try 2x scaling
|
||||||
|
This->render.width *= 2;
|
||||||
|
This->render.height *= 2;
|
||||||
|
|
||||||
|
This->render.mode.dmPelsWidth = This->render.width;
|
||||||
|
This->render.mode.dmPelsHeight = This->render.height;
|
||||||
|
|
||||||
|
if (ChangeDisplaySettings(&This->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
// try current display settings
|
||||||
|
This->render.width = This->mode.dmPelsWidth;
|
||||||
|
This->render.height = This->mode.dmPelsHeight;
|
||||||
|
|
||||||
|
This->render.mode.dmPelsWidth = This->render.width;
|
||||||
|
This->render.mode.dmPelsHeight = This->render.height;
|
||||||
|
|
||||||
|
if (ChangeDisplaySettings(&This->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
// everything failed, use window mode instead
|
||||||
|
This->render.width = width;
|
||||||
|
This->render.height = height;
|
||||||
|
|
||||||
|
This->render.mode.dmPelsWidth = This->render.width;
|
||||||
|
This->render.mode.dmPelsHeight = This->render.height;
|
||||||
|
|
||||||
|
This->windowed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(This->windowed)
|
if(This->windowed)
|
||||||
{
|
{
|
||||||
if(!This->windowed_init)
|
if(!This->windowed_init)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user