Hello forum, sorry for a noob question, I know it's a basic stuff and all that. So I have read some tutorials about basics of DX and found some complete code to draw lines, rectangles, circles, text.., combined it in my own class and it works pretty well. But I can't get how to draw triangles using primitives. I have found some code, but one problem is that I can't rotate it. Here is the code I've found:
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
DWORD tColor; // from the D3DFVF_DIFFUSE flag
};
HRESULT DrawFilledTriangleEx( FLOAT PosX, FLOAT PosY, FLOAT Size, DWORD tColourStart, DWORD tColourMid, DWORD tColourEnd, IDirect3DDevice9* Dev )
{
CUSTOMVERTEX pLine[3];
pLine[0].x = PosX;
pLine[0].y = PosY;
pLine[0].z = 1.0f;
pLine[0].rhw = 1.0f;
pLine[0].tColor = tColourStart;
pLine[1].x = PosX + Size;
pLine[1].y = PosY;
pLine[1].z = 0.0f;
pLine[1].rhw = 1.0f;
pLine[1].tColor = tColourMid;
pLine[2].x = PosX;
pLine[2].y = PosY + Size;
pLine[2].z = 0.0f;
pLine[2].rhw = 1.0f;
pLine[2].tColor = tColourEnd;
HRESULT hRet = D3D_OK;
DWORD dwFvF;
Dev->GetFVF( &dwFvF );
Dev->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
hRet = Dev->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 3, pLine, sizeof(CUSTOMVERTEX) );
Dev->SetFVF( dwFvF );
return hRet;
}
Here is the result of a function : here
So on the screen red triangle is what I got after DrawFilledTriangleEx call, white is what I want to get. I've tried to play with function code, but triangle just disappears quickly. I know I should spend the time on reading or find something different to do, but seriously everything I was able to find in examples it's just one colored triangle and no information on how to setup it's size or angle. Please sorry one more time.