Sign in to follow this  

About multiple vertex buffer

This topic is 4274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this