Archived

This topic is now archived and is closed to further replies.

Z buffer(Depth buffer)

This topic is 5013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So what about depth buffer? It seems that I'' missed something about that buffer I draw a cube, there is a landscape below that object.I decided, that the easiest way to move the cube in 3D with mouse(so the cube is at the land) is do disable Z buffer. Mouse pointer took the coordinate of the land(box''s z-value is not in the buffer, because it is disabled), and I draw the cube at the new point of the mouse pointer Yep, it is working, I''m so proud, but... )) When z-buffer is disabled, my front side of the cube is obscured of the back side of the cube Does somebody know something about that? You wish to see a little code? OK There it is: for(int i=0; im_ListOfHouses.GetAt(i); if(pHouse->GetSelection()) glDisable(GL_DEPTH_TEST); pHouse->Draw(); if(pHouse->GetSelection()) glEnable(GL_DEPTH_TEST); ListOfHouses.GetNext(pos); } //GetSelection means that I hit the house with the mouse,And //now will move it at another place...May be here is not so //clear, but it works

Share this post


Link to post
Share on other sites
the depth buffer isn''t the z-axis. Remember that by the time things are rasterized they are nothing but collections of 2d pixels that have been shaded and transformed according to 3 space coordinates. The z-buffer stores the theoretical "distance" of each of these pixels from the screen. By disabling the z-test/buffer opengl has no sense of whether polygons are in front of or behind each other. So if you draw tha back of the box after the front, at just gets layered on top (painter''s algorithm).

Share this post


Link to post
Share on other sites
Yep, that''s right...I see that too...the back side of box is drawing after the front side...and depth buffer is disabled!So the back side obscure the front side.
I can change the order,but...I have and camera movement, when I move from the over side of the cube it will be the same
So does somebody know a tricky methot to resolve this?

Share this post


Link to post
Share on other sites