mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 10:07:47 +01:00
some tweaks for upscaling checks
This commit is contained in:
parent
49b5f808e6
commit
11c0353b82
37
src/dd.c
37
src/dd.c
@ -491,29 +491,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
if (!g_ddraw->windowed)
|
||||
{
|
||||
/* Making sure the chosen resolution is valid */
|
||||
int old_width = g_ddraw->render.width;
|
||||
int old_height = g_ddraw->render.height;
|
||||
|
||||
if (ChangeDisplaySettings(&g_ddraw->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
/* fail... compare resolutions */
|
||||
if (g_ddraw->render.width > g_ddraw->mode.dmPelsWidth ||
|
||||
g_ddraw->render.height > g_ddraw->mode.dmPelsHeight)
|
||||
{
|
||||
/* Try without upscaling */
|
||||
g_ddraw->render.width = g_ddraw->width;
|
||||
g_ddraw->render.height = g_ddraw->height;
|
||||
|
||||
g_ddraw->render.mode.dmPelsWidth = g_ddraw->render.width;
|
||||
g_ddraw->render.mode.dmPelsHeight = g_ddraw->render.height;
|
||||
|
||||
if (ChangeDisplaySettings(&g_ddraw->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
/* chosen game resolution higher than current resolution, use windowed mode for this case */
|
||||
g_ddraw->windowed = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Try without upscaling */
|
||||
g_ddraw->render.width = g_ddraw->width;
|
||||
@ -539,10 +517,10 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
|
||||
/* try to get a resolution with the same aspect ratio as the requested resolution */
|
||||
BOOL found_res = util_get_lowest_resolution(
|
||||
(float)old_width / old_height,
|
||||
(float)g_ddraw->width / g_ddraw->height,
|
||||
&res,
|
||||
old_width + 1, /* don't return the original resolution since we tested that one already */
|
||||
old_height + 1,
|
||||
g_ddraw->width + 1, /* don't return the original resolution since we tested that one already */
|
||||
g_ddraw->height + 1,
|
||||
g_ddraw->mode.dmPelsWidth,
|
||||
g_ddraw->mode.dmPelsHeight);
|
||||
|
||||
@ -552,8 +530,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
found_res = util_get_lowest_resolution(
|
||||
(float)g_ddraw->mode.dmPelsWidth / g_ddraw->mode.dmPelsHeight,
|
||||
&res,
|
||||
old_width,
|
||||
old_height,
|
||||
g_ddraw->width,
|
||||
g_ddraw->height,
|
||||
g_ddraw->mode.dmPelsWidth,
|
||||
g_ddraw->mode.dmPelsHeight);
|
||||
}
|
||||
@ -577,8 +555,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
if (ChangeDisplaySettings(&g_ddraw->render.mode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
/* everything failed, use windowed mode instead */
|
||||
g_ddraw->render.width = old_width;
|
||||
g_ddraw->render.height = old_height;
|
||||
g_ddraw->render.width = g_ddraw->width;
|
||||
g_ddraw->render.height = g_ddraw->height;
|
||||
|
||||
g_ddraw->render.mode.dmPelsWidth = g_ddraw->render.width;
|
||||
g_ddraw->render.mode.dmPelsHeight = g_ddraw->render.height;
|
||||
@ -590,7 +568,6 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_ddraw->render.viewport.width = g_ddraw->render.width;
|
||||
g_ddraw->render.viewport.height = g_ddraw->render.height;
|
||||
|
Loading…
x
Reference in New Issue
Block a user