/********************************/ /* Smooth walkthrought */ /* (C) Bedrich Benes 2004 */ /* this is NOT freeware */ /* bbenes ~ at ~ purdue.edu */ /********************************/ #include #include #include #include //the main window size //could be changed inside the resize callback GLint wWindow=400; GLint hWindow=200; //position of the camera is cam, its angle is alpha GLfloat cam[3],alpha; //increments of position and angle GLfloat deltaStep=0.f; GLfloat deltaAlpha=0.f; //possible objects in the scene #define SPHERE 1 #define CUBE 2 #define TEAPOT 3 //radius of collision detection #define RAD 0.4 //object positions and types typedef struct ObjH { GLfloat pos[3]; GLubyte color[3]; int type; } ObjT; int maxObj=6; ObjT objs[] = { {{4,0,0}, {128,128,128},SPHERE}, {{0,0,-4}, {255,255,0}, CUBE}, {{10,0,-4},{0,0,255}, TEAPOT}, {{10,0,4}, {255,0,255}, TEAPOT}, {{6,0,3}, {255,255,0}, CUBE}, {{5,0,-4}, {0,0,255}, CUBE} }; void Reshape(int w, int h) { glViewport(0,0,w, h); glEnable(GL_DEPTH_TEST); //remember the settings for the camera wWindow=w; hWindow=h; //no transformations are needed here, the camera is set elsewhere } void RenderObjects() { static GLint i; //draw the ground glBegin(GL_QUADS); glColor3ub(0,128,0); glVertex3f(-100,-0.6,-100); glVertex3f(100,-0.6,-100); glVertex3f(100,-0.6,100); glVertex3f(-100,-0.6,100); glEnd(); //draw the objects for (i=0;i