mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Code edits to Graphics.cpp for device lost state
This commit is contained in:
@@ -39,6 +39,12 @@ namespace sfall
|
||||
#if !(NDEBUG) && !(_DEBUG)
|
||||
static LPD3DXFONT font;
|
||||
static RECT fontPosition;
|
||||
|
||||
#define FPSOnLostDevice font->OnLostDevice();
|
||||
#define FPSOnResetDevice font->OnResetDevice();
|
||||
#else
|
||||
#define FPSOnLostDevice
|
||||
#define FPSOnResetDevice
|
||||
#endif
|
||||
|
||||
IDirectDrawSurface* primarySurface = nullptr; // aka _GNW95_DDPrimarySurface
|
||||
@@ -235,7 +241,7 @@ static void ResetDevice(bool create) {
|
||||
if (Graphics::GPUBlt == 0) palette = new PALCOLOR[256];
|
||||
|
||||
#if !(NDEBUG) && !(_DEBUG)
|
||||
D3DXCreateFontA(d3d9Device, 24, 0, 500, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &font); // create a font
|
||||
D3DXCreateFontA(d3d9Device, 24, 0, 500, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &font);
|
||||
|
||||
fontPosition.top = 10;
|
||||
fontPosition.left = 10;
|
||||
@@ -247,6 +253,7 @@ static void ResetDevice(bool create) {
|
||||
d3d9Device->Reset(¶ms);
|
||||
if (gpuBltEffect) gpuBltEffect->OnResetDevice();
|
||||
ScriptShaders::OnResetDevice();
|
||||
FPSOnResetDevice
|
||||
}
|
||||
|
||||
d3d9Device->CreateTexture(ResWidth, ResHeight, 1, 0, textureFormat, D3DPOOL_DEFAULT, &mainTexD, 0);
|
||||
@@ -404,6 +411,7 @@ static void Present() {
|
||||
Graphics::ReleaseMovieTexture();
|
||||
if (gpuBltEffect) gpuBltEffect->OnLostDevice();
|
||||
ScriptShaders::OnLostDevice();
|
||||
FPSOnLostDevice
|
||||
}
|
||||
CalcFPS();
|
||||
}
|
||||
@@ -638,6 +646,8 @@ public:
|
||||
|
||||
// called 0x4868DA movie_MVE_ShowFrame_ used for game movies (only for w/o HRP by Mash)
|
||||
HRESULT __stdcall Blt(LPRECT dst, LPDIRECTDRAWSURFACE b, LPRECT scr, DWORD d, LPDDBLTFX e) {
|
||||
if (DeviceLost && Restore() == DD_FALSE) return DDERR_SURFACELOST;
|
||||
|
||||
mveDesc.dwHeight = scr->bottom;
|
||||
mveDesc.lPitch = scr->right;
|
||||
|
||||
@@ -765,7 +775,6 @@ public:
|
||||
primaryPalette = a;
|
||||
return DD_OK; // prevents executing the function when called from outside of sfall
|
||||
}
|
||||
if (DeviceLost) return DD_OK;
|
||||
|
||||
D3DLOCKED_RECT dRect;
|
||||
mainTex->LockRect(0, &dRect, 0, 0);
|
||||
@@ -786,7 +795,7 @@ public:
|
||||
}
|
||||
|
||||
mainTex->UnlockRect(0);
|
||||
d3d9Device->UpdateTexture(mainTex, mainTexD);
|
||||
if (!DeviceLost) d3d9Device->UpdateTexture(mainTex, mainTexD);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
@@ -913,7 +922,7 @@ public:
|
||||
b++;
|
||||
} while (--c);
|
||||
paletteTex->UnlockRect(0);
|
||||
SetGPUPalette();
|
||||
if (!DeviceLost) SetGPUPalette();
|
||||
} else {
|
||||
// copy and swap color B <> R
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user