next up previous
Next: palm Up: Code Previous: reshape

display

This function is the main function for display of my model. It calls a lot of different functions in order to dcreate the entire hand.
void display()
{
	    gluPerspective( 40.0, 1.0 , 0.1,  120.0);	// set the perspective  40.0, 1.0, 0.1, 120.0
    glMatrixMode(GL_MODELVIEW);			// set matrix mode
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// clear the screen	
    glLoadIdentity();					// load identity matrix
    gluLookAt(0.0, 0.0, 30.0,   0.0, 0.0, 0.0,   0.0, 1.0, 0.0);	// change camara position
	
	glRotatef(double(xrot), 0, 1, 0); // rotate the screen to supply for
	glRotatef(double(yrot), 1, 0, 0); // multiple different viewing angles
	
	glPushMatrix();
	palm();   // draw the palm of the hand
	for(int x=0; x<4; x++)
	  finger(x, 2.5-1.6666666666*x, 2.85-1.0*pow((x-1), 2));// draw each finger at a different position
	thumb(); // draws the thumb
	glPopMatrix();
	glFlush();			// data to screen
    glutSwapBuffers();		// buffer the picture
    glutPostRedisplay();	// display
}
A lot fo the early function calls are just mandatory in order to create the right conditions to start making the object to be displayed. gluLookAt sets the camaras position and view. The first three coordinates are the positions of the camara. The second set of three numbers is where the camara is looking. The final set of three numbers tells the computer what directions is up for the camara. This sets the camara position and angle. The two rotation functions is a way for the user to look at different parts of the hand from different angles. Exactly how ths works will be covered in the mouse function. A matrix is then pushed to draw on. Then, the palm function is called that draws the palm of the hand. A for loop runs to create the four different fingers at different positions according to a formula. This way allows me to have only one function for the drawing of the finger instead of having a function for each finger. I could have obtained a few hundred extra lines of code by doing this, but I decided organization and compaction was a better idea. The matrix is then popped and flushed to the screen with buffering to make changes of images smooth.


next up previous
Next: palm Up: Code Previous: reshape
Michael Hull 2003-06-11