函数的原型例如以下所看到的:
HRESULT DrawIndexedPrimitive(
[in] D3DPRIMITIVETYPE Type,
[in] INT BaseVertexIndex,
[in] UINT MinIndex,
[in] UINT NumVertices,
[in] UINT StartIndex,
[in] UINT PrimitiveCount
);
<1> Type:D3DPRIMITIVETYPE枚举成员中的一个,表示绘制的图元类型
typedef enum D3DPRIMITIVETYPE {
D3DPT_POINTLIST = 1,
D3DPT_LINELIST = 2,
D3DPT_LINESTRIP = 3,
D3DPT_TRIANGLELIST = 4,
D3DPT_TRIANGLESTRIP = 5,
D3DPT_TRIANGLEFAN = 6,
D3DPT_FORCE_DWORD = 0x7fffffff
}D3DPRIMITIVETYPE, *LPD3DPRIMITIVETYPE;
当中D3DPT_POINTLIST表示点列
D3DPT_LINELIST表示线段列
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGR1cGQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
D3DPT_LINESTRIP表示线段带
D3DPT_TRIANGLELIST
表示三角面列
D3DPT_TRIANGLESTRIP
表示三角面带
D3DPT_TRIANGLEFAN
表示扇形面
<2> BaseVertexIndex
顶点缓存中距离第一个顶点的偏移量,这里说的都是顶点缓存中的索引。
BaseVertexIndex is a value that's effectively added to every VBIndex stored in the index buffer.
它是要加入到索引缓存中存储的顶点缓存的每个值上的。
<3> MinIndex
函数调用中最小的索引。这是以0为基础,相对于BaseVertexIndex的索引。当然是针对顶点缓存来说的。
<4> NumVertices
函数调用过程中用到的顶点数,第一个顶点是BaseVertexIndex +MinIndex
<5> StartIndex
当訪问顶点缓存的时候用到的第一个索引的的索引,
<6> PrimitiveCount
图元的个数
以下几幅图最能说明BaseVertexIndex。MiniIndex,StartIndex。以及NumVertices的含义
<1>
当BaseVertexIndex =0
此时的函数调用例如以下所看到的:
DrawIndexedPrimitive( D3DPT_TRIANGLELIST, // PrimitiveType
0, // BaseVertexIndex
0, // MinIndex
4, // NumVertices
3, // StartIndex
1 ); // PrimitiveCount
<2>
当BaseVertexIndex ≠0
此时索引缓存中的没一个值都要加上一个BaseVertexIndex的值来表示真正的索引。
函数的调用例如以下所看到的:
DrawIndexedPrimitive(D3DPT_TRIANGLELIST, // PrimitiveType
50, // BaseVertexIndex
0, // MinIndex
4, // NumVertices
3, // StartIndex
1 );