In our init function we establish the clear color and set the values used in creating our scene. Our world consists of two objects -- a checker like board and a cylinder. Part of the example is allowing the user to choose a bitmap that becomes a texture for the cylinder. The Utils library contains the class ImageMap that provides the facilities for reading and using a mapping. We use the variable imageMap for storing the pointer to a class object. Since initially there is no image map established, we set the pointer variable imageMap to NULL.

In addition to the light color, which we store in the array lightColor, we store the material color of cylinder in the array materialColor. We initialize both of these colors to white. Some of the colors for painting the squares of the checker board are mixed using the HSV color model. The HSV class definition resides in the Utils library.

The user is provided with options with respect to lighting (enabled or not) and the texture method to be used when applying the image map (MODULATE, DECAL or NONE). We store the user's choice of option in the variables enableLighting and textureChoice, which we initialize respectively with true and NONE.

Another initialization we include in Init is setting the viewing and projection transformations. We also set the lighting with a call to the function SetLighting that is part of our class CGWorld. Note that the call is made after the viewing transformation is set. Doing it in this order is important since OpenGL applies the current matrix on the model-view stack to the geometric data values of the light (e.g. position and direction). Therefore, we want our viewing transformation to be the one used when we set the lights.

Last, we establish a texture object by generating a name for the object and binding the wrapping and filter properties here.