/* ** File: dancer0.c ** Description: Uses GLU quadric objects. ** First step in creating a hierarchical ** model of a dancer. ** Rev: 1.0 ** Created: 10 September 2002 ** Last Update: 16 September 2002 ** Author: Fran Soddell ** Email: F.Soddell@bendigo.latrobe.edu.au */ #include &amp;amp;lt;GL/glut.h&amp;amp;gt; #include &amp;amp;lt;stdio.h&amp;amp;gt; #define TRUE 1 #define FALSE 0 /* ** manage 3D */ enum {x,y,z}; /* ** manage window */ int width =400; int height=400; int xPosition=50; int yPosition=70; /* ** manage world projection */ enum {xLeft,xRight,yBottom,yTop,zNear,zFar}; GLdouble world[]={ -6.0,6.0,-6.0,6.0,0.1,1000 }; GLdouble fovy =90.0; GLdouble aspect =1.0; int perspective =TRUE; /* ** manage camera */ GLdouble eye[]={ 0,1,3 }; GLdouble centre[]={ 0.0,1.0,0.0 }; GLdouble up[]={ 0.0,1.0,0.0 }; /* ** manage colour */ #define NUM_COLOURS 8 #define ALPHA 0.0 enum {red,green,blue, yellow,magenta,cyan, white,black,colours}; typedef GLfloat colourType[4]; colourType colour[NUM_COLOURS]={ {1.0,0.0,0.0,1.0},{0.0,1.0,0.0,1.0},{0.0,0.0,1.0,1.0}, {1.0,1.0,0.0,1.0},{1.0,0.0,1.0,1.0},{0.0,1.0,1.0,1.0}, {1.0,1.0,1.0,1.0},{0.0,0.0,0.0,1.0} }; /* ** *********************************************************** ** code ** *********************************************************** */ void renderDancer(){ } void renderView(){ } void setCamera(){ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye[x], eye[y],eye[z], centre[x],centre[y],centre[z], up[x],up[y],up[z]); } void display(){ setCamera(); /* ** Clear window with background colour before (re)rendering. */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderView(); glFlush(); } void setProjection(){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(!perspective) glOrtho(world[xLeft], world[xRight], world[yBottom],world[yTop], world[zNear], world[zFar]); else gluPerspective(fovy,1,world[zNear],world[zFar]); } void reshapeWindow(int w, int h){ int yOrigin=0, xOrigin=0; if(w&amp;amp;gt;h){ yOrigin=(h-w)/2; h=w; } else{ xOrigin=(w-h)/2; w=h; } glViewport(xOrigin,yOrigin,(GLsizei)w,(GLsizei)h); setProjection(); } void keyboard(unsigned char key,int xMouse,int yMouse){ switch(key){ case 27 : exit(0); case 'p': perspective=!perspective; setProjection(); break; case 'f': if(fovy&amp;amp;lt;180) fovy+=0.5; setProjection(); break; case 'F': if(fovy&amp;amp;gt;0) fovy-=0.5; setProjection(); break; } glutPostRedisplay(); } void setUpGLUT(int argc,char ** argv){ glutInit(&amp;amp;amp;argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(width,height); glutInitWindowPosition(xPosition,yPosition); glutCreateWindow(&amp;amp;quot;Hierarchical Model - Dancer&amp;amp;quot;); /* ** Register callbacks. */ glutDisplayFunc(display); glutReshapeFunc(reshapeWindow); glutKeyboardFunc(keyboard); } void initialiseGL(){ int i; glClearColor(0,0,0,ALPHA); glEnable(GL_DEPTH_TEST); } int main(int argc,char ** argv){ setUpGLUT(argc,argv); initialiseGL(); /* ** Display window and enter the GLUT event ** processing loop. */ glutMainLoop(); return 0; } &amp;lt;/pre&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</pre></body></html></pre></body></html>