Skip to main content
GameDev.net gamedev.net
🔒 Locked

2d ordering

Started by Wavarian Jul 17, 2003 at 1:59 AM 4 replies 700+ views
Original Post
Wavarian
Wavarian
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?
Sphax
Sphax
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
Wavarian
Wavarian
I''d rather not have to do that considering how it could very well affect my per-pixel positioning of 2d elements.
Enigma
Enigma
Either:
glDisable(GL_DEPTH_TEST);
Or:
glDepthFunc(GL_LEQUAL);
James Trotter
James Trotter
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.

Wavarian
Wavarian
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.