1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| bool GfxEntitySkybox::Render ( ) const
{
// Disable the depth buffer
glDisable( GL_DEPTH_TEST );
// Disable lighting
glDisable( GL_LIGHTING );
// Backup the model - view matrix
glPushMatrix();
// Modify the view matrix so it is centred
Vector cameraPosition = GRAPHICS.GetCameraPosition();
glTranslatef( cameraPosition[0], cameraPosition[1], cameraPosition[2] );
// --- We can now render the skybox ---
glColor4f( 1.f, 1.f, 1.f, 1.f );
// Left side
GRAPHICS.EnableTexture( _leftTexId );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex3i( -1, -1, 1 );
glTexCoord2i( 1, 0 ); glVertex3i( -1, -1, -1 );
glTexCoord2i( 1, 1 ); glVertex3i( -1, 1, -1 );
glTexCoord2i( 0, 1 ); glVertex3i( -1, 1, 1 );
glEnd();
// Right side
GRAPHICS.EnableTexture( _rightTexId );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex3i( 1, -1, -1 );
glTexCoord2i( 1, 0 ); glVertex3i( 1, -1, 1 );
glTexCoord2i( 1, 1 ); glVertex3i( 1, 1, 1 );
glTexCoord2i( 0, 1 ); glVertex3i( 1, 1, -1 );
glEnd();
// Front side
GRAPHICS.EnableTexture( _frontTexId );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex3i( -1, -1, -1 );
glTexCoord2i( 1, 0 ); glVertex3i( 1, -1, -1 );
glTexCoord2i( 1, 1 ); glVertex3i( 1, 1, -1 );
glTexCoord2i( 0, 1 ); glVertex3i( -1, 1, -1 );
glEnd();
// Back side
GRAPHICS.EnableTexture( _backTexId );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex3i( 1, -1, 1 );
glTexCoord2i( 1, 0 ); glVertex3i( -1, -1, 1 );
glTexCoord2i( 1, 1 ); glVertex3i( -1, 1, 1 );
glTexCoord2i( 0, 1 ); glVertex3i( 1, 1, 1 );
glEnd();
// TODO: Top and bottom side
// Restore the original model - view matrix
glPopMatrix();
// Restore the states
GRAPHICS.DisableTexture();
glEnable( GL_DEPTH_TEST );
glEnable( GL_LIGHTING );
return true;
} |
Partager