• Advertisement

Archived

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

Confused about z-buffer

This topic is 5835 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

i am pretty new with this opengl stuff. only been trying it for about a month. i am having a problem the whole depth testing thing. i have scene where a solid object is using glDepthTest, and i have a another object which doesnt. how do i get the non-depth tested object to not draw in front of the other object?

Share this post


Link to post
Share on other sites
Advertisement
There are two ways that you can "not use" the z buffer.

You can not write to it, only read, or you can not even test with it at all.

For the latter, it''s really simple. Just call glDisable (GL_DEPTH_TEST).

For example:

// Draw z buffered objects
glEnable (GL_DEPTH_TEST);
DrawObjects ();

// Draw non-z buffered objects
glDisable (GL_DEPTH_TEST);
DrawOtherObjects ();

For the former, the term to describe this is "depth masking". You would want to use this for things like laser beams, where you want to test against the objects you''ve already drawn, but not actually write new Z values.

// Draw z buffered objects
glEnable (GL_DEPTH_TEST);
DrawObjects ();

// Draw depth masked objects
glDepthMask (GL_TRUE);
DrawLasers ();
glDepthMask (GL_FALSE);

Hope this helps.

- Pete

Share this post


Link to post
Share on other sites
i tried glDepthMask(); it is not the solution.
what i have is a simple NeHe particle engine at the bottom of a rocket. when i rotate the rocket''s head positive z-axis, you can still see the particle engine through the end of the rocket.
i disable depth testing to draw the particle engine and enable it at the end of the function but that doesnt do anything but draw the rocket correctly (on redraws for movement). any other ideas i could try?

Share this post


Link to post
Share on other sites
WAIT I apologize!!!!

depth masking worked...i was just using it wrong. like i said, i am new at this.

thanx for the help!!

Share this post


Link to post
Share on other sites

  • Advertisement