Example: 3D Geometry

The Geometry example illustrates some basic concepts of Fastgraph's 3D geometry system. After performing the usual initialization tasks, the Geometry program's WM_CREATE handler creates and opens a z-buffer, sets the render state to enable z-buffering, and defines a 3D viewport. After doing this, the WM_CREATE handler calls the program's DrawCubes() function to draw two cubes, one in 3D world space and the other in object space, along with (x,y,z) coordinate axes. DrawCubes() also sets the POV so we can see all three axes and then calls fg_3Dmoveobject() to define where the world space cube will be drawn. It then draws the cube faces in a loop, alternating between calls to fg_3Dpolygon() to draw one face of the world space cube and fg_3Dpolygonobject() to draw one face of the object space cube, with each cube face a different color. The world space cube is centered at the world space origin, while the object space cube is centered on the z axis at z=20. The result looks like this:

If we didn't use z-buffering, the coordinate axes would not extend into and out of each cube. Instead, the cube faces would completely overwrite the axes, giving the misleading appearance of the axes being behind the cubes.

C/C++ version

C++Builder version

Delphi version

Visual Basic version

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.