Game Development Reference
In-Depth Information
3.4 Drawing with Vertex/Index Buffers
After we have created our vertex/index buffers and done our prepara-
tion work, we can draw our geometry, which sends the geometry
through the rendering pipeline using either DrawPrimitive or
DrawIndexedPrimitive . These methods obtain the vertex info from
the vertex streams and the index info from the currently set index
buffer.
3.4.1 IDirect3DDevice9::DrawPrimitive
This method is used to draw primitives that do not use index info.
HRESULT IDirect3DDevice9::DrawPrimitive(
D3DPRIMITIVETYPE PrimitiveType,
UINT StartVertex,
UINT PrimitiveCount
);
PrimitiveType —The type of primitive that we are drawing. For
instance, we can draw points and lines in addition to triangles.
Since we are using a triangle, use D3DPT_TRIANGLELIST for this
parameter.
StartVertex —Index to an element in the vertex streams that
marks the starting point from which to begin reading vertices. This
parameter gives us the flexibility to only draw certain portions of a
vertex buffer.
PrimitiveCount —The number of primitives to draw
Example :
// draw four triangles.
_device->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 4);
3.4.2 IDirect3DDevice9::DrawIndexedPrimitive
This method is used to draw primitives using index info.
HRESULT IDirect3DDevice9::DrawIndexedPrimitive(
D3DPRIMITIVETYPE Type,
INT BaseVertexIndex,
UINT MinIndex,
UINT NumVertices,
UINT StartIndex,
UINT PrimitiveCount
);
Type —The type of primitive that we are drawing. For instance, we
can draw points and lines in addition to triangles. Since we are
using a triangle, use D3DPT_TRIANGLELIST for this parameter.
Search WWH ::




Custom Search