Jump to content
  • Advertisement

Archived

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

Andrew Russell

Depth Buffer Tricks

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

OK, basicly I want to use the depth buffer to do something like a stencil buffer. I have a poly, with 2 polys over the top. [edit - Oh, and I am in ortho mode] in my Init Code, I have glDepthFunc(???????); And in my drawing code: glTranslatef(0.0f, 0.0f, ????) PolyThatRestrictsArea() glEnable(GL_DEPTH_TEST); glTranslatef(0.0f, 0.0f, ????) PolysToOverlayOnly() glDisable(GL_DEPTH_TEST); (obviously, that is not the _exact_ code) I want the poly in PolyThatRestrictsArea() to basicly form the boundies for PolysToOverlayOnly(), and also to be drawn. Can anyone help me with what the ???'s should be? or what else I may be doing wrong. This is the only place I am using the depth buffer, and in theory it should work. What's going on? Thanks to anyone who can help, Andrew.

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Refrence | OGL v D3D | File Formats | Go FAQ yourself ]
[edited by - Andrew Russell on June 30, 2002 5:55:17 AM]

Share this post


Link to post
Share on other sites
Advertisement
OK, after a fair bit of fiddeling, I fixed it.

As far as I can tell, when depth test is disabled, the depth buffer does not get written to. so this is my new code.


glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_GEQUAL);
glTranslatef(0.0f, 0.0f, 0.5f)
PolyThatRestrictsArea();
glDepthFunc(GL_GEQUAL);
glTranslatef(0.0f, 0.0f, -0.25f)
PolysToOverlayOnly();
glDisable(GL_DEPTH_TEST);



Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Refrence | OGL v D3D | File Formats | Go FAQ yourself ]

Share this post


Link to post
Share on other sites
Just an little idea to fiddle around with, if you are using the depth buffer as a mask.

glDepthRange(n,n);

If you render a polygon using this setting, it will *always* fill the depth buffer with the specified value n. It won''t mess with anything else (eg. texture perspective correction, etc), it just fills the z buffer with a constant value over the area of that polygon. That''s very handy to draw masks and similar.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!