Skip to content

Commit

Permalink
Set default Texture Perspective
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jan 21, 2025
1 parent 2cb317a commit 5e7b668
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 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 7447
#define BUILD_NUMBER 7448
23 changes: 17 additions & 6 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void m_IDirect3DDeviceX::ReleaseExecuteBuffer(LPDIRECT3DEXECUTEBUFFER lpDirect3D
}
}

inline static void CopyConvertExecuteVertex(BYTE*& DestVertex, DWORD& DestVertexCount, BYTE* SrcVertex, DWORD SrcIndex, DWORD VertexTypeDesc)
void m_IDirect3DDeviceX::CopyConvertExecuteVertex(BYTE*& DestVertex, DWORD& DestVertexCount, BYTE* SrcVertex, DWORD SrcIndex, DWORD VertexTypeDesc)
{
// Primitive structures and related defines. Vertex offsets are to types D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
if (VertexTypeDesc == D3DFVF_VERTEX)
Expand Down Expand Up @@ -3359,7 +3359,11 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_TEXTUREADDRESS: // 3
return SetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESS, dwRenderState);
case D3DRENDERSTATE_TEXTUREPERSPECTIVE: // 4
// For the IDirect3DDevice3 interface, the default value is TRUE. For earlier interfaces, the default is FALSE.
if (dwRenderState != rsTexturePerspective)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: 'D3DRENDERSTATE_ZVISIBLE' not implemented: " << dwRenderState);
}
rsTexturePerspective = dwRenderState;
return D3D_OK;
case D3DRENDERSTATE_WRAPU: // 5
rsTextureWrappingChanged = true;
Expand Down Expand Up @@ -3743,8 +3747,7 @@ HRESULT m_IDirect3DDeviceX::GetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_TEXTUREADDRESS: // 3
return GetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESS, lpdwRenderState);
case D3DRENDERSTATE_TEXTUREPERSPECTIVE: // 4
// For the IDirect3DDevice3 interface, the default value is TRUE. For earlier interfaces, the default is FALSE.
*lpdwRenderState = TRUE;
*lpdwRenderState = rsTexturePerspective;
return D3D_OK;
case D3DRENDERSTATE_WRAPU: // 5
*lpdwRenderState = rsTextureWrappingU;
Expand Down Expand Up @@ -5258,14 +5261,22 @@ void m_IDirect3DDeviceX::SetDefaults()
SetTextureStageState(5, D3DTSS_TEXCOORDINDEX, 0);
SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 0);

DWORD DirectXVersion =
WrapperInterface ? 1 :
WrapperInterface2 ? 2 :
WrapperInterface3 ? 3 : 7;

// Set color key defaults (for interface v1)
if (WrapperInterface)
if (DirectXVersion == 1)
{
rsColorKeyEnabled = true;
}

// For the IDirect3DDevice3 interface, the default value is TRUE. For earlier interfaces, the default is FALSE.
rsTexturePerspective = (DirectXVersion > 2);

// Set texture blend defaults (for interface v1, v2 and v3)
if (WrapperInterface || WrapperInterface2 || WrapperInterface3)
if (DirectXVersion < 7)
{
SetRenderState(D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
}
Expand Down
2 changes: 2 additions & 0 deletions ddraw/IDirect3DDeviceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class m_IDirect3DDeviceX : public IUnknown, public AddressLookupTableDdrawObject
// Render states
bool rsAntiAliasChanged;
DWORD rsAntiAlias;
DWORD rsTexturePerspective;
DWORD rsEdgeAntiAlias;
bool rsTextureWrappingChanged;
DWORD rsTextureWrappingU;
Expand Down Expand Up @@ -197,6 +198,7 @@ class m_IDirect3DDeviceX : public IUnknown, public AddressLookupTableDdrawObject
HRESULT CheckInterface(char *FunctionName, bool CheckD3DDevice);

// Execute buffer function
inline void CopyConvertExecuteVertex(BYTE*& DestVertex, DWORD& DestVertexCount, BYTE* SrcVertex, DWORD SrcIndex, DWORD VertexTypeDesc);
HRESULT DrawExecutePoint(D3DPOINT* point, WORD pointCount, DWORD vertexIndexCount, BYTE* vertexBuffer, DWORD VertexTypeDesc);
HRESULT DrawExecuteLine(D3DLINE* line, WORD lineCount, DWORD vertexIndexCount, BYTE* vertexBuffer, DWORD VertexTypeDesc);
HRESULT DrawExecuteTriangle(D3DTRIANGLE* triangle, WORD triangleCount, DWORD vertexIndexCount, BYTE* vertexBuffer, DWORD VertexTypeDesc);
Expand Down

0 comments on commit 5e7b668

Please sign in to comment.