Game Development Reference
In-Depth Information
characters in your favorite FPS or fighting game are just a list of vertices that can
be joined up to make a list of triangles.
Gl.glBegin(Gl.GL_POINTS);
{
Gl.glVertex3d(-0.5, 0, 0);
Gl.glVertex3d(0.5, 0, 0);
Gl.glVertex3d(0, 0.5, 0);
}
Gl.glEnd();
Run the above code snippet. It will draw three vertices as points in a triangle
shape. To actually draw a full triangle, the argument passed into glBegin needs
to change from GL_POINTS to GL_TRIANGLES . Run the program after making
this change and you'll see a white triangle like in Figure 5.6.
GL_TRIANGLES reads three vertices and then draws a triangle using those ver-
tices. When loading meshes, it's more common to use GL_TRIANGLE_STRIP .
GL_TRIANGLE requires three vertices to draw a triangle. GL_TRIANGLE_
STRIP is similar; the first triangle requires three vertices, but then each
additional triangle only requires one more vertex. The difference is shown in
Figure 5.7.
Figure 5.6
A rendered triangle.
 
Search WWH ::




Custom Search