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