Jump to content
  • Advertisement
Sign in to follow this  
norbip

HUD problem

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

If you intended to correct an error in the post then please contact us.

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();
	glLoadIdentity();
	glOrtho( 0, 1024, 0, 768, -1, 1 );
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();	
	glLoadIdentity();
	glColor3f(1,0,0);
	glBegin(GL_QUADS);
		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 this post


Link to post
Share on other sites
Advertisement
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 depth
renderTerrain();
renderVehicles();
glClear(GL_DEPTH_BUFFER_BIT); // Clear depth buffer ONLY
renderHUD();


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 this post


Link to post
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.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!