Jump to content
  • Advertisement
Sign in to follow this  

Clipping. 2D and 3D?

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

Hi guys, anyone got a clipping tutorial. I want to use it with 2D ( for my GUI, so for example, if I have a window pane that holds an image, if the image goes outside of the clip rect associated with the pane, then the image will be clipped appropriately ). Presumably a 3D clipper algo will be very similar and possibly could be used as a 2D clipper?? cheers,

Share this post

Link to post
Share on other sites
I do not have any clipping tutorial links to give you, but I do have an alternate and very simple way to do what you want using the stencil buffer.

All you need to have is a 1 bit (could be more, but you only need 1 to do what I'm about to tell you) stencil buffer, here's how you'd do what you want with your GUI example:

1) Set the stencil values to 0 (probably along with clearing the z-buffer)
2) Turn off stencil tests
3) Turn on stencil writes and set it to set the pixels to 1
4) Render your GUI
5) Turn off stencil writes
6) Turn on stencil tests and set it to only let pixels pass where the stencil value is 1
7) Render your scene

If you don't know about stencil buffers or what they do, you may read a small explanation about them here. Also, google is your friend.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!