2.6 Geometry Mode

Thus far, we have talked about how to change primitive color, how to set vertex color, and the procedure for positioning lights. However, specifying rendering using these specific coloring methods is a separate matter. To select a coloring method and to switch between flat shading and smooth shading you change the "geometry mode," which was brought up in a previous chapter, but not explained at the time.

The following two macros can be used to change the geometry mode:

gSPSetGeometryMode Set the specified geometry mode
gSPClearGeometryMode Clear the specified geometry mode

These two commands pass the bit-OR of the following flags:

G_SHADE Shading
G_SHADING_SMOOTH Smooth shading
G_LIGHTING Lighting
G_CULL_FRONT Front face culling
G_CULL_BACK Back face culling
G_CULL_BOTH G_CULL_FRONT | G_CULL_BACK
G_ZBUFFER Z buffering (Chapter 7)
G_FOG Fog (Chapter 8)
G_TEXTURE_GEN Use highlights & reflection mapping (Chapter 9)
G_TEXTURE_GEN_LINEAR Use Reflection Mapping (Chapter 9)

So, for example, to color a surface using primitive color you would turn off the G_SHADE, G_SHADING_SMOOTH and G_LIGHTING flags. Then, as explained in the next section, by setting the combine mode to G_CC_PRIMITIVE you can add color using primitive color.

To color a surface using vertex color, you turn on G_SHADE and turn off G_LIGHTING. Then if G_SHADING_SMOOTH is turned off, flat shading is performed, and if it is turned on, smooth shading is performed.

For lighting, you turn on both G_SHADE and G_LIGHTING. As with vertex color, if G_SHADING_SMOOTH is turned off, then flat shading is used for rendering, and if it is turned on, then smooth shading is used.