polygon z-ordering

BlitzMax Forums/OpenGL Module/polygon z-ordering

slenkar(Posted 2008) [#1]
I have to translate the 'camera' backwards to get the most recently drawn polygon to show on top of the last one:

I just want to draw 2d shapes to the screen, using gltranslate makes the gl-coord to pixel co-ord calculations change


the code above is not using glortho
does glortho fix this problem?
p.s. is there another way of beggining a new quad other than using glbegin?


ImaginaryHuman(Posted 2008) [#2]
If you only want 2D shapes and you never want to rotate them in 3D around the X or Y axis, then just use glOrtho (glOrtho2D?) instead of perspective. Note that in orthographic projections, the stuff in front of the camera is in positive Z coordinates, while in perspective mode you're looking at negative Z coords. You don't really need or want perspective division to occur if you're not doing anything 3D.

You still need glBegin to draw your quad, unless you get into vertex arrays or vertex buffers.


JoshK(Posted 2008) [#3]
Disable depth testing and draw in order from back to front.


slenkar(Posted 2008) [#4]
thanks that worked josh

thx IH


ImaginaryHuman(Posted 2008) [#5]
I think I misunderstood your question, it sounds more like you NEED the depth test so that anything closest to you will be drawn, no matter what order you draw it in?


slenkar(Posted 2008) [#6]
same behaviour as drawimage


ImaginaryHuman(Posted 2008) [#7]
Oh, so because you're using 3D, if you have the depth test turned on, the fragments for your first image drawn will have the same depth value as those for the second image and it would prevent the second image being drawn `on top of` the old one. Turn depth test off?


slenkar(Posted 2008) [#8]
yeah that worked