Skip to content

Commit

Permalink
Delay device creation and fix device size
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 13, 2023
1 parent a2ce4cc commit 97b1c09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 6812
#define BUILD_NUMBER 6813
4 changes: 3 additions & 1 deletion ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
}
inline bool GetSurfaceSetSize(DWORD& Width, DWORD& Height)
{
if ((ResetDisplayFlags & (DDSD_WIDTH | DDSD_HEIGHT)) == 0 && surfaceDesc2.dwWidth && surfaceDesc2.dwHeight)
if ((surfaceDesc2.dwFlags & (DDSD_WIDTH | DDSD_HEIGHT)) == (DDSD_WIDTH | DDSD_HEIGHT) &&
(ResetDisplayFlags & (DDSD_WIDTH | DDSD_HEIGHT)) == 0 &&
surfaceDesc2.dwWidth && surfaceDesc2.dwHeight)
{
Width = surfaceDesc2.dwWidth;
Height = surfaceDesc2.dwHeight;
Expand Down
16 changes: 10 additions & 6 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,9 @@ HRESULT m_IDirectDrawX::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRE
// Get present parameters
if (Desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
Logging::LogDebug() << __FUNCTION__ << " Primary surface " << Desc2.dwWidth << "x" << Desc2.dwHeight << " ddsCaps: " << Logging::hex(Desc2.ddsCaps.dwCaps) << " " <<
Logging::hex(Desc2.ddsCaps.dwCaps2) << " " << LOWORD(Desc2.ddsCaps.dwVolumeDepth);
Logging::Log() << __FUNCTION__ << " Primary surface " << Desc2.dwWidth << "x" << Desc2.dwHeight <<
" dwFlags: " << Logging::hex(Desc2.dwFlags) <<
" ddsCaps: " << Logging::hex(Desc2.ddsCaps.dwCaps) << ", " << Logging::hex(Desc2.ddsCaps.dwCaps2) << ", " << LOWORD(Desc2.ddsCaps.dwVolumeDepth);

// Anti-aliasing
if (!Config.AntiAliasing)
Expand Down Expand Up @@ -1631,7 +1632,7 @@ HRESULT m_IDirectDrawX::SetCooperativeLevel(HWND hWnd, DWORD dwFlags, DWORD Dire
Device.NoWindowChanges = ((dwFlags & DDSCL_NOWINDOWCHANGES) != 0);

// Reset if mode was changed
if (LastExclusiveMode != ExclusiveMode || LasthWnd != DisplayMode.hWnd || LastFPUPreserve != Device.FPUPreserve || LastNoWindowChanges != Device.NoWindowChanges)
if (d3d9Device && (LastExclusiveMode != ExclusiveMode || LasthWnd != DisplayMode.hWnd || LastFPUPreserve != Device.FPUPreserve || LastNoWindowChanges != Device.NoWindowChanges))
{
CreateD3D9Device();
}
Expand Down Expand Up @@ -2761,8 +2762,8 @@ HRESULT m_IDirectDrawX::CreateD3D9Device()
}

// Get width and height
DWORD BackBufferWidth = Exclusive.Width;
DWORD BackBufferHeight = Exclusive.Height;
DWORD BackBufferWidth = Device.Width;
DWORD BackBufferHeight = Device.Height;
if (!BackBufferWidth || !BackBufferHeight)
{
if (Direct3DSurface && Direct3DSurface->GetSurfaceSetSize(BackBufferWidth, BackBufferHeight))
Expand All @@ -2783,7 +2784,10 @@ HRESULT m_IDirectDrawX::CreateD3D9Device()
else
{
// Reset display to get proper screen size
ChangeDisplaySettingsEx(nullptr, nullptr, nullptr, CDS_RESET, nullptr);
if (d3d9Device && !LastWindowedMode)
{
ChangeDisplaySettingsEx(nullptr, nullptr, nullptr, CDS_RESET, nullptr);
}
BackBufferWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
BackBufferHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
}
Expand Down

0 comments on commit 97b1c09

Please sign in to comment.