direct3d 三角形
有个问题请教各位大哥,我利用direct3D创建了一个三角形,代码如下(由于参数太长,为了方便,我换成了具体的数字,在我的程序中,三角形是能够建立成功的)我现在想把三角形填充成红色或者其他颜色,请问各位大哥 我具体该怎么做?O(∩_∩)O谢谢#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
struct CUSTOMVERTEX1
{
FLOAT x, y, z;
DWORD color;
};
LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; //顶点缓冲区对象
int x=0;
if(x==0)
{
vertices9[0].x = 6.0f;
vertices9[0].y = 6.0f;
vertices9[0].z = 0.0f;
vertices9[0].color = 0xff0000ff;//蓝色
vertices9[1].x=4.5f;//"\"
vertices9[1].y=6.0f;
vertices9[1].z = 0.0f;
vertices9[1].color = 0xff0000ff;//蓝色
vertices9[2].x=1.5f;
vertices9[2].y=3.0f;
vertices9[2].z = 0.0f;
vertices9[2].color = 0xff0000ff;//蓝色
vertices9[3].x = 6.0f;
vertices9[3].y = 6.0f
vertices9[3].z = 0.0f;
vertices9[3].color = 0xff0000ff;//蓝色
vertices9[4].x=4.5f;//"\"
vertices9[4].y=6;
vertices9[4].z = 0.0f;
vertices9[4].color = 0xff0000ff;//蓝色
vertices9[5].x=1.5f;
vertices9[5].y=3.0f;
vertices9[5].z = 0.0f;
vertices9[5].color = 0xff0000ff;//蓝色
//创建顶点缓冲区
pd3dDevice->CreateVertexBuffer( 6*sizeof(CUSTOMVERTEX1), 0, D3DFVF_CUSTOMVERTEX1, D3DPOOL_DEFAULT, &g_pVB1, NULL);
//填充顶点缓冲区
g_pVB1->Lock(0, sizeof(vertices9), (void **) &pVertices, 0);
memcpy(pVertices, vertices9, sizeof(vertices9));
g_pVB1->Unlock();
pd3dDevice->SetStreamSource(0, g_pVB1, 0, sizeof(CUSTOMVERTEX1));
pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX1);
pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 0, 3);//最后一个为绘制顶点的数目
//释放顶点缓冲区对象
SAFE_RELEASE(g_pVB1);
}