I'm new to DirectX, and I'm trying to draw two rectangles in the same scene using D3DPT_TRIANGLESTRIP. One rectangle is not a problem, but two rectangles is a completely different ball game. Yes, I could draw them using four triangles drawn using a primitive type D3DPT_TRIANGLELIST. My curiosity is about using technology D3DPT_TRIANGLESTRIP. The parts of the code that I use for one rectangle with D3DPT_TRIANGLESTRIPare the following:
CUSTOMVERTEX recVertex[] = {
{ 10.0f, 10.0f, 0.10f, 1.0f, 0xffffffff, },
{ 220.0f, 10.0f, 0.10f, 1.0f, 0xffffffff, },
{ 10.0f, 440.0f, 0.10f, 1.0f, 0xffffffff, },
{ 220.0f, 440.0f, 0.10f, 1.0f, 0xffffffff, },
};
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 4 * sizeof( CUSTOMVERTEX ),
0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
return E_FAIL;
}
More life code ...
VOID* precVertex;
if( FAILED( g_pVB->Lock( 0, sizeof( recVertex ), ( void** )&pGameField, 0 ) ) )
{
return E_FAIL;
}
memcpy( precVertex, recVertex, sizeof( recVertex ) );
then render like this ...
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
Based on this model, I could easily duplicate the code by changing the x and y values on the user vertex and creating another vertex buffer, and this will work.
, , 100 - . , . , : D3DPT_TRIANGLESTRIP? ?