I am having some trouble drawing a 2d overlay. I am currently trying to draw a quad that is 200x200 pixels in screen coordinates. If you could point out what is wrong in the following code or show your own I would highly appreciate it:
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
}
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluOrtho2D(0,800,0,600); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glTranslated(0,0,0); // draw some stuff (blended, textured, alpha tested quad etc.)
if(use_tex)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex.tex);
glTexCoord2f(0.0f, 0.0f); glVertex2d( lBC.x, lBC.y); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex2d( rBC.x, rBC.y); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex2d( rTC.x, rTC.y); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex2d( 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); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix();
if (use_alpha)
{
glDisable(GL_BLEND);
}
return true;
}