Skip to content

Commit

Permalink
Implement basic Get/SetViewport
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Mar 8, 2024
1 parent bf692c6 commit e89dcce
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 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 6951
#define BUILD_NUMBER 6952
60 changes: 40 additions & 20 deletions ddraw/IDirect3DViewportX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,21 @@ HRESULT m_IDirect3DViewportX::GetViewport(LPD3DVIEWPORT lpData)
return DDERR_INVALIDPARAMS;
}

if (!IsDataSet)
if (!D3DDeviceInterface || !*D3DDeviceInterface)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: Viewport not set!");
LOG_LIMIT(100, __FUNCTION__ << " Error: no D3DirectDevice interface!");
return DDERR_GENERIC;
}

*lpData = ViewportData;
D3DVIEWPORT7 Viewport7 = {};
HRESULT hr = (*D3DDeviceInterface)->GetViewport(&Viewport7);

return D3D_OK;
if (SUCCEEDED(hr))
{
ConvertViewport(*lpData, Viewport7);
}

return hr;
}

return ProxyInterface->GetViewport(lpData);
Expand All @@ -193,17 +200,22 @@ HRESULT m_IDirect3DViewportX::SetViewport(LPD3DVIEWPORT lpData)
return DDERR_INVALIDPARAMS;
}

if (!D3DDeviceInterface || !*D3DDeviceInterface)
{
LOG_LIMIT(100, __FUNCTION__ << " Error: no D3DirectDevice interface!");
return DDERR_GENERIC;
}

if (lpData->dvScaleX != 0 || lpData->dvScaleY != 0 || lpData->dvMaxX != 0 || lpData->dvMaxY != 0)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: 'Scale homogeneous' Not Implemented: " <<
" ScaleX: " << lpData->dvScaleX << " ScaleY: " << lpData->dvScaleY << " MaxX: " << lpData->dvMaxX << " MaxY: " << lpData->dvMaxY);
}

IsDataSet = true;
ViewportData = *lpData;
ConvertViewport(ViewportData2, *lpData);
D3DVIEWPORT7 Viewport7 = {};
ConvertViewport(Viewport7, *lpData);

return D3D_OK;
return (*D3DDeviceInterface)->SetViewport(&Viewport7);
}

if (Config.DdrawUseNativeResolution && lpData)
Expand Down Expand Up @@ -392,14 +404,21 @@ HRESULT m_IDirect3DViewportX::GetViewport2(LPD3DVIEWPORT2 lpData)
return DDERR_INVALIDPARAMS;
}

if (!IsDataSet)
if (!D3DDeviceInterface || !*D3DDeviceInterface)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: Viewport not set!");
LOG_LIMIT(100, __FUNCTION__ << " Error: no D3DirectDevice interface!");
return DDERR_GENERIC;
}

*lpData = ViewportData2;
D3DVIEWPORT7 Viewport7 = {};
HRESULT hr = (*D3DDeviceInterface)->GetViewport(&Viewport7);

return D3D_OK;
if (SUCCEEDED(hr))
{
ConvertViewport(*lpData, Viewport7);
}

return hr;
}

return ProxyInterface->GetViewport2(lpData);
Expand All @@ -417,17 +436,22 @@ HRESULT m_IDirect3DViewportX::SetViewport2(LPD3DVIEWPORT2 lpData)
return DDERR_INVALIDPARAMS;
}

if (!D3DDeviceInterface || !*D3DDeviceInterface)
{
LOG_LIMIT(100, __FUNCTION__ << " Error: no D3DirectDevice interface!");
return DDERR_GENERIC;
}

if (lpData->dvClipWidth != 0 || lpData->dvClipHeight != 0 || lpData->dvClipX != 0 || lpData->dvClipY != 0)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: 'clip volume' Not Implemented: " <<
lpData->dvClipWidth << "x" << lpData->dvClipHeight << " X: " << lpData->dvClipX << " Y: " << lpData->dvClipY);
}

IsDataSet = true;
ViewportData2 = *lpData;
ConvertViewport(ViewportData, *lpData);
D3DVIEWPORT7 Viewport7 = {};
ConvertViewport(Viewport7, *lpData);

return D3D_OK;
return (*D3DDeviceInterface)->SetViewport(&Viewport7);
}

if (Config.DdrawUseNativeResolution && lpData)
Expand Down Expand Up @@ -512,10 +536,6 @@ void m_IDirect3DViewportX::InitViewport(DWORD DirectXVersion)
return;
}

// ToDo: set default viewport data
ViewportData.dwSize = sizeof(D3DVIEWPORT);
ViewportData2.dwSize = sizeof(D3DVIEWPORT2);

AddRef(DirectXVersion);
}

Expand Down
5 changes: 0 additions & 5 deletions ddraw/IDirect3DViewportX.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class m_IDirect3DViewportX : public IUnknown, public AddressLookupTableDdrawObje
ULONG RefCount2 = 0;
ULONG RefCount3 = 0;

// Viewport data
bool IsDataSet = false;
D3DVIEWPORT ViewportData = {};
D3DVIEWPORT2 ViewportData2 = {};

// Convert Viewport
m_IDirect3DDeviceX **D3DDeviceInterface = nullptr;

Expand Down

0 comments on commit e89dcce

Please sign in to comment.