Game Development Reference
In-Depth Information
To draw the triangle we've been building up to, we can use the following code snippet:
uint16* indices = new uint16[3];
indices[0] = 0; indices[1] = 1; indices[2] = 2;
IwGxDrawPrims(IW_GX_TRI_STRIP, indices, 3);
We could simplify this a little more as the index stream isn't actually necessary in this
instance since our input streams are accessed one element at a time in the order they
occur in the stream, so we can just specify NULL for the indices parameter like this:
IwGxDrawPrims(IW_GX_TRI_STRIP, NULL, 3);
When creating the index stream there is one other point to bear in mind, which is the
order in which we supply our vertices. Because IwGx can also be used to render 3D
polygons on screen, it supports back face culling, which prevents any polygon that is
facing away from the viewer from being rendered.
How is a polygon classified as facing toward or away from the viewer? If we label
each vertex of a polygon with an incrementing number, starting with zero for the
first vertex and following around the edges of the polygon from vertex to vertex,
then a polygon is facing the viewer if its vertices form an anti-clockwise pattern
when rendered on screen and considered in ascending numerical order. The order
the vertices are supplied in is called the winding order , and the following diagram
shows this more clearly:
Putting the vertices in the correct order is not the only way to solve this problem,
but it is worth getting in the habit of ordering the vertices in this way for when we
progress to rendering 3D polygons. We can disable or reverse the back face culling
operation on a per material basis by calling the CIwMaterial::SetCullMode method
with one of the following enumeration values: CULL_FRONT , CULL_BACK , or CULL_
NONE . The default is CULL_BACK .
Search WWH ::




Custom Search