I am a beginner using Direct3D C++ 2010. Trying to build Tutorial2 which shows 3 vertices for a triangle.
Works fine.
Now I need to understand how to display many triangles.
Based on suggestions from Jack Dingler,
I changed the vertices to 2 triangles as below.
Also changed the buffer parameter 3 * to 6*.
Currently it displays only the first triangle.
Which call below has the number of triangles to display?
Please help.
thanks
ayyangar
6/21
CUSTOMVERTEX vertices[] =
{
{ 250.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, { 250.0f, 250.0f, 0.5f, 1.0f, 0xffff0000, },
{ 50.0f, 250.0f, 0.5f, 1.0f, 0xfffffffff, },
{ 50.0f, 250.0f, 0.5f, 1.0f, 0xfffffffff, },
{ 50.0f, 50.0f, 0.5f, 1.0f, 0xfffffffff, },
{ 250.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, },
};
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 6 * sizeof( CUSTOMVERTEX ),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
return E_FAIL;
}
VOID Render()
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 1, 1 );