OpenGL drawing order

I present an OpenGL scene that includes some bitmap text. I understand that the order in which I draw things will determine which elements are on top.

However, my bitmap text, even if I draw the last one, is not up to par!

For example, I draw:

1) Background information 2) Buttons
3) Text

All at the same depth z. The buttons are above the background, but the text is invisible. I am changing the depth z of the text, I can see it, but I have other problems.

I use the raster text method from Nehe Tutorials.

How can I make text visible without changing depth z?

+4
source share
2 answers

You can simply disable the z-test through

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

If you do this, Z of your text primitives will be ignored. Primitives are drawn in the same order as your gl function call.

Another way would be to set some constant z-offset through glPolygonOffset (not recommended) or set the depth comparison mode to something like GL_LESS_EQUAL (EQUAL is important). This ensures that primitives drawn with the same depth are mapped onto each other.

Hope this helps.

+8
source

You can also use glDepthFunc (GL_ALWAYS).

0
source

All Articles