About multiple vertex buffer

Started by
0 comments, last by ProgramMax 18 years, 1 month ago
When I have multiple vertex buffer, how to invoke DrawPrimitive()? For example, I create 2 vertex-buffers(named as pVB1, pVB2). I want to draw 2 Triangles: //now in the render() function if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { SetupMatrices(); g_pd3dDevice->SetStreamSource( 0, pVB1, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); g_pd3dDevice->SetStreamSource( 1, pVB2, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); g_pd3dDevice->EndScene(); } g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); But that does not work as I expect.
Advertisement
g_pd3dDevice->SetStreamSource( 0, g_pVB1, 0, sizeof(CUSTOMVERTEX) );
...
g_pd3dDevice->SetStreamSource( 1, g_pVB2, 0, sizeof(CUSTOMVERTEX) );

That second line should be SetStreamSource( 0, not 1.

The 0/1 thing is used for splitting up data between streams. For example a particle system might change the XYZ of each particle per frame, so it is very dynamic. However each particle maintains the same texture coordinates, so it is very static. This could be split into two seperate streams, 0 and 1. You can set both streams and then DrawPrimitive.

I hope this helps.

This topic is closed to new replies.

Advertisement