|
9楼

楼主 |
发表于 2016-8-3 11:02:39
|
只看该作者
天津市天津市
D3D游戏通病,透视用第83个函数IDirect3DDevice9::DrawIndexedPrimitive实现透视
关键点:渲染前后对Z轴缓冲的过滤处理,核心代码:
HRESULT __stdcall NewDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
HRESULT hRet = S_OK;
IDirect3DVertexBuffer9* pStreamData = NULL;
UINT iOffsetInBytes,iStride;
if(D3D_OK == pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride)){
pStreamData->Release();
}
if(iStride == g_Stride){ //g_Stride为调试获得的过滤角色的Stride值
pDevice->SetRenderState(D3DRS_ZENABLE,FALSE);//禁用Z轴缓冲
hRet = OldDrawIndexedPrimitive(pDevice,type,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount);
pDevice->SetRenderState(D3DRS_ZENABLE,TRUE );//恢复Z轴缓冲
}
else{
hRet = OldDrawIndexedPrimitive(pDevice,type,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount);
}
return hRet;
}
还有这个
麻烦大神 |
|