Skip to content

Commit

Permalink
Update comments and release viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jan 19, 2025
1 parent 58d9833 commit 9f143a6
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 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 7441
#define BUILD_NUMBER 7442
32 changes: 20 additions & 12 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,6 @@ HRESULT m_IDirect3DDeviceX::Load(LPDIRECTDRAWSURFACE7 lpDestTex, LPPOINT lpDestP
LOG_LIMIT(100, __FUNCTION__ << " Warning: flags not supported. dwFlags: " << Logging::hex(dwFlags));
}

// ToDo: check if source and destination surfaces are valid

if (!lprcSrcRect && (!lpDestPoint || (lpDestPoint && lpDestPoint->x == 0 && lpDestPoint->y == 0)))
{
return lpDestTex->Blt(nullptr, lpSrcTex, nullptr, 0, nullptr);
Expand Down Expand Up @@ -1787,7 +1785,6 @@ HRESULT m_IDirect3DDeviceX::GetRenderTarget(LPDIRECTDRAWSURFACE7* lplpRenderTarg
return DDERR_GENERIC;
}

// ToDo: Validate RenderTarget address
*lplpRenderTarget = CurrentRenderTarget;

CurrentRenderTarget->AddRef();
Expand Down Expand Up @@ -2126,7 +2123,6 @@ HRESULT m_IDirect3DDeviceX::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
return DDERR_INVALIDPARAMS;
}

// ToDo: Validate Viewport address
AttachedViewports.push_back(lpDirect3DViewport);

lpDirect3DViewport->AddRef();
Expand All @@ -2152,6 +2148,15 @@ HRESULT m_IDirect3DDeviceX::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
}
}

void m_IDirect3DDeviceX::ReleaseViewport(m_IDirect3DViewportX* lpViewportX)
{
if (lpViewportX == lpCurrentViewportX)
{
lpCurrentViewport = nullptr;
lpCurrentViewportX = nullptr;
}
}

HRESULT m_IDirect3DDeviceX::DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";
Expand All @@ -2163,21 +2168,21 @@ HRESULT m_IDirect3DDeviceX::DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewpor
return DDERR_INVALIDPARAMS;
}

// ToDo: Figure out what to do if an attempting to delete the SetCurrentViewport
bool ret = DeleteAttachedViewport(lpDirect3DViewport);

if (!ret)
{
return DDERR_INVALIDPARAMS;
}

// ToDo: if deleting the current material then invalidate the material

if (lpDirect3DViewport == lpCurrentViewport)
{
lpCurrentViewport = nullptr;
lpCurrentViewportX = nullptr;
}

// ToDo: Validate Viewport address
lpDirect3DViewport->Release();

return D3D_OK;
Expand Down Expand Up @@ -2246,7 +2251,6 @@ HRESULT m_IDirect3DDeviceX::NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport,
break;
}

// ToDo: Validate return Viewport address
return D3D_OK;
}

Expand Down Expand Up @@ -2300,7 +2304,6 @@ HRESULT m_IDirect3DDeviceX::SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport
D3DVIEWPORT Viewport = {};
Viewport.dwSize = sizeof(D3DVIEWPORT);

// ToDo: Validate Viewport address
HRESULT hr = lpd3dViewport->GetViewport(&Viewport);

if (SUCCEEDED(hr))
Expand Down Expand Up @@ -2359,7 +2362,6 @@ HRESULT m_IDirect3DDeviceX::GetCurrentViewport(LPDIRECT3DVIEWPORT3* lplpd3dViewp
return D3DERR_NOCURRENTVIEWPORT;
}

// ToDo: Validate Viewport address
*lplpd3dViewport = lpCurrentViewport;

lpCurrentViewport->AddRef();
Expand Down Expand Up @@ -2950,6 +2952,7 @@ HRESULT m_IDirect3DDeviceX::SetLight(m_IDirect3DLight* lpLightInterface, LPD3DLI
D3DLIGHT7 Light7;

// ToDo: the dvAttenuation members are interpreted differently in D3DLIGHT2 than they were for D3DLIGHT.

ConvertLight(Light7, *lpLight);

DWORD dwLightIndex = 0;
Expand Down Expand Up @@ -4136,7 +4139,6 @@ HRESULT m_IDirect3DDeviceX::DrawPrimitiveVB(D3DPRIMITIVETYPE dptPrimitiveType, L

dwFlags = (dwFlags & D3DDP_FORCE_DWORD);

// ToDo: Validate vertex buffer
m_IDirect3DVertexBufferX* pVertexBufferX = nullptr;
lpd3dVertexBuffer->QueryInterface(IID_GetInterfaceX, (LPVOID*)&pVertexBufferX);
if (!pVertexBufferX)
Expand Down Expand Up @@ -4402,7 +4404,6 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE dptPrimitive

dwFlags = (dwFlags & D3DDP_FORCE_DWORD);

// ToDo: Validate vertex buffer
m_IDirect3DVertexBufferX* pVertexBufferX = nullptr;
lpd3dVertexBuffer->QueryInterface(IID_GetInterfaceX, (LPVOID*)&pVertexBufferX);
if (!pVertexBufferX)
Expand Down Expand Up @@ -4855,7 +4856,6 @@ HRESULT m_IDirect3DDeviceX::GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
return DDERR_INVALIDPARAMS;
}

// ToDo: get clip status from Direct3D9
*lpD3DClipStatus = D3DClipStatus;

return D3D_OK;
Expand Down Expand Up @@ -5036,6 +5036,14 @@ void m_IDirect3DDeviceX::ReleaseInterface()
}
}

