当我尝试使用 D3DPT_TRIANGLELIST 时遇到问题。以下示例来自一本书,所以我看不出问题出在哪里。
顶点数据:
ColorVertex *v;
Triangle->Lock(0,0,(void**)&v,0);
v[0] = ColorVertex(-1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(255, 0,0));
v[1] = ColorVertex(0.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(0,255,0));
v[2] = ColorVertex(1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(0,0,255));
Triangle->Unlock();
绘图功能:
Device->SetFVF(ColorVertex::FVF);
Device->SetStreamSource(0,Triangle,0,sizeof(ColorVertex));
D3DXMatrixTranslation(&World,-1.25f,0.0f,0.0f);
Device->SetTransform(D3DTS_WORLD,&World);
Device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
D3DXMatrixTranslation(&World,1.25f,0.0f,0.0f);
Device->SetTransform(D3DTS_WORLD,&World);
Device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
Device->EndScene();
Device->Present(0,0,0,0);
但是,如果我从 D3DPT_TRIANGLELIST 更改为例如 D3DPT_LINELIST 它会画一条线。如果我使用 D3DPT_POINTLIST,它只会为每个 DrawPrimite 调用绘制一个点(像素)。
谢谢你的帮助!