Game Development Reference
In-Depth Information
annoying flickering that can occur when a single buffer is used with
animated sequences.
OpenGL can use several buffers in addition to the actual display
buffer. In this example we use the depth buffer. The purpose of the
depth buffer is to ensure that foreground polygons appear to be in front
of more distant polygons. As each polygon is rasterized, the z distance
from the viewer is compared with the value stored in the depth buffer for
this pixel. If the z distance stored in the buffer is greater than that for the
pixel under consideration, then the new pixel is painted using the data
for the new polygon and this new z distance is stored in the depth
buffer. If the value in the buffer is less than the value under
consideration, then the current pixel is ignored because the polygon
being rasterized must be behind a polygon that has already been
void glutInitWindowSize (int width, int height )
Requests windows created by the next function to have an initial size in
pixels indicated by the width and height arguments. The initial window
size is only a hint to the system and may be overridden.
void glutCreateWindow (char * name )
Creates a window with the caption indicated by name appearing in the
title bar. The window is not actually displayed until the call to
glutMainLoop ().
GLUT functionality comes from the use of callback functions. These
functions are called in response to a system event.
void glutDisplayFunc (void (* func )(void))
This function is called whenever the contents of the window need to be
redrawn. This can happen because the window was hidden and is now
revealed or in response to a call to glutPostRedisplay ().
void glutReshapeFunc (void (* func )(int width , int height ))
The reshape function is called whenever the window is resized. The
callback is usually used to adjust the projection matrix to accommodate
for the new aspect ratio. More on this later.
void glutKeyboardFunc (void (* func )(unsigned int key , int x , int y ))
When a key is pressed, the ASCII value for this key is passed to the
argument key and the mouse coordinates in window-relative pixel
coordinates are passed to x and y .
void glutMouseFunc (void (* func )(int button , int state , int x , int y ))
The mouse function is called in response to a press or release of a
mouse button. The button argument can be GLUT_LEFT_BUTTON,
ment can be either GLUT_UP or GLUT_DOWN. The values for x and
y are window-relative pixel coordinates.
Search Nedrilad ::

Custom Search