/* * r_drawFrame * Perform any drawing and setup necessary to produce a single frame. */ static void r_drawFrame() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); r_setupModelviewRotate(); glClear(GL_DEPTH_BUFFER_BIT); // Just in case we set all vertices to white. glColor4f(1,1,1,1); glBindTexture(GL_TEXTURE_2D, textureStars); // Render the front quad glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f( 1.0f, -1.0f, -1.0f ); glTexCoord2f(1, 0); glVertex3f( -1.0f, -1.0f, -1.0f ); glTexCoord2f(1, 1); glVertex3f( -1.0f, 1.0f, -1.0f ); glTexCoord2f(0, 1); glVertex3f( 1.0f, 1.0f, -1.0f ); glEnd(); // Render the left quad glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f( 1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 0); glVertex3f( 1.0f, -1.0f, -1.0f ); glTexCoord2f(1, 1); glVertex3f( 1.0f, 1.0f, -1.0f ); glTexCoord2f(0, 1); glVertex3f( 1.0f, 1.0f, 1.0f ); glEnd(); // Render the back quad glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f( -1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 0); glVertex3f( 1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 1); glVertex3f( 1.0f, 1.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f( -1.0f, 1.0f, 1.0f ); glEnd(); // Render the right quad glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f( -1.0f, -1.0f, -1.0f ); glTexCoord2f(1, 0); glVertex3f( -1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 1); glVertex3f( -1.0f, 1.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f( -1.0f, 1.0f, -1.0f ); glEnd(); // Render the top quad glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex3f( -1.0f, 1.0f, -1.0f ); glTexCoord2f(0, 0); glVertex3f( -1.0f, 1.0f, 1.0f ); glTexCoord2f(1, 0); glVertex3f( 1.0f, 1.0f, 1.0f ); glTexCoord2f(1, 1); glVertex3f( 1.0f, 1.0f, -1.0f ); glEnd(); // Render the bottom quad glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f( -1.0f, -1.0f, -1.0f ); glTexCoord2f(0, 1); glVertex3f( -1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 1); glVertex3f( 1.0f, -1.0f, 1.0f ); glTexCoord2f(1, 0); glVertex3f( 1.0f, -1.0f, -1.0f ); glEnd(); glClear(GL_DEPTH_BUFFER_BIT); r_setupModelviewTranslate(); renderer_model_drawASE(0); glBindTexture(GL_TEXTURE_2D, textureLava); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(200,-201,200); glTexCoord2f(1,0); glVertex3f(200,-201,-200); glTexCoord2f(1,1); glVertex3f(-200,-201,-200); glTexCoord2f(0,1); glVertex3f(-200,-201,200); glEnd(); glBindTexture(GL_TEXTURE_2D, textureScore); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(20,-200,20); glTexCoord2f(1,0); glVertex3f(20,-200,120); glTexCoord2f(1,1); glVertex3f(120,-200,120); glTexCoord2f(0,1); glVertex3f(120,-200,20); glEnd(); glBindTexture(GL_TEXTURE_2D, textureBrick); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(2,-1,2); glTexCoord2f(1,0); glVertex3f(2,-1,-2); glTexCoord2f(1,1); glVertex3f(-2,-1,-2); glTexCoord2f(0,1); glVertex3f(-2,-1,2); glEnd(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(randx+size,-100,randz+size); glTexCoord2f(size/4,0); glVertex3f(randx+size,-100,randz-size); glTexCoord2f(size/4,size/4); glVertex3f(randx-size,-100,randz-size); glTexCoord2f(0,size/4); glVertex3f(randx-size,-100,randz+size); glEnd(); // DrawOverlay(); r_setupModelview(); glBindTexture(GL_TEXTURE_2D, textureBrick); // // Render a square in front of us // // Render the front quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.0f, SQRT_2*-0.1f, -0.2f ); // glTexCoord2f(1, 0); glVertex3f( 0.05f, SQRT_2*-0.1f, -0.1f ); // glTexCoord2f(1, 1); glVertex3f( 0.05f, SQRT_2*-0.05f, -0.1f ); // glTexCoord2f(0, 1); glVertex3f( 0.0f, SQRT_2*-0.05f, -0.2f ); // glEnd(); // // Render the left quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.15f, SQRT_2*-0.1f, -0.3f ); // glTexCoord2f(1, 0); glVertex3f( 0.0f, SQRT_2*-0.1f, -0.2f ); // glTexCoord2f(1, 1); glVertex3f( 0.0f, SQRT_2*-0.05f, -0.2f ); // glTexCoord2f(0, 1); glVertex3f( 0.15f, SQRT_2*-0.05f, -0.3f ); // glEnd(); // // Render the back quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.2f, SQRT_2*-0.1f, -0.2f ); // glTexCoord2f(1, 0); glVertex3f( 0.15f, SQRT_2*-0.1f, -0.3f ); // glTexCoord2f(1, 1); glVertex3f( 0.15f, SQRT_2*-0.05f, -0.3f ); // glTexCoord2f(0, 1); glVertex3f( 0.2f, SQRT_2*-0.05f, -0.2f ); // glEnd(); // // Render the right quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.05f, SQRT_2*-0.1f, -0.1f ); // glTexCoord2f(1, 0); glVertex3f( 0.2f, SQRT_2*-0.1f, -0.2f ); // glTexCoord2f(1, 1); glVertex3f( 0.2f, SQRT_2*-0.05f, -0.2f ); // glTexCoord2f(0, 1); glVertex3f( 0.05f, SQRT_2*-0.05f, -0.1f ); // glEnd(); // // Render the top quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.05f, SQRT_2*-0.05f, -0.1f ); // glTexCoord2f(1, 0); glVertex3f( 0.2f, SQRT_2*-0.05f, -0.2f ); // glTexCoord2f(1, 1); glVertex3f( 0.15f, SQRT_2*-0.05f, -0.3f ); // glTexCoord2f(0, 1); glVertex3f( 0.0f, SQRT_2*-0.05f, -0.2f ); // glEnd(); // // Render the bottom quad // glBegin(GL_QUADS); // glTexCoord2f(0, 0); glVertex3f( 0.05f, SQRT_2*-0.1f, -0.1f ); // glTexCoord2f(1, 0); glVertex3f( 0.2f, SQRT_2*-0.1f, -0.2f ); // glTexCoord2f(1, 1); glVertex3f( 0.15f, SQRT_2*-0.1f, -0.3f ); // glTexCoord2f(0, 1); glVertex3f( 0.0f, SQRT_2*-0.1f, -0.2f ); // glEnd(); SDL_GL_SwapBuffers(); }
/* * r_drawFrame * Perform any drawing and setup necessary to produce a single frame. */ static void r_drawFrame() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Orient and position the camera r_setupModelview(); //Draw sky? glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glPushMatrix(); glLoadIdentity(); r_setupModelviewforSky(); renderer_model_drawASE(0); glPopMatrix(); glClear(GL_DEPTH_BUFFER_BIT); //Draw fighter. Needs to stay with the camera. //Doesn't rotate. Only stays in the same position relative to camera. glPushMatrix(); glLoadIdentity(); renderer_model_drawASE(1); glPopMatrix(); //Texture stuff past this point. glColor3f(1.0, 1.0, 1.0); glBindTexture(GL_TEXTURE_2D, face1); glBegin(GL_QUADS); //Set up appropriate texture for the forward face. //I've been visualizing this the wrong way. Each four is considered a square. //Face 1 glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, -0.5, -8.0); glTexCoord2f(1.0, 0.0); glVertex3f( 0.5, -0.5, -8.0); glTexCoord2f(1.0, 1.0); glVertex3f( 0.5, 0.5, -8.0); glTexCoord2f(0.0, 1.0); glVertex3f(-0.5, 0.5, -8.0); glEnd(); //Face 2 glBindTexture(GL_TEXTURE_2D, face4); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, -0.5, -9.0); glTexCoord2f(1.0, 0.0); glVertex3f(-0.5, -0.5, -8.0); glTexCoord2f(1.0, 1.0); glVertex3f(-0.5, 0.5, -8.0); glTexCoord2f(0.0, 1.0); glVertex3f(-0.5, 0.5, -9.0); glEnd(); //Face 3 glBindTexture(GL_TEXTURE_2D, face3); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(0.5, -0.5, -8.0); glTexCoord2f(1.0, 0.0); glVertex3f(0.5, -0.5, -9.0); glTexCoord2f(1.0, 1.0); glVertex3f(0.5, 0.5, -9.0); glTexCoord2f(0.0, 1.0); glVertex3f(0.5, 0.5, -8.0); glEnd(); //Face 4 glBindTexture(GL_TEXTURE_2D, face6); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(0.5, -0.5, -9.0); glTexCoord2f(1.0, 0.0); glVertex3f(-0.5, -0.5, -9.0); glTexCoord2f(1.0, 1.0); glVertex3f(-0.5, 0.5, -9.0); glTexCoord2f(0.0, 1.0); glVertex3f(0.5, 0.5, -9.0); glEnd(); //Face 5 glBindTexture(GL_TEXTURE_2D, face5); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, 0.5, -8.0); glTexCoord2f(1.0, 0.0); glVertex3f(0.5, 0.5, -8.0); glTexCoord2f(1.0, 1.0); glVertex3f(0.5, 0.5, -9.0); glTexCoord2f(0.0, 1.0); glVertex3f(-0.5, 0.5, -9.0); glEnd(); //Face 6 glBindTexture(GL_TEXTURE_2D, face2); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(0.5, -0.5, -8.0); glTexCoord2f(1.0, 0.0); glVertex3f(-0.5, -0.5, -8.0); glTexCoord2f(1.0, 1.0); glVertex3f(-0.5, -0.5, -9.0); glTexCoord2f(0.0, 1.0); glVertex3f(0.5, -0.5, -9.0); glEnd(); SDL_GL_SwapBuffers(); }