tags:

views:

422

answers:

2

I am rendering an OpenGL scene that include some bitmap text. It is my understanding the order I draw things in will determine which items are on top.

However, my bitmap text, even though I draw it last, is not on top!

For instance, I am drawing:

1) Background
2) Buttons
3) Text

All at the same z depth. Buttons are above the background, but text is invisible. It I change the z depth of the text, I can see it, but I then have other problems.

I am using the bitmap text method from Nehe's Tutorials.

How can I make the text visible without changing the z depth?

+6  A: 

You can simply disable the z-test via

  glDisable (GL_DEPTH_TEST);  // or something related..

If you do so the Z of your text-primitives will be ignored. Primitives are drawn in the same order as your call the gl-functions.

Another way would be to set some constant z-offset via glPolygonOffset (not recommended) or set the depth-compare mode to something like GL_LESS_EQUAL (the EQUAL is the important one). That makes sure that primitives drawn with the same depth are rendered ontop of each other.

Hope that helps.

Nils Pipenbrinck
Yep, turn off z-buffering for UI drawing.
Chris Blackwell
Good answer--I was going to suggest all of the same! :)
Drew Hall
Thank you for the help!
Evan Marks
A: 

You can also use glDepthFunc (GL_ALWAYS).

karx11erx
If you vote this answer down, please explain what is wrong about it.
karx11erx