1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

add new ini setting "fixchilds"

This commit is contained in:
FunkyFr3sh 2021-08-10 14:12:06 +02:00
parent a19ce92425
commit 1fde0ef382
6 changed files with 56 additions and 39 deletions

View File

@ -22,6 +22,10 @@ HRESULT dd_GetAvailableVidMem(LPDDSCAPS lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpd
HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB); HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB);
HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOuter); HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOuter);
#define FIX_CHILDS_DISABLED 0
#define FIX_CHILDS_DETECT 1
#define FIX_CHILDS_DETECT_PAINT 2
#define RESLIST_NORMAL 0 #define RESLIST_NORMAL 0
#define RESLIST_MINI 1 #define RESLIST_MINI 1
#define RESLIST_FULL 2 #define RESLIST_FULL 2
@ -117,7 +121,7 @@ typedef struct CNCDDRAW
BOOL resizable; BOOL resizable;
BOOL nonexclusive; BOOL nonexclusive;
BOOL fixpitch; BOOL fixpitch;
BOOL fixchildwindows; int fixchilds;
BOOL fixwndprochook; BOOL fixwndprochook;
BOOL d3d9linear; BOOL d3d9linear;
BOOL gdilinear; BOOL gdilinear;

View File

@ -49,7 +49,7 @@ void cfg_load()
g_ddraw->resizable = cfg_get_bool("resizable", TRUE); g_ddraw->resizable = cfg_get_bool("resizable", TRUE);
g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE);
g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE);
g_ddraw->fixchildwindows = cfg_get_bool("fixchildwindows", TRUE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT);
g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE); g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE);
g_ddraw->d3d9linear = cfg_get_bool("d3d9linear", TRUE); g_ddraw->d3d9linear = cfg_get_bool("d3d9linear", TRUE);
g_ddraw->gdilinear = cfg_get_bool("gdilinear", FALSE); g_ddraw->gdilinear = cfg_get_bool("gdilinear", FALSE);
@ -282,7 +282,7 @@ static void cfg_create_ini()
"; Should the window be resizable by the user in windowed mode?\n" "; Should the window be resizable by the user in windowed mode?\n"
"resizable=true\n" "resizable=true\n"
"\n" "\n"
"; Enable linear (D3DTEXF_LINEAR) upscaling filter for the direct3d9 renderer (16 bit color depth games only)\n" "; Enable linear (D3DTEXF_LINEAR) upscaling filter for the direct3d9 renderer\n"
"d3d9linear=true\n" "d3d9linear=true\n"
"\n" "\n"
"; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n" "; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n"
@ -329,6 +329,10 @@ static void cfg_create_ini()
"; Note: Set this to 2 if your chosen resolution is not working, set to 1 if the game is crashing\n" "; Note: Set this to 2 if your chosen resolution is not working, set to 1 if the game is crashing\n"
"resolutions=0\n" "resolutions=0\n"
"\n" "\n"
"; Child window handling, possible values: 0 = Disabled, 1 = Display top left, 2 = Display top left + repaint\n"
"; Note: Disables upscaling if a child window was detected\n"
"fixchilds=2\n"
"\n"
"\n" "\n"
"\n" "\n"
"; ### Game specific settings ###\n" "; ### Game specific settings ###\n"
@ -641,7 +645,7 @@ static void cfg_create_ini()
"\n" "\n"
"; Deadlock 2\n" "; Deadlock 2\n"
"[DEADLOCK]\n" "[DEADLOCK]\n"
"fixchildwindows=false\n" "fixchilds=0\n"
"adjmouse=false\n" "adjmouse=false\n"
"maintas=false\n" "maintas=false\n"
"boxing=false\n" "boxing=false\n"
@ -869,7 +873,7 @@ static void cfg_create_ini()
"nonexclusive=true\n" "nonexclusive=true\n"
"maxgameticks=60\n" "maxgameticks=60\n"
"adjmouse=true\n" "adjmouse=true\n"
"fixchildwindows=false\n" "fixchilds=1\n"
"maintas=false\n" "maintas=false\n"
"boxing=false\n" "boxing=false\n"
"\n" "\n"

View File

@ -421,22 +421,25 @@ DWORD WINAPI d3d9_render_main(void)
IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
} }
g_ddraw->child_window_exists = FALSE; if (g_ddraw->fixchilds)
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)
{ {
if (g_ddraw->child_window_exists) g_ddraw->child_window_exists = FALSE;
{ EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
if (!needs_update && d3d9_update_vertices(FALSE, FALSE)) if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)
needs_update = TRUE;
}
else if (needs_update)
{ {
if (d3d9_update_vertices(FALSE, TRUE)) if (g_ddraw->child_window_exists)
needs_update = FALSE; {
IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
if (!needs_update && d3d9_update_vertices(FALSE, FALSE))
needs_update = TRUE;
}
else if (needs_update)
{
if (d3d9_update_vertices(FALSE, TRUE))
needs_update = FALSE;
}
} }
} }
} }

View File

@ -72,8 +72,11 @@ DWORD WINAPI gdi_render_main(void)
if (g_ddraw->vhack) if (g_ddraw->vhack)
InterlockedExchange(&g_ddraw->upscale_hack_active, upscale_hack); InterlockedExchange(&g_ddraw->upscale_hack_active, upscale_hack);
g_ddraw->child_window_exists = FALSE; if (g_ddraw->fixchilds)
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary); {
g_ddraw->child_window_exists = FALSE;
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
}
if (g_ddraw->primary->palette) if (g_ddraw->primary->palette)
{ {

View File

@ -664,28 +664,31 @@ static void ogl_render()
g_ogl.use_opengl = FALSE; g_ogl.use_opengl = FALSE;
} }
g_ddraw->child_window_exists = FALSE; if (g_ddraw->fixchilds)
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)
{ {
if (g_ddraw->child_window_exists) g_ddraw->child_window_exists = FALSE;
{ EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
glClear(GL_COLOR_BUFFER_BIT);
if (!needs_update) if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)
{
if (g_ddraw->child_window_exists)
{ {
glViewport(0, g_ddraw->render.height - g_ddraw->height, g_ddraw->width, g_ddraw->height); glClear(GL_COLOR_BUFFER_BIT);
needs_update = TRUE;
}
}
else if (needs_update)
{
glViewport(
g_ddraw->render.viewport.x, g_ddraw->render.viewport.y,
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
needs_update = FALSE; if (!needs_update)
{
glViewport(0, g_ddraw->render.height - g_ddraw->height, g_ddraw->width, g_ddraw->height);
needs_update = TRUE;
}
}
else if (needs_update)
{
glViewport(
g_ddraw->render.viewport.x, g_ddraw->render.viewport.y,
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
needs_update = FALSE;
}
} }
} }
} }

View File

@ -374,7 +374,7 @@ BOOL CALLBACK util_enum_child_proc(HWND hwnd, LPARAM lparam)
{ {
g_ddraw->got_child_windows = g_ddraw->child_window_exists = TRUE; g_ddraw->got_child_windows = g_ddraw->child_window_exists = TRUE;
if (g_ddraw->fixchildwindows) if (g_ddraw->fixchilds == FIX_CHILDS_DETECT_PAINT)
{ {
HDC dst_dc = GetDC(hwnd); HDC dst_dc = GetDC(hwnd);
HDC src_dc; HDC src_dc;