Advertisement

2d ordering

Started by July 17, 2003 01:59 AM
4 comments, last by Wavarian 21 years, 7 months ago
I''ve got a problem , I''m using glOrtho() to initialize a 2d rendering interface, but my 2d ordering seems messed up, and I haven''t a clue as to how to go about fixing it. For example, when I do something like this: drawFirstSquare(); drawSecondSquare(); First square is always on top, even if second square overlaps it. I need to be able to draw them both such that what ever is drawn first, stays at the bottom. I''ve solved this before by enabling and disabling depth masking, but surely there has to be a more convienient option. Any help?
Try enabling Z buffer and draw your quads with different z values (for example , the quad you want at the top, draw it with z = 0, the second one with z = -1 etc ...)
Sphax
Advertisement
I''d rather not have to do that considering how it could very well affect my per-pixel positioning of 2d elements.
Either:
glDisable(GL_DEPTH_TEST);
Or:
glDepthFunc(GL_LEQUAL);
quote:
Original post by wAVaRiaN
I''d rather not have to do that considering how it could very well affect my per-pixel positioning of 2d elements.


It won''t... Not when you''re in ortho mode... There is no perspective, so no matter the Z value, the square will be the same size anyway.

I just tried it, and you're right, it doesn't change the size. It seems a little annoying to change the z value for every object though.. Thanks for the hints though

Enigma: ah ty, thats exactly what i was looking for.

[edited by - wavarian on July 17, 2003 11:39:42 AM]

This topic is closed to new replies.

Advertisement