Temporaryly disable and re-enable gluPerspective?

I’m working on a Heads Up Display for my application. I need to be able to acuratly place quads on the screen. This was easy before I used gluPerspective but now that it is enabled, -1x, -1y is no longer an exact corner.

Is there a way to disable gluPerspective while drawing the HUD and re-enable it for the rest of geometry?

The gluPerspective is nothing that is enabled or disabled. That function simply modifies currently set matrix so you can redefine that matrix at any time.

To draw the hud you might use something like:

// Configure orthographic projection.

glMatrixMode( GL_PROJECTION ) ;
glLoadIdentity() ;
gluOrtho2D( -1.0, 1.0, -1.0, 1.0 )
glMatrixMode( GL_MODELVIEW ) ;

// Draw HUD quads. 


// Configure perspective projection

glMatrixMode( GL_PROJECTION ) ;
glLoadIdentity() ;
gluPerspective ( desired parameters )
glMatrixMode( GL_MODELVIEW ) ;

// Draw the geometry

Ok I’ll try to figure it out using Ortho2D thanks.

How about some ready made code, it works like a charm.

 
void ViewOrtho(int x, int y)							// Set Up An Ortho View
{
	glMatrixMode(GL_PROJECTION);					// Select Projection
	glPushMatrix();							// Push The Matrix
	glLoadIdentity();						// Reset The Matrix
	glOrtho( 0, x , y , 0, -1, 1 );				// Select Ortho Mode 
	glMatrixMode(GL_MODELVIEW);					// Select Modelview Matrix
	glPushMatrix();							// Push The Matrix
	glLoadIdentity();						// Reset The Matrix
}

void ViewPerspective(void)							// Set Up A Perspective View
{
	glMatrixMode( GL_PROJECTION );					// Select Projection
	glPopMatrix();							// Pop The Matrix
	glMatrixMode( GL_MODELVIEW );					// Select Modelview
	glPopMatrix();							// Pop The Matrix
} 

That looks like it should work, thanks. I’ll try it out.

Well I thought I understood the code you gave me but I can’t seem to get it to work. The HUD quads don’t show at all in orthographic. I tried switching the Z location of the quads from negative to positive and turning off back-face culling.

I call ViewOrtho(config.resX, config.resY) imedietly before drawing the HUD and call ViewPerspective before drawing worldly geometry.

-thanks in advance