I just started learning DirectX. I am currently on this chapter of the DirectX Tutorial: http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B4.aspx.
My question is simple enough but the answer will probably be complex. Please note that I am very new to directX and am only a beginner in c++.
What I'm wondering is how I can make multiple triangles using the method showed in that tutorial. Like I said I'm new to DirectX and some of the things DirectX uses are very overwhelming for me.
I do understand most of it and I have tried creating a second triangle using the same method shown in the tutorial (creating a new CUSTOMVERTEX, filling it up, going through the stages of creating a new buffer, etc.)
The part I got stuck on was when I went to draw the triangle. I couldn't find a way to implement the new triangle into one scene:
// this is the function used to render a single frame
void render_frame(void)
{
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
// select which vertex format we are using
d3ddev->SetFVF(CUSTOMFVF);
// select the vertex buffer to display
d3ddev->SetStreamSource(0, t_buffer, 0, sizeof(CUSTOMVERTEX));
// copy the vertex buffer to the back buffer
d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
return;
}
I tried adding this line after
d3ddev->SetStreamSource(0, t_buffer, 0, sizeof(CUSTOMVERTEX));
:
d3ddev->SetStreamSource(0, t_buffer2, 0, sizeof(CUSTOMVERTEX2));
I had already set up the new buffer and customvertex so I didn't get any errors. However, when I tried running it, I just got the second triangle.
I know I am doing this wrong because there can only be one StreamSource (I think).
So my question is this: how would I create a second triangle to fit this format?