HUD problem

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, I'm trying to draw a hud into my game, I'm using the following code:
void orthogonalStart () {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glOrtho( 0, 1024, 0, 768, -1, 1 );
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glColor3f(1,0,0);
glVertex3f(0,0,0);
glVertex3f(100,0,0);
glVertex3f(100,100,0);
glVertex3f(0,100,0);
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}


And I get the following: hud How can I fix this, that the tank won't overlay any part of my quads? Thanks

Share on other sites
Your HUD probably needs to be on top of everything. In that case, you can simply clear your depth buffer and render your HUD thereafter.
For instance :
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Clear color and depthrenderTerrain();renderVehicles();glClear(GL_DEPTH_BUFFER_BIT); // Clear depth buffer ONLYrenderHUD();

As a side note, according to the glColor3f(1,0,0) call, your HUD quad should be red, which isn't. Make sure to disable lighting and/or texturing before rendering your quad.

Share on other sites
Alternatively, if you're not relying on Z-buffering for proper layering of GUI elements, just glDisable(GL_DEPTH_TEST) before you draw your GUI. (Don't forget to reënable it afterwards.)