GlColor

You use glColor to set the default color for the subsequent drawing that takes place. In the following code segment, the method glColor4f sets the color to red:

//Set the current color glColor4f(1.0f, 0, 0, 0.5f);

Recall the discussion about method nomenclature: 4f refers to the four arguments that the method takes, each of which is a float. The four arguments are components of red, green, blue, and alpha (color gradient). The starting values for each are (1,1,1,1). In this case, we have set the color to red with half a gradient (specified by the last alpha argument).

Although we have covered the basic drawing APIs, we still need to address a few things regarding the coordinates of the points that you specify in 3D space. The next subsection explains how OpenGL models a real-world scene through the viewing perspective of an observer looking through a camera.

0 0

Post a comment