Game Development Reference
other values will result in some interesting scenes (just use your imagination and the
tree/hill/sky example from earlier).
So with this knowledge, inside the Initialize() function, we create a light at po-
sition ( 5,10,1 ) with ambient, diffuse, and specular properties, set the shading mod-
el to smooth lighting ( GL_SMOOTH ), and set the depth testing function to only over-
write pixels if their depth value is less than the existing value ( GL_LESS ). And voila!
We have lighting enabled in our scene. Here is our box with basic lighting applied:
Coloring your box
If you recall, we called glColor3f() in our DrawBox() function, and set the de-
fault color parameter in the function's declaration to an RGB value of ( 1,1,1 ). This
represents the white color: 100 percent red, green, and blue in additive coloring.
Since we're not passing a value for this parameter in our DrawBox() call, it is still
defaulting to white. Therefore, in order to change the color of our box, we simply add
a color value to our DrawBox() call in the form of a btVector3 .