-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert D3DFVF_XYZRHW into D3DFVF_XYZW #188
Changes from 7 commits
ee3a7f1
3c1ee96
ec96e85
0562725
22ab3bf
15f2241
74d067a
b147e75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,6 +330,28 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat | |
break; | ||
} | ||
|
||
if(Config.DdrawConvertHomogeneousW) | ||
{ | ||
if(dtstTransformStateType == D3DTS_VIEW) | ||
{ | ||
D3DVIEWPORT9 Viewport9; | ||
if(SUCCEEDED((*d3d9Device)->GetViewport(&Viewport9))) | ||
{ | ||
ZeroMemory(lpD3DMatrix, sizeof(_D3DMATRIX)); | ||
lpD3DMatrix->_11 = 2.0f / (float)Viewport9.Width; | ||
lpD3DMatrix->_22 = -2.0f / (float)Viewport9.Height; | ||
lpD3DMatrix->_33 = 1.0f; | ||
lpD3DMatrix->_41 = -1.0f; // translate X | ||
lpD3DMatrix->_42 = 1.0f; // translate Y | ||
lpD3DMatrix->_44 = 1.0f; | ||
} | ||
} | ||
else | ||
{ | ||
return D3D_OK; | ||
} | ||
} | ||
|
||
return (*d3d9Device)->SetTransform(dtstTransformStateType, lpD3DMatrix); | ||
} | ||
|
||
|
@@ -1760,6 +1782,28 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType, | |
|
||
if (Config.Dd7to9) | ||
{ | ||
if(Config.DdrawConvertHomogeneousW) | ||
{ | ||
// ReSharper disable once CppIncompleteSwitchStatement | ||
switch(dwRenderStateType) | ||
{ | ||
case D3DRS_CULLMODE: | ||
//dwRenderState = D3DCULL_NONE; | ||
break; | ||
|
||
case D3DRS_LIGHTING: | ||
dwRenderState = FALSE; | ||
break; | ||
|
||
case D3DRS_CLIPPLANEENABLE: | ||
//dwRenderState = 0; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
// Check for device interface | ||
if (FAILED(CheckInterface(__FUNCTION__, true))) | ||
{ | ||
|
@@ -2164,6 +2208,26 @@ HRESULT m_IDirect3DDeviceX::DrawIndexedPrimitive(D3DPRIMITIVETYPE dptPrimitiveTy | |
} | ||
else | ||
{ | ||
const UINT stride = GetVertexStride(dwVertexTypeDesc); | ||
|
||
// Handle PositionT | ||
if((dwVertexTypeDesc & D3DFVF_XYZRHW) != 0 && Config.DdrawConvertHomogeneousW) | ||
{ | ||
UINT8 *vertex = (UINT8*)lpVertices; | ||
|
||
for (UINT x = 0; x < dwVertexCount; x++) | ||
{ | ||
float *pos = (float*) vertex; | ||
|
||
pos[3] = 1.0f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you lose information here if rhw is != 1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation read that the use of W is undefined here, and not seen as part of the position vector. For me it made no difference if I had it or not. So it is probably better to just remove it then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah not sure if they use the W at all in this mode, also they also say it's "designed for, and can only be used with, the programmable vertex pipeline." So the input coordinates are in screen space and your view matrix transforms it back into clip space? https://gamedev.net/forums/topic/582097-difference-between-d3dfvf_xyzw-and-d3dfvf_xyzrhw/4705397/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SetTransform function overrides the game matrices with its own, when the mode is active.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know. |
||
|
||
vertex += stride; | ||
} | ||
|
||
// Update the FVF | ||
dwVertexTypeDesc = (dwVertexTypeDesc & ~D3DFVF_XYZRHW) | D3DFVF_XYZW; | ||
} | ||
|
||
// Set fixed function vertex type | ||
(*d3d9Device)->SetFVF(dwVertexTypeDesc); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assumes that SetTransform is called, which is not the case for DK2 for example