|
|
为什么我的这个绘制有问题?
请高手指点。谢谢了
VOID Render()
{
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
SetupMatrices();
LPDIRECT3DVERTEXBUFFER9 mesh_pVB = NULL;
LPDIRECT3DINDEXBUFFER9 mesh_pIB = NULL;
HRESULT hr = g_pMesh->GetVertexBuffer( &mesh_pVB );
hr = g_pMesh->GetIndexBuffer( &mesh_pIB );
DWORD mesh_FVF = g_pMesh->GetFVF();
DWORD mesh_NumVers = g_pMesh->GetNumVertices();
g_pd3dDevice->SetFVF(mesh_FVF);
g_pd3dDevice->SetStreamSource(0,mesh_pVB,0,sizeof(mesh_FVF));
g_pd3dDevice->SetIndices( mesh_pIB);
g_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );//默认填充模式
DWORD numSubsets = 0;
g_pMesh->GetAttributeTable(0, &numSubsets);
D3DXATTRIBUTERANGE* table = new D3DXATTRIBUTERANGE[numSubsets];
g_pMesh->GetAttributeTable(table, &numSubsets);
for(DWORD i=0; i<numSubsets; i++)
{
DWORD attribId = table.AttribId;
DWORD FaceStart = table.FaceStart;
DWORD FaceCount = table.FaceCount;
DWORD VertexStart = table.VertexStart;
DWORD VertexCount = table.VertexCount;
g_pd3dDevice->SetMaterial( &g_pMeshMaterials );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures );
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0,0,
mesh_NumVers,FaceStart*3, FaceCount);
}
g_pd3dDevice->EndScene();
}
g_pd3dDevice-> resent( NULL, NULL, NULL, NULL );
}
/* 这样绘制就是对的。
for( DWORD i=0; i<g_dwNumMaterials; i++ )
{
g_pd3dDevice->SetMaterial( &g_pMeshMaterials );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures );
g_pMesh->DrawSubset( i );
}
*/ |
|