void draw(void) { GLenum err; GLdouble secs; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_room(); draw_cone(); /* draw the front and then the back faces (essentially sorts the polygons). */ secs = get_secs(); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_sphere(secs * 360. / 10.); glCullFace(GL_BACK); draw_sphere(secs * 360. / 10.); glDisable(GL_CULL_FACE); glDisable(GL_BLEND); err = glGetError(); if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err)); glutSwapBuffers(); }
void draw(void) { GLenum err; GLdouble secs, degrees; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* one revolution every 10 seconds... */ secs = get_secs(); secs = secs - 10.*trunc(secs / 10.); degrees = (secs/10.) * (360.); draw_room(); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_cone(); draw_sphere(degrees); glCullFace(GL_BACK); draw_cone(); draw_sphere(degrees); glDisable(GL_CULL_FACE); glDisable(GL_BLEND); err = glGetError(); if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err)); glutSwapBuffers(); }
int Tile3d::draw_tiles(SDL_Surface **screen, int tilemap[], double transx, double transy) { volatile int i = 0; register int j = 0; for (j = 0; j < 15; j++) { for (i = 0; i < 20; i++) { switch (tilemap[i+j*20]){ case 1:{ draw_tile3d1grass(screen, i*32, j*32,transx,transy); break; } case 2:{ draw_tile3d2grass(screen, i*32, j*32,transx,transy); break; } case 3:{ draw_tile3d3door(screen, i*32, j*32,transx,transy); break; } case 4:{ draw_sphere(screen, i*32, j*32,transx,transy); break; } default:{ break; } } } } return 0; }
object * init_sphere(double x, double y, double z, double vx, double vy, double vz, int on) { object * obj = malloc(sizeof(object)); obj->object_number = on; obj->id = SPHERE_ID; obj->movable = 1; obj->should_fill = 0; obj->visible = 1; obj->x = x; obj->y = y; obj->z = z; obj->vx = vx; obj->vy = vy; obj->vz = vz; obj->rx = .01; obj->ry = .01; obj->rz = 0; obj->theta_x = 0; obj->theta_y = 0; obj->theta_z = 0; obj->r = .5; obj->mat = malloc(sizeof(matrix)); *(obj->mat) = init_identity(4); draw_sphere(0, 0, 0, 1, obj->mat); return obj; }
static GLuint get_sphere_display_list(int divisions) { static bool initialized = false; static const int num_display_lists = MAX_SPHERE_DIVISIONS - MIN_SPHERE_DIVISIONS + 1; static GLuint display_lists[num_display_lists]; if(!initialized){ initialized = true; for(int i=0; i<num_display_lists; i++){ display_lists[i] = 0; } } const int idx = divisions - MIN_SPHERE_DIVISIONS; PP_ENSURE(idx >= 0 && idx < num_display_lists, "invalid number of sphere subdivisions" ); if(display_lists[idx]==0){ // Initialize the sphere display list display_lists[idx] = gl::GenLists(1); gl::NewList( display_lists[idx], GL_COMPILE ); draw_sphere( divisions ); gl::EndList(); } return display_lists[idx]; }
void traverse_dag_sub( scene_node_t *node, material_t *mat ) { scene_node_t *child; glm::mat4 matrix; int i,j; check_assertion( node != NULL, "node is NULL" ); hier_push_mat(); for( i = 0; i < 4; i++ ) { for( j = 0; j < 4; j++ ) matrix[i][j] = node->trans[i][j]; } hier_mult_mat(matrix); if ( node->mat != NULL ) { mat = node->mat; } if ( node->geom == Sphere ) { //FIXME draw_sphere(std::min(MAX_SPHERE_DIVISIONS, std::max(MIN_SPHERE_DIVISIONS, ROUND_TO_NEAREST(node->param.sphere.divisions))), mat); } child = node->child; while (child != NULL) { traverse_dag_sub( child, mat ); child = child->next; } hier_pop_mat(); }
/*TODO: expand according to assignment 2 specs*/ void draw_object(int shape) { switch(shape) { case HOUSE: draw_house(); break; case CUBE: draw_cube_brute(); break; case CYLINDER: draw_cylinder(crt_rs, crt_vs); break; case SPHERE: draw_sphere(crt_rs, crt_vs); break; case TORUS: /*TODO EC: call your function here*/ ; break; case MESH: /*TODO EC: call your function here*/ ; break; default: break; } }
void draw_scene(GLdouble degrees, GLint bits) { glEnable(GL_CULL_FACE); draw_room(); if (bits & TORUS_BIT) draw_torus(degrees); if (bits & SPHERE_BIT) draw_sphere(degrees); }
static void draw_scene() { // stars: to simulate infinite distance, // translate the sphere of stars to the eye // and perform the arcball rotation around the eye // (also disable depth test so they become the background) glPushMatrix(); glDisable( GL_DEPTH_TEST ); glTranslatef( eye.x, eye.y, eye.z ); arcball_rotate(); draw_stars(); glEnable( GL_DEPTH_TEST ); glPopMatrix(); // now render the regular scene under the arcball rotation about 0,0,0 // (generally you would want to render everything here) arcball_rotate(); draw_sphere(); }
void draw(void) { GLenum err; GLdouble secs; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_room(); draw_cone(); glEnable(GL_BLEND); secs = get_secs(); draw_sphere(secs * 360. / 10.); glDisable(GL_BLEND); err = glGetError(); if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err)); glutSwapBuffers(); }
void draw(void) { GLenum err; GLdouble secs; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_room(); draw_cone(); secs = get_secs(); /* draw the transparent object... */ glEnable(GL_POLYGON_STIPPLE); draw_sphere(secs * 360. / 10.); glDisable(GL_POLYGON_STIPPLE); err = glGetError(); if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err)); glutSwapBuffers(); }
static void render_to_fbo(void) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO); glViewport(0, 0, SIZE, SIZE); glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1, 1.0); glColor4f(1.0, 0.0, 0.0, 0.0); draw_sphere(); glDisable(GL_DEPTH_TEST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); }
/** * Draw quad with fragment shader that compares fragment.z against the * depth texture value (draw on left side of window). * We draw on the left side of the window to easily convert gl_FragCoord * into a texture coordinate. */ static void draw_sphere_with_fragment_shader_compare(void) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0 * SIZE, 0, SIZE, SIZE); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1, 1.0); glBindTexture(TexTarget, DepthTex); piglit_UseProgram(ShaderProg); glEnable(GL_DEPTH_TEST); if (1) { draw_sphere(); } else { /* To test using gl_TexCoord[0].xy instead of gl_FragCoord.xy in the shader */ static const GLfloat sPlane[4] = {0.5, 0, 0, 0.5}; static const GLfloat tPlane[4] = {0, 0.5, 0, 0.5}; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGenfv(GL_S, GL_EYE_PLANE, sPlane); glTexGenfv(GL_T, GL_EYE_PLANE, tPlane); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); draw_sphere(); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } glDisable(GL_DEPTH_TEST); piglit_UseProgram(0); #if DEBUG { GLfloat *z = read_float_z_image(0, 0); GLfloat min, max, center; find_float_min_max_center(z, SIZE * SIZE, &min, &max, ¢er); printf("rendered min %f max %f center %f\n", min, max, center); free(z); } { GLuint *z = read_uint_z_image(0, 0); GLuint min, max, center; find_uint_min_max_center(z, SIZE * SIZE, &min, &max, ¢er); printf("rendered min 0x%x max 0x%x center 0x%x\n", min, max, center); free(z); } #endif /* DEBUG */ }
//draw the main object void draw_man(){ stacks.push(modelM); // modelM *= Mtranslate(0,-ii,0); modelM *= Mrotate(angle_whole,0,0,1); // modelM *= Mtranslate(0,ii,0); //modelM *= Mtranslate(0,-ii,0); //modelM = modelM*Mrotate(angle_whole,0,0,1); //modelM *= Mtranslate(0,ii,0); //ii=0; stacks.push(modelM); //Head and nose modelM = modelM*Mrotate(angle_head,0,0,1); modelM = modelM*Mtranslate(0,0,5); draw_sphere(1.5,12,12,c1,modelM);//head modelM = modelM*Mtranslate(0,-2,0); modelM = modelM*Mtranslate(0,1,0); modelM = modelM*Mrotate(angle_nose,0,0,1); modelM = modelM*Mtranslate(0,-1,0); modelM = modelM*Mrotate(90,1,0,0); draw_cylinder(0.2,0.1,1,12,c4,false,modelM);//nose //draw_cube(1,c2,modelM); //Left arm and body modelM=stacks.top(); modelM = modelM * Mtranslate(0,0,2); draw_cylinder(2,1,4,12,c6,false,modelM);//Body modelM = modelM * Mtranslate(-2,0,1); modelM = modelM*Mrotate(90,0,1,0); modelM = modelM*Mtranslate(0,0,1); modelM = modelM*Mrotate(angle_larm,0,1,0); modelM = modelM*Mtranslate(0,0,-1); draw_cylinder(0.5,0.8,2,12,c3,false,modelM);//L Arm modelM = modelM * Mtranslate(0,0,-1); draw_sphere(0.5,12,12,c1,modelM); // L connector // modelM = modelM*Mtranslate(0,0,1); modelM = modelM*Mrotate(angle_lhand,0,1,0); // modelM = modelM*Mtranslate(0,0,-1); modelM = modelM * Mtranslate(0,0,-1); draw_cylinder(0.1,0.5,2,12,c5,false,modelM); //Right arm modelM=stacks.top(); modelM = modelM*Mtranslate(2,0,3); modelM = modelM*Mrotate(-90,0,1,0); modelM = modelM*Mtranslate(0,0,1); modelM = modelM*Mrotate(angle_rarm,0,1,0); modelM = modelM*Mtranslate(0,0,-1); draw_cylinder(0.5,0.8,2,12,c3,false,modelM);//R Arm modelM = modelM * Mtranslate(0,0,-1); draw_sphere(0.5,12,12,c1,modelM); // R connector // modelM = modelM*Mtranslate(0,0,1); modelM = modelM*Mrotate(angle_rhand,0,1,0); // modelM = modelM*Mtranslate(0,0,-1); modelM = modelM * Mtranslate(0,0,-1); draw_cylinder(0.1,0.5,2,12,c5,false,modelM); //legs modelM=stacks.top(); modelM = modelM*Mtranslate(1,0,-2); modelM = modelM*Mscale(0.7,0.7,4); draw_cube(1,c3,modelM); modelM=stacks.top(); modelM = modelM*Mtranslate(-1,0,-2); modelM = modelM*Mscale(0.7,0.7,4); draw_cube(1,c3,modelM); stacks.pop(); modelM=stacks.top(); stacks.pop(); }
void render(void) { int i; allegro_gl_begin(); glClearColor(0.1, 0.2, 0.2, 1); glClear(GL_DEPTH_BUFFER_BIT); glLoadIdentity(); const dReal * ballpos = dBodyGetPosition(ball.body); const dReal * machpos0 = dBodyGetPosition(machine[0].body[0]); const dReal * machpos1 = dBodyGetPosition(machine[1].body[0]); camera.adjust(ballpos[0], ballpos[1], machpos0[0], machpos0[1], machpos1[0], machpos1[1], camerazoomtime*court.x*2-50*camerazoomtime); GLfloat LightAmbient[]= { 0.7, 0.7, 0.7, 1.0 }; GLfloat LightDiffuse[]= { 1.0, 1.0, 1.0, 1.0 }; GLfloat LightPosition[]= { -300.0, -300.0, 1000.0, 1.0 }; glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, floortex); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glColor3f(0.8, 0.8, 0.8); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-court.x-300, -court.y-300, 0); glTexCoord2f(10, 0); glVertex3f(court.x+300, -court.y-300, 0); glTexCoord2f(10, 10); glVertex3f(court.x+300, court.y+300, 0); glTexCoord2f(0, 10); glVertex3f(-court.x-300, court.y+300, 0); glEnd(); glColor3f(1, 1, 1); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glBindTexture(GL_TEXTURE_2D, floortex); glBegin(GL_QUADS); glNormal3f(0, 0, 1); glTexCoord2f(0, 0); glVertex3f(-court.x-30, -court.y, 0); glTexCoord2f(court.x/30, 0); glVertex3f(court.x+30, -court.y, 0); glTexCoord2f(court.x/30, court.y/30); glVertex3f(court.x+30, court.y, 0); glTexCoord2f(0, court.y/30); glVertex3f(-court.x-30, court.y, 0); glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-1, -court.y, 0); glVertex3f(1, -court.y, 0); glVertex3f(1, court.y, 0); glVertex3f(-1, court.y, 0); glVertex3f(-court.x, court.y/2, 0); glVertex3f(-court.x/1.5, court.y/2, 0); glVertex3f(-court.x/1.5, court.y/2-1, 0); glVertex3f(-court.x, court.y/2-1, 0); glVertex3f(-court.x, -court.y/2, 0); glVertex3f(-court.x/1.5, -court.y/2, 0); glVertex3f(-court.x/1.5, -court.y/2+1, 0); glVertex3f(-court.x, -court.y/2+1, 0); glVertex3f(-court.x/1.5, court.y/2, 0); glVertex3f(-court.x/1.5+1, court.y/2, 0); glVertex3f(-court.x/1.5+1, -court.y/2, 0); glVertex3f(-court.x/1.5, -court.y/2, 0); glVertex3f(court.x, court.y/2, 0); glVertex3f(court.x/1.5, court.y/2, 0); glVertex3f(court.x/1.5, court.y/2-1, 0); glVertex3f(court.x, court.y/2-1, 0); glVertex3f(court.x, -court.y/2, 0); glVertex3f(court.x/1.5, -court.y/2, 0); glVertex3f(court.x/1.5, -court.y/2+1, 0); glVertex3f(court.x, -court.y/2+1, 0); glVertex3f(court.x/1.5, court.y/2, 0); glVertex3f(court.x/1.5+1, court.y/2, 0); glVertex3f(court.x/1.5+1, -court.y/2, 0); glVertex3f(court.x/1.5, -court.y/2, 0); glVertex3f(-court.x-1, -35, 0); glVertex3f(-court.x, -35, 0); glVertex3f(-court.x, 35, 0); glVertex3f(-court.x-1, 35, 0); glVertex3f(court.x, -35, 0); glVertex3f(court.x+1, -35, 0); glVertex3f(court.x+1, 35, 0); glVertex3f(court.x, 35, 0); glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, shadowtex); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glColor4f(0, 0, 0, 0.6); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(ballpos[0]-ball.getRadius()*1.2, ballpos[1]-ball.getRadius()*1.2, 0); glTexCoord2f(1, 0); glVertex3f(ballpos[0]+ball.getRadius()*1.2, ballpos[1]-ball.getRadius()*1.2, 0); glTexCoord2f(1, 1); glVertex3f(ballpos[0]+ball.getRadius()*1.2, ballpos[1]+ball.getRadius()*1.2, 0); glTexCoord2f(0, 1); glVertex3f(ballpos[0]-ball.getRadius()*1.2, ballpos[1]+ball.getRadius()*1.2, 0); glEnd(); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, walltex); glColor3f(1, 1, 1); glBegin(GL_QUAD_STRIP); glTexCoord2f(0, 0); glVertex3f(-court.x+28.48581, court.y, 0); glTexCoord2f(0, 1); glVertex3f(-court.x+28.48581, court.y, 30); glTexCoord2f(15, 0); glVertex3f(court.x-28.48581, court.y, 0); glTexCoord2f(15, 1); glVertex3f(court.x-28.48581, court.y, 30); glTexCoord2f(16, 0); glVertex3f(court.x-14, court.y-6, 0); glTexCoord2f(16, 1); glVertex3f(court.x-14, court.y-6, 30); glTexCoord2f(17, 0); glVertex3f(court.x-6, court.y-14, 0); glTexCoord2f(17, 1); glVertex3f(court.x-6, court.y-14, 30); glTexCoord2f(18, 0); glVertex3f(court.x, court.y-28.48581, 0); glTexCoord2f(18, 1); glVertex3f(court.x, court.y-28.48581, 30); glTexCoord2f(21, 0); glVertex3f(court.x, 35, 0); glTexCoord2f(21, 1); glVertex3f(court.x, 35, 30); glTexCoord2f(23, 0); glVertex3f(court.x+30, 35, 0); glTexCoord2f(23, 1); glVertex3f(court.x+30, 35, 30); glTexCoord2f(25, 0); glVertex3f(court.x+30, -35, 0); glTexCoord2f(25, 1); glVertex3f(court.x+30, -35, 30); glTexCoord2f(27, 0); glVertex3f(court.x, -35, 0); glTexCoord2f(27, 1); glVertex3f(court.x, -35, 30); glTexCoord2f(29, 0); glVertex3f(court.x, -court.y+28.48581, 0); glTexCoord2f(29, 1); glVertex3f(court.x, -court.y+28.48581, 30); glTexCoord2f(32, 0); glVertex3f(court.x-6, -court.y+14, 0); glTexCoord2f(32, 1); glVertex3f(court.x-6, -court.y+14, 30); glTexCoord2f(33, 0); glVertex3f(court.x-14, -court.y+6, 0); glTexCoord2f(33, 1); glVertex3f(court.x-14, -court.y+6, 30); glTexCoord2f(34, 0); glVertex3f(court.x-28.48581, -court.y, 0); glTexCoord2f(34, 1); glVertex3f(court.x-28.48581, -court.y, 30); glTexCoord2f(49, 0); glVertex3f(-court.x+28.48581, -court.y, 0); glTexCoord2f(49, 1); glVertex3f(-court.x+28.48581, -court.y, 30); glTexCoord2f(50, 0); glVertex3f(-court.x+14, -court.y+6, 0); glTexCoord2f(50, 1); glVertex3f(-court.x+14, -court.y+6, 30); glTexCoord2f(51, 0); glVertex3f(-court.x+6, -court.y+14, 0); glTexCoord2f(51, 1); glVertex3f(-court.x+6, -court.y+14, 30); glTexCoord2f(52, 0); glVertex3f(-court.x, -court.y+28.48581, 0); glTexCoord2f(52, 1); glVertex3f(-court.x, -court.y+28.48581, 30); glTexCoord2f(54, 0); glVertex3f(-court.x, -35, 0); glTexCoord2f(54, 1); glVertex3f(-court.x, -35, 30); glTexCoord2f(56, 0); glVertex3f(-court.x-30, -35, 0); glTexCoord2f(56, 1); glVertex3f(-court.x-30, -35, 30); glTexCoord2f(59, 0); glVertex3f(-court.x-30, 35, 0); glTexCoord2f(59, 1); glVertex3f(-court.x-30, 35, 30); glTexCoord2f(61, 0); glVertex3f(-court.x, 35, 0); glTexCoord2f(61, 1); glVertex3f(-court.x, 35, 30); glTexCoord2f(63, 0); glVertex3f(-court.x, court.y-28.48581, 0); glTexCoord2f(63, 1); glVertex3f(-court.x, court.y-28.48581, 30); glTexCoord2f(64, 0); glVertex3f(-court.x+6, court.y-14, 0); glTexCoord2f(64, 1); glVertex3f(-court.x+6, court.y-14, 30); glTexCoord2f(65, 0); glVertex3f(-court.x+14, court.y-6, 0); glTexCoord2f(65, 1); glVertex3f(-court.x+14, court.y-6, 30); glTexCoord2f(66, 0); glVertex3f(-court.x+28.48581, court.y, 0); glTexCoord2f(66, 1); glVertex3f(-court.x+28.48581, court.y, 30); glEnd(); glBegin(GL_QUAD_STRIP); glTexCoord2f(0, 0); glVertex3f(-court.x/3*2, court.y*2, 0); glTexCoord2f(0, 2); glVertex3f(-court.x/3*2, court.y*2, 200); glTexCoord2f(1, 0); glVertex3f(-court.x/3*2, court.y+40, 0); glTexCoord2f(1, 2); glVertex3f(-court.x/3*2, court.y*1.5+20, 200); glTexCoord2f(2, 0); glVertex3f(-court.x/3*1, court.y+40, 0); glTexCoord2f(2, 2); glVertex3f(-court.x/3*1, court.y*1.5+20, 200); glTexCoord2f(3, 0); glVertex3f(-court.x/3*1, court.y*2, 0); glTexCoord2f(3, 2); glVertex3f(-court.x/3*1, court.y*2, 200); glEnd(); glBegin(GL_QUAD_STRIP); glTexCoord2f(0, 0); glVertex3f(court.x/3*2, court.y*2, 0); glTexCoord2f(0, 2); glVertex3f(court.x/3*2, court.y*2, 200); glTexCoord2f(1, 0); glVertex3f(court.x/3*2, court.y+40, 0); glTexCoord2f(1, 2); glVertex3f(court.x/3*2, court.y*1.5+20, 200); glTexCoord2f(2, 0); glVertex3f(court.x/3*1, court.y+40, 0); glTexCoord2f(2, 2); glVertex3f(court.x/3*1, court.y*1.5+20, 200); glTexCoord2f(3, 0); glVertex3f(court.x/3*1, court.y*2, 0); glTexCoord2f(3, 2); glVertex3f(court.x/3*1, court.y*2, 200); glEnd(); glBegin(GL_QUAD_STRIP); glTexCoord2f(0, 0); glVertex3f(-court.x/3*2, -court.y*2, 0); glTexCoord2f(0, 2); glVertex3f(-court.x/3*2, -court.y*2, 200); glTexCoord2f(1, 0); glVertex3f(-court.x/3*2, -court.y-40, 0); glTexCoord2f(1, 2); glVertex3f(-court.x/3*2, -court.y*1.5-20, 200); glTexCoord2f(2, 0); glVertex3f(-court.x/3*1, -court.y-40, 0); glTexCoord2f(2, 2); glVertex3f(-court.x/3*1, -court.y*1.5-20, 200); glTexCoord2f(3, 0); glVertex3f(-court.x/3*1, -court.y*2, 0); glTexCoord2f(3, 2); glVertex3f(-court.x/3*1, -court.y*2, 200); glEnd(); glBegin(GL_QUAD_STRIP); glTexCoord2f(0, 0); glVertex3f(court.x/3*2, -court.y*2, 0); glTexCoord2f(0, 2); glVertex3f(court.x/3*2, -court.y*2, 200); glTexCoord2f(1, 0); glVertex3f(court.x/3*2, -court.y-40, 0); glTexCoord2f(1, 2); glVertex3f(court.x/3*2, -court.y*1.5-20, 200); glTexCoord2f(2, 0); glVertex3f(court.x/3*1, -court.y-40, 0); glTexCoord2f(2, 2); glVertex3f(court.x/3*1, -court.y*1.5-20, 200); glTexCoord2f(3, 0); glVertex3f(court.x/3*1, -court.y*2, 0); glTexCoord2f(3, 2); glVertex3f(court.x/3*1, -court.y*2, 200); glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, balltex); glPushMatrix(); position_gl(ball.body); glColor3f(0.5, 0.5, 0.5); draw_sphere(ball.getRadius(), 24); glPopMatrix(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, machinetex); glEnable(GL_CULL_FACE); for(i=0; i<2; i++) { glPushMatrix(); position_gl(machine[i].body[0]); if(i==0) glColor3f(0.5, 0.3, 0.2); else glColor3f(0.5, 0.5, 0.5); bodymodel.render(); if(machine[i].powerupcount>0 && machine[i].turbocount!=0) { glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); glBegin(GL_QUADS); glColor4f(1, 0, 0, 0.7); glVertex3f(5.5, -12, 0); glVertex3f(3.5, -12, 0); glColor4f(1, 1, 0, 0); glVertex3f(4, -25, 0); glVertex3f(5, -25, 0); glColor4f(1, 0, 0, 0.7); glVertex3f(-3.5, -12, 0); glVertex3f(-5.5, -12, 0); glColor4f(1, 1, 0, 0); glVertex3f(-5, -25, 0); glVertex3f(-4, -25, 0); glEnd(); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); } glPopMatrix(); glPushMatrix(); position_gl(machine[i].body[1]); if(machine[i].getEnergy()==4) glColor3f(0.5, 0.5, 0.5); else glColor3f(0.35, 0.3, 0.3); pushermodel.render(); glPopMatrix(); } glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glBindTexture(GL_TEXTURE_2D, reflecttex); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glColor3f(1, 1, 1); for(i=0; i<2; i++) { glPushMatrix(); position_gl(machine[i].body[0]); glBegin(GL_QUADS); glNormal3f(0, 0.8, 0.4); glVertex3f(0, 7.4298439026, 1.25); glNormal3f(0, 0.7, 0.7); glVertex3f(0, 4.8880519867, 2.75); glNormal3f(0.6, 0.7, 0.7); glVertex3f(7.4881892204, 4.8880519867, 2.75); glNormal3f(0.6, 0.8, 0.4); glVertex3f(7.4881892204, 7.4298439026, 1.25); glNormal3f(0, 0.8, 0.4); glVertex3f(0, 7.4298439026, 1.25); glNormal3f(0, 0.7, 0.7); glVertex3f(0, 4.8880519867, 2.75); glNormal3f(-0.6, 0.7, 0.7); glVertex3f(-7.4881892204, 4.8880519867, 2.75); glNormal3f(-0.6, 0.8, 0.4); glVertex3f(-7.4881892204, 7.4298439026, 1.25); glEnd(); glPopMatrix(); } glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glEnable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); for(i=0; i<2; i++) { if(machine[i].shieldcount>0) { const dReal * pos0 = dBodyGetPosition(machine[i].body[0]); const dReal * pos1 = dBodyGetPosition(machine[i].body[1]); double length=sqrt( (pos0[0]-pos1[0])*(pos0[0]-pos1[0]) + (pos0[1]-pos1[1])*(pos0[1]-pos1[1]) + (pos0[2]-pos1[2])*(pos0[2]-pos1[2]))+3; glEnable(GL_BLEND); glEnable(GL_LIGHTING); glPushMatrix(); position_gl(machine[i].body[0]); glColor4f(0, 1, 0, machine[i].shieldcount>1?((machine[i].shieldcount-(int)machine[i].shieldcount)/6.0+0.2):machine[i].shieldcount/2); glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-12, -14, 6); glVertex3f(12, -14, 6); glVertex3f(12, length, 6); glVertex3f(-12, length, 6); glNormal3f(0, 0, -1); glVertex3f(12, -14, -6); glVertex3f(-12, -14, -6); glVertex3f(-12, length, -6); glVertex3f(12, length, -6); glNormal3f(0, -1, 0); glVertex3f(-12, -14, -6); glVertex3f(12, -14, -6); glVertex3f(12, -14, 6); glVertex3f(-12, -14, 6); glNormal3f(0, 1, 0); glVertex3f(12, length, -6); glVertex3f(-12, length, -6); glVertex3f(-12, length, 6); glVertex3f(12, length, 6); glNormal3f(-1, 0, 0); glVertex3f(-12, length, -6); glVertex3f(-12, -14, -6); glVertex3f(-12, -14, 6); glVertex3f(-12, length, 6); glNormal3f(1, 0, 0); glVertex3f(12, -14, -6); glVertex3f(12, length, -6); glVertex3f(12, length, 6); glVertex3f(12, -14, 6); glEnd(); glPopMatrix(); glDisable(GL_BLEND); glDisable(GL_LIGHTING); } if(machine[i].meshatekcount>0) { const dReal * pos0 = dBodyGetPosition(machine[i].body[0]); const dReal * pos1 = dBodyGetPosition(machine[i].body[1]); double length=sqrt( (pos0[0]-pos1[0])*(pos0[0]-pos1[0]) + (pos0[1]-pos1[1])*(pos0[1]-pos1[1]) + (pos0[2]-pos1[2])*(pos0[2]-pos1[2]))+3; glEnable(GL_BLEND); glEnable(GL_LIGHTING); glPushMatrix(); position_gl(machine[i].body[0]); glColor4f(1, 1, 1, machine[i].meshatekcount>1?((machine[i].meshatekcount-(int)machine[i].meshatekcount)/6.0+0.2):machine[i].meshatekcount/2); glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-12, -14, 6); glVertex3f(12, -14, 6); glVertex3f(12, length, 6); glVertex3f(-12, length, 6); glNormal3f(0, 0, -1); glVertex3f(12, -14, -6); glVertex3f(-12, -14, -6); glVertex3f(-12, length, -6); glVertex3f(12, length, -6); glNormal3f(0, -1, 0); glVertex3f(-12, -14, -6); glVertex3f(12, -14, -6); glVertex3f(12, -14, 6); glVertex3f(-12, -14, 6); glNormal3f(0, 1, 0); glVertex3f(12, length, -6); glVertex3f(-12, length, -6); glVertex3f(-12, length, 6); glVertex3f(12, length, 6); glNormal3f(-1, 0, 0); glVertex3f(-12, length, -6); glVertex3f(-12, -14, -6); glVertex3f(-12, -14, 6); glVertex3f(-12, length, 6); glNormal3f(1, 0, 0); glVertex3f(12, -14, -6); glVertex3f(12, length, -6); glVertex3f(12, length, 6); glVertex3f(12, -14, 6); glEnd(); glPopMatrix(); glDisable(GL_BLEND); glDisable(GL_LIGHTING); } } glDisable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, poweruptex); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glDepthMask(GL_FALSE); for(i=0; i<powerups.numpowerups; i++) { glPushMatrix(); glTranslatef(powerups.getPowerup(i).x, powerups.getPowerup(i).y, 5); glRotatef(powerups.spin, 1, 0, 0); if(powerups.getPowerup(i).type==0) glColor3f(0.33, 0.33, 1); else if(powerups.getPowerup(i).type==1) glColor3f(0.33, 1, 0.33); else if(powerups.getPowerup(i).type==2) glColor3f(1, 0.33, 1); else if(powerups.getPowerup(i).type==3) glColor3f(1, 1, 0.33); else if(powerups.getPowerup(i).type==4) glColor3f(0.4, 0.4, 0.4); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-5, -5, 0); glTexCoord2f(1, 0); glVertex3f(5, -5, 0); glTexCoord2f(1, 1); glVertex3f(5, 5, 0); glTexCoord2f(0, 1); glVertex3f(-5, 5, 0); glEnd(); glRotatef(90+powerups.spin*2, 0, 1, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-5, -5, 0); glTexCoord2f(1, 0); glVertex3f(5, -5, 0); glTexCoord2f(1, 1); glVertex3f(5, 5, 0); glTexCoord2f(0, 1); glVertex3f(-5, 5, 0); glEnd(); glRotatef(90+powerups.spin*4, 1, 0, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-5, -5, 0); glTexCoord2f(1, 0); glVertex3f(5, -5, 0); glTexCoord2f(1, 1); glVertex3f(5, 5, 0); glTexCoord2f(0, 1); glVertex3f(-5, 5, 0); glEnd(); glPopMatrix(); } glBindTexture(GL_TEXTURE_2D, explosiontex); for(i=0; i<explosions.numexplosions; i++) { glPushMatrix(); glTranslatef(explosions.getExplosion(i).x, explosions.getExplosion(i).y, explosions.getExplosion(i).z); glScalef(explosions.getExplosion(i).curradius*1.4, explosions.getExplosion(i).curradius*1.4, 1); glColor4f(1, 1, 1, 1.0-explosions.getExplosion(i).life/explosions.getExplosion(i).lifetime); glBegin(GL_QUADS); if(explosions.getExplosion(i).life/explosions.getExplosion(i).lifetime<=0.25) { glTexCoord2f(0, 0.5); glVertex3f(-1, -1, 0); glTexCoord2f(0.5, 0.5); glVertex3f(1, -1, 0); glTexCoord2f(0.5, 1); glVertex3f(1, 1, 0); glTexCoord2f(0, 1); glVertex3f(-1, 1, 0); } else if(explosions.getExplosion(i).life/explosions.getExplosion(i).lifetime<=0.5) { glTexCoord2f(0.5, 0.5); glVertex3f(-1, -1, 0); glTexCoord2f(1, 0.5); glVertex3f(1, -1, 0); glTexCoord2f(1, 1); glVertex3f(1, 1, 0); glTexCoord2f(0.5, 1); glVertex3f(-1, 1, 0); } else if(explosions.getExplosion(i).life/explosions.getExplosion(i).lifetime<=0.75) { glTexCoord2f(0, 0); glVertex3f(-1, -1, 0); glTexCoord2f(0.5, 0); glVertex3f(1, -1, 0); glTexCoord2f(0.5, 0.5); glVertex3f(1, 1, 0); glTexCoord2f(0, 0.5); glVertex3f(-1, 1, 0); } else { glTexCoord2f(0.5, 0); glVertex3f(-1, -1, 0); glTexCoord2f(1, 0); glVertex3f(1, -1, 0); glTexCoord2f(1, 0.5); glVertex3f(1, 1, 0); glTexCoord2f(0.5, 0.5); glVertex3f(-1, 1, 0); } glEnd(); glPopMatrix(); } glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, weaponstex); glColor3f(1, 1, 1); for(i=0; i<mines.nummines; i++) { glPushMatrix(); if(mines.getMine(i).danger) { glTranslatef(mines.getMine(i).x, mines.getMine(i).y, 6); glBegin(GL_QUADS); glTexCoord2f(0.5, 0); glVertex3f(-3, -3, 0); glTexCoord2f(1, 0); glVertex3f(3, -3, 0); glTexCoord2f(1, 0.5); glVertex3f(3, 3, 0); glTexCoord2f(0.5, 0.5); glVertex3f(-3, 3, 0); glEnd(); } else { glTranslatef(mines.getMine(i).x, mines.getMine(i).y, 3); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-3, -3, 0); glTexCoord2f(0.5, 0); glVertex3f(3, -3, 0); glTexCoord2f(0.5, 0.5); glVertex3f(3, 3, 0); glTexCoord2f(0, 0.5); glVertex3f(-3, 3, 0); glEnd(); } glPopMatrix(); } glDepthMask(GL_TRUE); for(i=0; i<projectiles.numprojectiles; i++) { glPushMatrix(); glTranslatef(projectiles.getProjectile(i).x, projectiles.getProjectile(i).y, 6); glRotatef(projectiles.getProjectile(i).angle, 0, 0, -1); glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); glColor4f(1, 0, 0, 0.7); glVertex3f(1, 0, 0); glVertex3f(-1, 0, 0); glColor4f(1, 1, 0, 0); glVertex3f(-0.5, -projectiles.getProjectile(i).length, 0); glVertex3f(0.5, -projectiles.getProjectile(i).length, 0); glEnd(); glEnable(GL_TEXTURE_2D); glColor3f(1, 1, 1); glBegin(GL_QUADS); if(projectiles.getProjectile(i).type==0) { glTexCoord2f(0, 0.5); glVertex3f(-5, -5, 0); glTexCoord2f(0.5, 0.5); glVertex3f(5, -5, 0); glTexCoord2f(0.5, 1); glVertex3f(5, 5, 0); glTexCoord2f(0, 1); glVertex3f(-5, 5, 0); } else { glTexCoord2f(0.5, 0.5); glVertex3f(-5, -5, 0); glTexCoord2f(1, 0.5); glVertex3f(5, -5, 0); glTexCoord2f(1, 1); glVertex3f(5, 5, 0); glTexCoord2f(0.5, 1); glVertex3f(-5, 5, 0); } glEnd(); glPopMatrix(); } glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); if(options.logoshow) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 800, 0, 600, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, bennykramekwebtex); glColor4f(1, 1, 1, 0.7); glEnable(GL_BLEND); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(544, 0); glTexCoord2f(1, 0); glVertex2i(800, 0); glTexCoord2f(1, 1); glVertex2i(800, 32); glTexCoord2f(0, 1); glVertex2i(544, 32); glEnd(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } if(goalcount>0) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 800, 0, 600, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glColor4f(0.8, 1, 0.8, goalcount/6.0); glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(800, 0); glVertex2i(800, 600); glVertex2i(0, 600); glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, goaltex); glColor4f(1, 1, 1, goalcount/4.0); glTranslatef(400, 300, 0); glScalef(1-goalcount/4.0, 1-goalcount/4.0, 0); glRotatef(goalcount/4.0*360+180, 0, 0, 1); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(-400, -300); glTexCoord2f(1, 0); glVertex2i(400, -300); glTexCoord2f(1, 1); glVertex2i(400, 300); glTexCoord2f(0, 1); glVertex2i(-400, 300); glEnd(); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } if(gameover) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 800, 0, 600, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glColor4f(0, 0, 0, 0.6); glBegin(GL_QUADS); glVertex2i(100, 100); glVertex2i(700, 100); glVertex2i(700, 500); glVertex2i(100, 500); glEnd(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } if(gamepaused) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 800, 0, 600, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glColor4f(0, 0, 0, 0.6); glBegin(GL_QUADS); glVertex2i(100, 100); glVertex2i(700, 100); glVertex2i(700, 500); glVertex2i(100, 500); glEnd(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } text.begin(); char a[10]; if(options.fpsshow) { glColor3f(0.3, 0.3, 0.3); sprintf(a, "%2.0f", 1.0/(m*4)); text.print(0, 0, a); } if(rendertime && gametime>=0) { sprintf(a, "%2.2d:%2.2d:%2.2d", (int)(gametime/60), (int)(gametime)%60, (int)((gametime-(int)(gametime))*100)); glColor3f(0, 0, 0); text.print(332, 558, a); glColor3f(1, 1, 1); if(gametime<=10) glColor3f(1, 0, 0); text.print(330, 560, a); } if(rendertime && gametime<0) { sprintf(a, "%2.2d:%2.2d:%2.2d", 0, 0, 0); glColor3f(0, 0, 0); text.print(332, 558, a); glColor3f(1, 1, 1); glColor3f(1, 0, 0); text.print(330, 560, a); } glColor3f(0, 0, 0); sprintf(a, "%d", (int)goals[0]); text.print(102, 558, a); glColor3f(0, 0, 1); text.print(100, 560, a); glColor3f(0, 0, 0); sprintf(a, "%d", (int)goals[1]); text.print(682, 558, a); glColor3f(0, 0, 1); text.print(680, 560, a); if(gameover) { glColor3f(1, 1, 1); text.print(290, 400, "GAME OVER"); if(goals[0]>goals[1]) { glColor3f(1, 0.6, 0.4); text.print(240, 280, "PLAYER 1 WINS!"); glColor3f(1, 1, 1); text.print(200, 240, "PLAYER 2: YOU SUCK!"); } if(goals[1]>goals[0]) { glColor3f(1, 1, 1); text.print(240, 280, "PLAYER 2 WINS!"); glColor3f(1, 0.6, 0.4); text.print(200, 240, "PLAYER 1: YOU SUCK!"); } if(goals[0]==goals[1]) { text.print(300, 280, "TIE GAME!"); text.print(240, 240, "YOU BOTH SUCK!"); } glColor3f(1, 1, 1); text.print(250, 140, "PRESS ESCAPE"); } if(gamepaused) { glColor3f(1, 0, 0); text.print(340, 400, "PAUSE"); glColor3f(1, 1, 1); text.print(120, 340, "CURRENT SONG:"); text.print(105, 280, "<"); text.print(680, 280, ">"); int mama_of; for(mama_of=0; mama_of<12; mama_of++) { char turd[3]; sprintf(turd, "%d", mama_of+1); if(mama_of==currentsong) glColor3f(1, 1, 0); else glColor3f(0.6, 0.6, 1); text.print(135+mama_of*45, 280, turd); } glColor3f(1, 1, 1); text.print(120, 160, "PRESS ESCAPE TO RESUME"); text.print(200, 120, "PRESS F11 TO QUIT"); } text.end(); glEnable(GL_LIGHTING); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glFlush(); allegro_gl_flip(); allegro_gl_end(); }
ENTRYPOINT void draw_stairs (ModeInfo * mi) { stairsstruct *sp = &stairs[MI_SCREEN(mi)]; GLfloat rot = current_device_rotation(); Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (!sp->glx_context) return; glXMakeCurrent(display, window, *(sp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(rot, 0, 0, 1); if ((rot > 45 && rot < 135) || (rot < -45 && rot > -135)) { GLfloat s = MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi); glScalef (s, 1/s, 1); } glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) { glScalef(Scale4Window * sp->WindH / sp->WindW, Scale4Window, Scale4Window); } else { glScalef(Scale4Iconic * sp->WindH / sp->WindW, Scale4Iconic, Scale4Iconic); } gltrackball_rotate (sp->trackball); glTranslatef(0, 0.5, 0); glRotatef(44.5, 1, 0, 0); glRotatef(50, 0, 1, 0); if (!sp->rotating) { if ((LRAND() % 500) == 0) sp->rotating = (LRAND() & 1) ? 1 : -1; } if (sp->rotating) { glRotatef(sp->rotating * sp->step, 0, 1, 0); if (sp->step >= 360) { sp->rotating = 0; sp->step = 0; } # ifndef DEBUG if (!sp->button_down_p) sp->step += 2; # endif /* DEBUG */ } draw_stairs_internal(mi); # ifdef DEBUG { int i, j; # ifdef DEBUG_PATH glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glBegin (GL_LINE_LOOP); # endif /* DEBUG_PATH */ for (i = 0; i < NPOSITIONS; i ++) for (j = 0; j < SPHERE_TICKS; j++) mi->polygon_count += draw_sphere(i, j); # ifdef DEBUG_PATH glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); # endif /* DEBUG_PATH */ } #else /* !DEBUG */ mi->polygon_count += draw_sphere(sp->sphere_position, sp->sphere_tick); #endif /* !DEBUG */ if (sp->button_down_p) ; else if (++sp->sphere_tick >= SPHERE_TICKS) { sp->sphere_tick = 0; if (++sp->sphere_position >= NPOSITIONS) sp->sphere_position = 0; } glPopMatrix(); if (mi->fps_p) do_fps (mi); glFlush(); glXSwapBuffers(display, window); }
/* metoda ce adauga jucatorul in labirint */ void Player::add() { draw_sphere(); draw_cone(); }
void draw_scene(GLdouble secs, int passes, GLenum cullFace, GLuint stencilVal, GLuint mirror) { GLenum newCullFace; int passesPerMirror, passesPerMirrorRem; unsigned int curMirror, drawMirrors; int i; /* one pass to draw the real scene */ passes--; /* only draw in my designated locations */ glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff); /* draw things which may obscure the mirrors first */ draw_sphere(secs); draw_cone(); /* now draw the appropriate number of mirror reflections. for * best results, we perform a depth-first traversal by allocating * a number of passes for each of the mirrors. */ if (mirror != 0xffffffff) { passesPerMirror = passes / (nMirrors - 1); passesPerMirrorRem = passes % (nMirrors - 1); if (passes > nMirrors - 1) drawMirrors = nMirrors - 1; else drawMirrors = passes; } else { /* mirror == -1 means that this is the initial scene (there was no * mirror) */ passesPerMirror = passes / nMirrors; passesPerMirrorRem = passes % nMirrors; if (passes > nMirrors) drawMirrors = nMirrors; else drawMirrors = passes; } for (i = 0; drawMirrors > 0; i++) { curMirror = i % nMirrors; if (curMirror == mirror) continue; drawMirrors--; /* draw mirror into stencil buffer but not color or depth buffers */ glColorMask(0, 0, 0, 0); glDepthMask(0); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); draw_mirror(&mirrors[curMirror]); glColorMask(1, 1, 1, 1); glDepthMask(1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); /* draw reflected scene */ newCullFace = reflect_through_mirror(&mirrors[curMirror], cullFace); if (passesPerMirrorRem) { draw_scene(secs, passesPerMirror + 1, newCullFace, stencilVal + 1, curMirror); passesPerMirrorRem--; } else { draw_scene(secs, passesPerMirror, newCullFace, stencilVal + 1, curMirror); } undo_reflect_through_mirror(&mirrors[curMirror], cullFace); /* back to our stencil value */ glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff); } draw_room(); }