Archived

This topic is now archived and is closed to further replies.

Huck

Multiple Material DrawIndexedPrimitive problem...

Recommended Posts

Hi all! i got a little problem with indexed primitives and multiple materials DrawIndexedPrimitive(), here it goes: i use a two streamsource vertex shader wich works very well. but when i have multiple materials on a mesh, i use DrawIndexedPrimitive() on each different material to render the affected faces. when i set the index buffer, my first call to DIndexPrimitive() works well, but the second call fails with the "Invalid index in the index stream: 148" error code. how can i get it to work? here''s my code: for(DWORD countRD = 0;countRD < NumMaterials;countRD++) { m_pd3dDevice->SetIndices( m_MeshIB,0); m_pd3dDevice->SetMaterial( &m_pMaterials[countRD] ); m_pd3dDevice->SetTexture( 0, m_pTextures[countRD] ); m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0, VertexCount[countRD ],VertexStart[countRD ],FaceCount [countRD ] ); } thanx for your support! C++ is the way to be... -GOD

Share this post


Link to post
Share on other sites
Just curious, but why set the indecies for X number of materials. If they are the same, no sense wasting a device state set call.

Share this post


Link to post
Share on other sites
Just curious, but why set the indecies for X number of materials. If they are the same, no sense wasting a device state set call.


"Five passengers set sail that day, for a three hour tour, a three hour tour...."

Share this post


Link to post
Share on other sites
well, in the SetIndices() function, should i use
" BaseVertexIndex" property or the "MinIndex" in DrawIndexedPrimitive() to solve my problem.

say i have a mesh with 1000 vertex and 2 materials with...
Mat1 -> Vertex 0 to 300
Mat2 -> Vertex 301 to 1000

My first call to : DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,300,0,x) succeeds, but the second one (
DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,700,301,x) fails...

whats wrong with my index buffer?

C++ is the way to be...
-GOD

Share this post


Link to post
Share on other sites