Game Development Reference
In-Depth Information
Here '3f' indicates that three floating-point values are being passed to
the function. '3fv' indicates that a floating-point array with three compo-
nents is being passed. Check the documentation with your compiler for
the full list of parameters that can be passed. If you are used to specifying
colours using byte wide arguments for red, green and blue, then you may
find it strange to specify a colour using floating-point values. Colour levels
vary between 0 and 1.0; a colour value of 1.0 compares with the byte wide
equivalent of 255.
On a Windows-based machine, all the OpenGL functions are provided
via a dynamic link library that is stored in the 'System' folder. This library
is called 'OpenGL32.dll' and it must exist on your computer in order to use
OpenGL. It is installed by default during Windows set-up. Along with this
file, another file is installed called 'glu32.dll'; this is the OpenGL utility
library. The file contains some useful shortcuts for using OpenGL, it
simplifies view orientation set-ups and contains NURBS routines. All
OpenGL commands that begin with 'gl' use the main library and all
OpenGL commands beginning with 'glu' use the utility library. You can
achieve everything you want from OpenGL without using the utility library,
but your life will be that much more difficult.
Using the OpenGL Utility Toolkit
In addition to the main OpenGL files 'OpenGL32.dll' and 'Glu32.dll', there
is a useful library written by Mark Kilgard, called the GLUT, which stands
for the OpenGL Utility Toolkit. This library is particularly useful for quick
code examples and we will use it now to create a first window. You will find
the GLUT library and include file on the CD. If you intend to compile any
of the GLUT examples then you will need to tell your compiler where to
find the include file and the library. Other GLUT-related downloads are
available at
The example 'GLUTExample' is a simple application that displays a
coloured cube, which can be rotated with the movement of the mouse.
Here is the 'main' code for this application.
void main (void)
glutInitWindowSize(width, height);
Search Nedrilad ::

Custom Search