Skip to main content
gamedev.net
🔒 Locked

About multiple vertex buffer

Started by bsh_aoa 0 replies 600+ views
Original Post
bsh_aoa
bsh_aoa
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.
ProgramMax
ProgramMax
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.