Original Post
Hello guys,
Im having trouble with rendering multiple meshes within my DirectX program.
I have one basic mesh that renders all the set up seems fine, then should be rendered with:
renderMesh(pd3dDevice, &g_MeshOne);
void renderMesh(ID3D10Device* pd3dDevice, CDXUTSDKMesh *mesh)
{
pd3dDevice->IASetInputLayout( g_p_VertexLayout );
UINT Strides[1];
UINT Offsets[1];
ID3D10Buffer* pVB[1];
pVB[0] = mesh->GetVB10( 0, 0 );
Strides[0] = ( UINT )mesh->GetVertexStride( 0, 0 );
Offsets[0] = 0;
pd3dDevice->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets );
pd3dDevice->IASetIndexBuffer( mesh->GetIB10( 0 ), mesh->GetIBFormat10( 0 ), 0 );
D3D10_TECHNIQUE_DESC techDesc;
g_p_Technique->GetDesc( &techDesc );
SDKMESH_SUBSET* pSubset = NULL;
ID3D10ShaderResourceView* pDiffuseRV = NULL;
D3D10_PRIMITIVE_TOPOLOGY PrimType;
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for( UINT subset = 0; subset < mesh->GetNumSubsets( 0 ); ++subset )
{
pSubset = mesh->GetSubset( 0, subset );
PrimType = mesh->GetPrimitiveType10( ( SDKMESH_PRIMITIVE_TYPE )pSubset->PrimitiveType );
pd3dDevice->IASetPrimitiveTopology( PrimType );
pDiffuseRV = mesh->GetMaterial( pSubset->MaterialID )->pDiffuseRV10;
g_p_txDiffuseInShader->SetResource( pDiffuseRV );
g_p_Technique->GetPassByIndex( p )->Apply( 0 );
pd3dDevice->DrawIndexed( ( UINT )pSubset->IndexCount, 0, ( UINT )pSubset->VertexStart );
}
}
}
However if I try and render another with renderMesh(pd3dDevice, &g_MeshTwo);
It seems they overwrite each other. Any help will be greatly appreciated, i'm just a beginner so please go easy on me.
Im having trouble with rendering multiple meshes within my DirectX program.
I have one basic mesh that renders all the set up seems fine, then should be rendered with:
renderMesh(pd3dDevice, &g_MeshOne);
void renderMesh(ID3D10Device* pd3dDevice, CDXUTSDKMesh *mesh)
{
pd3dDevice->IASetInputLayout( g_p_VertexLayout );
UINT Strides[1];
UINT Offsets[1];
ID3D10Buffer* pVB[1];
pVB[0] = mesh->GetVB10( 0, 0 );
Strides[0] = ( UINT )mesh->GetVertexStride( 0, 0 );
Offsets[0] = 0;
pd3dDevice->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets );
pd3dDevice->IASetIndexBuffer( mesh->GetIB10( 0 ), mesh->GetIBFormat10( 0 ), 0 );
D3D10_TECHNIQUE_DESC techDesc;
g_p_Technique->GetDesc( &techDesc );
SDKMESH_SUBSET* pSubset = NULL;
ID3D10ShaderResourceView* pDiffuseRV = NULL;
D3D10_PRIMITIVE_TOPOLOGY PrimType;
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for( UINT subset = 0; subset < mesh->GetNumSubsets( 0 ); ++subset )
{
pSubset = mesh->GetSubset( 0, subset );
PrimType = mesh->GetPrimitiveType10( ( SDKMESH_PRIMITIVE_TYPE )pSubset->PrimitiveType );
pd3dDevice->IASetPrimitiveTopology( PrimType );
pDiffuseRV = mesh->GetMaterial( pSubset->MaterialID )->pDiffuseRV10;
g_p_txDiffuseInShader->SetResource( pDiffuseRV );
g_p_Technique->GetPassByIndex( p )->Apply( 0 );
pd3dDevice->DrawIndexed( ( UINT )pSubset->IndexCount, 0, ( UINT )pSubset->VertexStart );
}
}
}
However if I try and render another with renderMesh(pd3dDevice, &g_MeshTwo);
It seems they overwrite each other. Any help will be greatly appreciated, i'm just a beginner so please go easy on me.