I am trying to get DirectX to draw a triangle in a single function. The function works, but I can only draw a single time, any ideas? I don't really know what other information to provide.
Code:
void graphics::fillTriangle(float x, float y, float x2, float y2, float x3, float y3, int r, int g, int b, int a)
{
Vertex vertexs[] =
{
{ x, y, 1.0f, 1.0f, D3DCOLOR_RGBA(r, g, b, a) },
{ x2, y, 1.0f, 1.0f, D3DCOLOR_RGBA(r, g, b, a) },
{ x2, y2, 1.0f, 1.0f, D3DCOLOR_RGBA(r, g, b, a) },
};
VOID* pVoid;
d3dDevice->CreateVertexBuffer(3*sizeof(Vertex), 0, CUSTOMFVF, D3DPOOL_MANAGED, &vBuffer, NULL);
vBuffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertexs, sizeof(vertexs));
vBuffer->Unlock();
d3dDevice->SetFVF(CUSTOMFVF);
d3dDevice->SetStreamSource(0, vBuffer, 0, sizeof(Vertex));
d3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
vBuffer->Release();
}