Drawing HUD's and other 2d overlays

How would I go about drawing a 2d overlay? I am trying to use the following code but it doesn’t work:

bool CFrame::Init()
{
//load data from resource file,

//for debug purposes
lTC.x = 0;
lTC.y = 0;

lBC.x = 0;
lBC.y = 200;

rTC.x = 200;
rTC.y = 0;

rBC.x = 200;
rBC.y = 200;

use_alpha = false;

use_tex = false;

col.r = 0;
col.g = 255;
col.b = 0;
col.a = 255;

if(use_tex)
{
	BuildTexture();
}
return true;

}

and the actual drawing code:

bool CFrame: raw()
{
if (use_alpha)
{
glEnable(GL_BLEND); // Enable Blending
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Select The Type Of Blending
}

glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,/*theApp.GetWidth()*/800,0,/*theApp.GetHeight()*/600,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

if(use_tex)
{
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, tex.tex);
	glTexCoord2f(0.0f, 0.0f); glVertex2f( lBC.x, lBC.y);	// Bottom Left Of The Texture and Quad
	glTexCoord2f(1.0f, 0.0f); glVertex2f( rBC.x, rBC.y);	// Bottom Right Of The Texture and Quad
	glTexCoord2f(1.0f, 1.0f); glVertex2f( rTC.x, rTC.y);	// Top Right Of The Texture and Quad
	glTexCoord2f(0.0f, 1.0f); glVertex2f( lTC.x, lTC.y);	// Top Left Of The Texture and Quad
	glDisable(GL_TEXTURE_2D);
}
else
{
	glColor4ub(col.r, col.g, col.b, col.a);                 // Color our quad
	glVertex2d( lBC.x, lBC.y);	// Bottom Left Of The Texture and Quad
	glVertex2d( rBC.x, rBC.y);	// Bottom Right Of The Texture and Quad
	glVertex2d( rTC.x, rTC.y);	// Top Right Of The Texture and Quad
	glVertex2d( lTC.x, lTC.y);	// Top Left Of The Texture and Quad
}

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
if (use_alpha)
{
    glDisable(GL_BLEND);
}
return true;

}

If anyone has any suggestions I would appreciate it alot, Thanks

-Corillian

Draw some textures with alpha testing and the depth buffer disabled after you have rendered the normal scene. You can also use the stencil buffer.

I have not looked into your code so maybe are you doing something like that already. Perhaps should you describe better why it does not work or post some screen shot.

I already am disabling depth testing. Could anyone provide some working 2d drawing code for a HUD or GUI? I would show u a screen shot but there is nothing to show, that’s what the problem is =D.

-Corillian

I think your Ortho call is wrong…

here is some code I use:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);

fColor[0]= 1.0f;
fColor[0]= 0.0f;
fColor[0]= 1.0f;
fColor[0]= 1.0f;

Print("This is a test!", 0, 0)

glViewport(0, 0, 640, 480);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f, (float)640/ (float)480, 0.1f, 300.f);

glMatrixMode(GL_MODELVIEW);