// ToDo: Clear device interface for m_IDirect3DLight

// ToDo: Clear device interface for m_IDirect3DMaterial

// ToDo: Clear device interface for m_IDirect3DVertexBuffer

// ToDo: Clear device interface for m_IDirect3DViewport

if (ddrawParent && !Config.Exiting)
{
ReleaseAllStateBlocks();
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DDeviceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class m_IDirect3DDeviceX : public IUnknown, public AddressLookupTableDdrawObject
// Viewport functions
inline void GetDefaultViewport(D3DVIEWPORT9& Viewport) const { Viewport = DefaultViewport; }
inline bool CheckIfViewportSet(m_IDirect3DViewportX* pViewport) { return (pViewport == lpCurrentViewportX); }
void ReleaseViewport(m_IDirect3DViewportX* lpViewportX);

// Texture handle function
void ReleaseTextureHandle(D3DTEXTUREHANDLE tHandle);
Expand Down
2 changes: 0 additions & 2 deletions ddraw/IDirect3DLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,4 @@ void m_IDirect3DLight::ReleaseInterface()
{
(*D3DDeviceInterface)->ReleaseLightInterface(this);
}

// ToDo: remove from AttachedLights vector
}
1 change: 0 additions & 1 deletion ddraw/IDirect3DMaterialX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ HRESULT m_IDirect3DMaterialX::GetHandle(LPDIRECT3DDEVICE3 lpDirect3DDevice, LPD3
return DDERR_GENERIC;
}

// ToDo: Validate Direct3D Device
m_IDirect3DDeviceX* pDirect3DDeviceX = nullptr;
lpDirect3DDevice->QueryInterface(IID_GetInterfaceX, (LPVOID*)&pDirect3DDeviceX);
if (!pDirect3DDeviceX)
Expand Down
1 change: 0 additions & 1 deletion ddraw/IDirect3DTextureX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ HRESULT m_IDirect3DTextureX::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice2, LPD3
return DDERR_GENERIC;
}

// ToDo: Validate Direct3D Device
m_IDirect3DDeviceX* pDirect3DDeviceX = nullptr;
lpDirect3DDevice2->QueryInterface(IID_GetInterfaceX, (LPVOID*)&pDirect3DDeviceX);
if (!pDirect3DDeviceX)
Expand Down
1 change: 0 additions & 1 deletion ddraw/IDirect3DVertexBufferX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ HRESULT m_IDirect3DVertexBufferX::ProcessVertices(DWORD dwVertexOp, DWORD dwDest
LOG_LIMIT(100, __FUNCTION__ << " Warning: 'D3DVOP_EXTENTS' not handled!");
}

// ToDo: Validate vertex buffer
m_IDirect3DVertexBufferX* pSrcVertexBufferX = nullptr;
lpSrcBuffer->QueryInterface(IID_GetInterfaceX, (LPVOID*)&pSrcVertexBufferX);

Expand Down
9 changes: 4 additions & 5 deletions ddraw/IDirect3DViewportX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ HRESULT m_IDirect3DViewportX::SetBackground(D3DMATERIALHANDLE hMat)
return DDERR_GENERIC;
}

// ToDo: validate handle
MaterialBackground.IsSet = TRUE;
MaterialBackground.hMat = hMat;

Expand Down Expand Up @@ -426,7 +425,6 @@ HRESULT m_IDirect3DViewportX::AddLight(LPDIRECT3DLIGHT lpDirect3DLight)
}
}

// ToDo: Validate Light address
AttachedLights.push_back(lpDirect3DLight);

lpDirect3DLight->AddRef();
Expand Down Expand Up @@ -466,7 +464,6 @@ HRESULT m_IDirect3DViewportX::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
return DDERR_INVALIDPARAMS;
}

// ToDo: Validate Light address
lpDirect3DLight->Release();

// If current viewport is then deactivate the light
Expand Down Expand Up @@ -541,7 +538,6 @@ HRESULT m_IDirect3DViewportX::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIREC
break;
}

// ToDo: Validate return Light address
return D3D_OK;
}

Expand Down Expand Up @@ -783,5 +779,8 @@ void m_IDirect3DViewportX::ReleaseInterface()
SaveInterfaceAddress(WrapperInterface2, WrapperInterfaceBackup2);
SaveInterfaceAddress(WrapperInterface3, WrapperInterfaceBackup3);

// ToDo: remove from AttachedViewports vector
if (D3DDeviceInterface && *D3DDeviceInterface)
{
(*D3DDeviceInterface)->ReleaseViewport(this);
}
}

0 comments on commit 9f143a6

Please sign in to comment.