Game Development Reference
In-Depth Information
glMaterialfv/glMateriali
The glMaterialfv and glMateriali functions specify material parameters for
the lighting system. Specifically, we will be using them to define the strength of
our specular lighting effect. The first parameter for both functions can either be
GL_FRONT , GL_BACK , or both combined to define if the setting should affect front or
back faces (faces pointing towards or away from the camera — which is determined
by using the normal).
We will be using them as follows:
glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
glMateriali(GL_FRONT, GL_SHININESS, 15);
The first call sets the color of the specular effect through GL_SPECULAR (we re-use
the specular variable for convenience since it already defines a white color). The
second sets the shininess ( GL_SHININESS ) to a value of 15 . Larger values produce
weaker shine effects, and vice versa.
glShadeModel
The glShadeModel() function sets the current style of lighting to either GL_FLAT
or GL_SMOOTH . This is most noticeable on objects such as spheres. Flat shading is
less computationally expensive, but provides a less believable lighting model. Even
though the performance hit is barely noticeable on modern GPUs, it can be used for
a particular artistic style, as shown in the following screenshot:
Search WWH ::




Custom Search