Game Development Reference
In-Depth Information
considering the Windows platform, but most of the code will transfer
readily to other platforms. Only the short code stubs that deal with the final
display of a window will need revising for a different platform.
OpenGL is a state machine. You set a flag in the system to say how the
rendering engine should respond to subsequent commands. For
example,
glEnable(GL_LIGHTING);
Using this line in your code would ensure that the render engine would
use any active lights to determine the shading of a pixel:
glDisable(GL_LIGHTING);
This would deactivate any lighting calculations so that just the basic
colour or the direct pixels in a texture map would be painted without any
further calculations resulting from lights.
Using the different states of the render engine it is possible to display
the same geometry as:
A wireframe model with no hidden lines.
Flat shaded polygonal model with no textures and no lighting.
Flat shaded polygonal model with no textures but lighting enabled.
Smooth shaded polygonal model with no textures with lighting
enabled.
Smooth shaded polygonal model with textures and lighting.
Smooth shaded, depth-cued (fog) with textures and lighting.
Smooth shaded, depth-cued, transparency enabled with textures and
lighting.
Smooth shaded, depth-cued, transparency enabled with textures and
lighting using anti-aliasing.
The realism of the scene will increase as you work through the list, but this
occurs with an inevitable performance hit. As a developer you need to
decide between frame rate and visual realism.
All OpenGL commands begin with 'gl', then the name of the command
and finally an indication of the parameters being passed. As an example,
when indicating the colour to use the syntax can be one of the
following:
glColor3f( 1.0, 0.0, 0.0);
Glfloat col[]={ 1.0, 0.0, 0.0};
glColor3fv( col);
Search Nedrilad ::




Custom Search