Code: Select all
glEnable( GL_DEPTH_TEST );
glViewport( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -300.0f, 300.0f); //ONLY DIFFERENT LINE OF CODE
glMatrixMode( GL_MODELVIEW );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
glBegin( GL_QUADS );
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f( -20.0f, -20.0f, 10.0f );
glVertex3f( 20.0f, -20.0f, 10.0f );
glVertex3f( 20.0f, 20.0f, 10.0f );
glVertex3f( -20.0f, 20.0f, 10.0f );
glEnd();
Code: Select all
glEnable( GL_DEPTH_TEST );
glViewport( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 45.0f, (GLfloat)SCREEN_WIDTH / (GLfloat)SCREEN_HEIGHT, 0.5f, 500.0f ); //ONLY DIFFERENT LINE OF CODE
glMatrixMode( GL_MODELVIEW );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
glBegin( GL_QUADS );
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f( -20.0f, -20.0f, 10.0f );
glVertex3f( 20.0f, -20.0f, 10.0f );
glVertex3f( 20.0f, 20.0f, 10.0f );
glVertex3f( -20.0f, 20.0f, 10.0f );
glEnd();