mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
enables fullscreen exclusive mode for d3d9
This commit is contained in:
parent
d693217fc8
commit
c0a26ce858
@ -98,6 +98,7 @@ typedef struct IDirectDrawImpl
|
|||||||
char shader[MAX_PATH];
|
char shader[MAX_PATH];
|
||||||
BOOL wine;
|
BOOL wine;
|
||||||
int sleep;
|
int sleep;
|
||||||
|
BOOL resetDirect3D9;
|
||||||
|
|
||||||
} IDirectDrawImpl;
|
} IDirectDrawImpl;
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ void DrawFrameInfoStart()
|
|||||||
debugText,
|
debugText,
|
||||||
sizeof(debugText),
|
sizeof(debugText),
|
||||||
"FPS: %lu | Time: %2.2f ms ",
|
"FPS: %lu | Time: %2.2f ms ",
|
||||||
DebugFrameCount,
|
DebugFrameCount * 2,
|
||||||
DebugFrameTime);
|
DebugFrameTime);
|
||||||
|
|
||||||
DebugFrameCount = 0;
|
DebugFrameCount = 0;
|
||||||
tick_fps = tick_start + 1000;
|
tick_fps = tick_start + 500;
|
||||||
|
|
||||||
CounterStart();
|
CounterStart();
|
||||||
}
|
}
|
||||||
|
@ -606,6 +606,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
if (!ddraw->windowed)
|
if (!ddraw->windowed)
|
||||||
{
|
{
|
||||||
ChangeDisplaySettings(&ddraw->render.mode, CDS_FULLSCREEN);
|
ChangeDisplaySettings(&ddraw->render.mode, CDS_FULLSCREEN);
|
||||||
|
InterlockedExchange(&ddraw->resetDirect3D9, TRUE);
|
||||||
|
|
||||||
if (wParam == WA_ACTIVE)
|
if (wParam == WA_ACTIVE)
|
||||||
{
|
{
|
||||||
@ -625,6 +626,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
ShowWindow(ddraw->hWnd, SW_MINIMIZE);
|
ShowWindow(ddraw->hWnd, SW_MINIMIZE);
|
||||||
ChangeDisplaySettings(&ddraw->mode, 0);
|
ChangeDisplaySettings(&ddraw->mode, 0);
|
||||||
|
InterlockedExchange(&ddraw->resetDirect3D9, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -27,7 +27,7 @@ static void UpdateVertices(BOOL inCutscene);
|
|||||||
static BOOL Reset();
|
static BOOL Reset();
|
||||||
static void SetMaxFPS(int baseMaxFPS);
|
static void SetMaxFPS(int baseMaxFPS);
|
||||||
static void Render();
|
static void Render();
|
||||||
static void ReleaseDirect3D();
|
static BOOL ReleaseDirect3D();
|
||||||
|
|
||||||
BOOL detect_cutscene();
|
BOOL detect_cutscene();
|
||||||
DWORD WINAPI render_soft_main(void);
|
DWORD WINAPI render_soft_main(void);
|
||||||
@ -59,14 +59,12 @@ DWORD WINAPI render_d3d9_main(void)
|
|||||||
|
|
||||||
static BOOL CreateDirect3D()
|
static BOOL CreateDirect3D()
|
||||||
{
|
{
|
||||||
D3d = NULL;
|
if (!ReleaseDirect3D())
|
||||||
D3ddev = NULL;
|
return FALSE;
|
||||||
SurfaceTex = NULL;
|
|
||||||
PaletteTex = NULL;
|
if (!hD3D9)
|
||||||
D3dvb = NULL;
|
hD3D9 = LoadLibrary("d3d9.dll");
|
||||||
PixelShader = NULL;
|
|
||||||
|
|
||||||
hD3D9 = LoadLibrary("d3d9.dll");
|
|
||||||
if (hD3D9)
|
if (hD3D9)
|
||||||
{
|
{
|
||||||
IDirect3D9 *(WINAPI *D3DCreate9)(UINT) =
|
IDirect3D9 *(WINAPI *D3DCreate9)(UINT) =
|
||||||
@ -74,7 +72,7 @@ static BOOL CreateDirect3D()
|
|||||||
|
|
||||||
if (D3DCreate9 && (D3d = D3DCreate9(D3D_SDK_VERSION)))
|
if (D3DCreate9 && (D3d = D3DCreate9(D3D_SDK_VERSION)))
|
||||||
{
|
{
|
||||||
D3dpp.Windowed = TRUE;
|
D3dpp.Windowed = ddraw->windowed;
|
||||||
D3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
D3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
D3dpp.hDeviceWindow = ddraw->hWnd;
|
D3dpp.hDeviceWindow = ddraw->hWnd;
|
||||||
D3dpp.PresentationInterval = ddraw->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
D3dpp.PresentationInterval = ddraw->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
@ -99,7 +97,7 @@ static BOOL CreateDirect3D()
|
|||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
ddraw->hWnd,
|
ddraw->hWnd,
|
||||||
D3DCREATE_NOWINDOWCHANGES | behaviorFlags[i],
|
D3DCREATE_MULTITHREADED | D3DCREATE_NOWINDOWCHANGES | behaviorFlags[i],
|
||||||
&D3dpp,
|
&D3dpp,
|
||||||
&D3ddev)))
|
&D3ddev)))
|
||||||
break;
|
break;
|
||||||
@ -281,7 +279,11 @@ static void Render()
|
|||||||
|
|
||||||
HRESULT hr = D3ddev->lpVtbl->TestCooperativeLevel(D3ddev);
|
HRESULT hr = D3ddev->lpVtbl->TestCooperativeLevel(D3ddev);
|
||||||
|
|
||||||
if (hr == D3DERR_DEVICENOTRESET)
|
if (InterlockedExchange(&ddraw->resetDirect3D9, FALSE))
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
else if (hr == D3DERR_DEVICENOTRESET && D3dpp.Windowed)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
@ -308,26 +310,47 @@ static void Render()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseDirect3D()
|
static BOOL ReleaseDirect3D()
|
||||||
{
|
{
|
||||||
if (D3dvb)
|
if (D3dvb)
|
||||||
|
{
|
||||||
D3dvb->lpVtbl->Release(D3dvb);
|
D3dvb->lpVtbl->Release(D3dvb);
|
||||||
|
D3dvb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (SurfaceTex)
|
if (SurfaceTex)
|
||||||
|
{
|
||||||
SurfaceTex->lpVtbl->Release(SurfaceTex);
|
SurfaceTex->lpVtbl->Release(SurfaceTex);
|
||||||
|
SurfaceTex = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (PaletteTex)
|
if (PaletteTex)
|
||||||
|
{
|
||||||
PaletteTex->lpVtbl->Release(PaletteTex);
|
PaletteTex->lpVtbl->Release(PaletteTex);
|
||||||
|
PaletteTex = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (PixelShader)
|
if (PixelShader)
|
||||||
|
{
|
||||||
PixelShader->lpVtbl->Release(PixelShader);
|
PixelShader->lpVtbl->Release(PixelShader);
|
||||||
|
PixelShader = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (D3ddev)
|
if (D3ddev)
|
||||||
D3ddev->lpVtbl->Release(D3ddev);
|
{
|
||||||
|
if (FAILED(D3ddev->lpVtbl->Release(D3ddev)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
D3ddev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (D3d)
|
if (D3d)
|
||||||
D3d->lpVtbl->Release(D3d);
|
{
|
||||||
|
if (FAILED(D3d->lpVtbl->Release(D3d)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (hD3D9)
|
D3d = NULL;
|
||||||
FreeLibrary(hD3D9);
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user