Can some one help me figure out why this GL_QUAD is not centering in my program:
#include <gl/glut.h>
void quad();
void init();
void display();
void quad() {
glBegin( GL_QUADS );
glTexCoord2f( 0.0, 0.0 ); glVertex3f( -1.0, 1.0, -1.0 );
glTexCoord2f( 0.0, 1.0 ); glVertex3f( 1.0, 1.0, -1.0 );
glTexCoord2f( 1.0, 1.0 ); glVertex3f( 1.0, -1.0, -1.0 );
glTexCoord2f( 0.0, 1.0 ); glVertex3f( -1.0, -1.0, -1.0 );
glEnd();
}
void keyboard( unsigned char key, int x, int y ) {
switch( key ) {
case 27:
exit( 0 );
break;
default:
break;
}
}
void init() {
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glEnable( GL_DEPTH_TEST );
glShadeModel( GL_SMOOTH );
}
void display() {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
quad();
glFlush();
}
void reshape( int h, int w ) {
float ratio = 1.0* w / h;
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glViewport( 0, 0, w, h );
gluPerspective( 25, ratio, 1, 1000 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt( 0.0,0.0,5.0,
0.0,0.0,-1.0,
0.0f,1.0f,0.0f );
glutSwapBuffers();
}
int main( int argc, char** argv ) {
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH );
glutEnterGameMode();
init();
glutDisplayFunc( display );
glutReshapeFunc( reshape );
glutKeyboardFunc( keyboard );
glutMainLoop();
return 0;
}