0. Clear color and depth buffers: glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
1. Draw all 3D "Stuff"
2. Turn off depth testing: glDisable(GL_DEPTH_TEST);
3. Switch to ortho coordinate system, draw all 2D "Stuff" over top of
3D Stuff
4. Switch back to perspective coordinate system, turn depth testing
back on: glEnable(GL_DEPTH_TEST);
5. Swap Buffers
6. Repeat...
You "should" draw all your 3D objects first, then the 2D elements over
top of them. Unless I am misunderstanding your ultimate goal.
Richard
On Nov 24, 2007, at 11:07 AM, Lorenzo wrote:
Hi Daniel,
true, if I disable the depth test I don't get the bad intersection.
This works with the scrolling text which is a 2D object (Quad). But
in case
I draw a 3D object, I get a bad result. The surfaces get all drawn
without
depth. Any solution?
Best Regards
--
Lorenzo
email: email@hidden
From: Daniel Koch <email@hidden>
Date: Sat, 24 Nov 2007 10:08:33 -0500
To: Lorenzo <email@hidden>
Cc: email@hidden
Subject: Re: glClear(GL_DEPTH_BUFFER_BIT)
Hi Lorenzo,
If you just disable the depth test before drawing drawing the
scrolling
text, and enable it again afterwards you should be able to accomplish
what you want without loosing the contents of your depth buffer.
Hope this helps,
Daniel
Lorenzo wrote:
Hi,
I have to draw a cube in a 3D space using a perspective camera,
then a scrolling text using an orthogonal camera. In some case,
when the
cube is too close, it intersects scrolling the text, even if I use 2
cameras. So I used a trick: when I set the ortho camera, before I
draw the
scrolling text, I call again glClear(GL_DEPTH_BUFFER_BIT). It
works very
well. I do
clear color buffer and depth buffer
set camera 1 (perspective)
draw the cube
set camera 2 (ortho)
clear depth buffer
draw the scrolling text
draw other objects (?)
flush
The problem is that now I have not longer my depth buffer, so I
can't
properly draw any other 3D object, not even if I re-set the camera
1.
I cannot change the drawing object order because I can't know in
advance.
Reading-Writing the z buffer is time consuming, so please have you
a good
idea to draw as on different layers?
Best Regards
--
Daniel Koch -+- Graphics Technology Lead -+- TransGaming Technologies
email@hidden +1 613.244.1111 x352 www.transgaming.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden