Game Development Reference
In-Depth Information
void glutMotionFunc (void (* func )(int x , int y ))
This function is called as the mouse moves. The values for x and y are
the window-relative pixel coordinates of the mouse.
void glutMainLoop (void)
Enters the GLUT processing loop, never to return. Now all registered
callbacks will be used as system events instigate them.
All the calls in the main function use GLUT functions except for one, the
call to 'init'. This function is in the source file on the CD for the example.
We use 'init' to store set-up code that only needs to be called once. The
function is as follows:
void init (void)
glClearColor(0.0f, 0.2f, 0.3f, 0.0f);
printf(”Realtime 3D Character Animation with Visual C++\n”);
printf(”Chapter 3 - GLUT Example01\n\n”);
printf(”Left Mouse Button - Rotate\n”);
printf(”Right Mouse Button - Zoom In and Out\n”);
- Quits\n”);
Using the OpenGL command 'glClearColor' we set the default back-
ground colour, which includes a value for the alpha. Usually, a redraw will
begin by completely clearing the existing buffer for the colour display and
the depth buffer. The value of the clear colour will be entered for every
pixel in the cleared buffer. To ensure that z -buffering is being considered
we use the OpenGL call 'glEnable' passing the constant 'GL_DEPTH_
Setting up a projection
The 'resize' callback function is responsible for setting up how OpenGL
will convert from world space vertices to screen space. This involves a
projection from world to the flat plane of the screen. OpenGL uses
matrices to perform all mappings; once a matrix is created then
subsequent transformation commands modify it. OpenGL uses three
different matrices, the modelview , projection and the texture matrix. You
Search Nedrilad ::

Custom Search