Noob question, depth vs stencil buffer

Started by
2 comments, last by dr_slash_uh 20 years, 1 month ago
The problem I am haivng is deciding which method I should use to cut a hole in a polygon to make a donut shape. I was wondering if I should use the depth buffer by drawing the "hole" first, than draw the polygon around the hole. I would draw the hole using glDrawBuffer(GL_NONE), than I turn use glDrawbuffer(GL_BACK) than draw the polygon. I like that technique, but i was wondering if I can do the same thing BETTER or more effecienty with the stencil buffer. Thanks [edited by - dr_slash_uh on March 24, 2004 7:54:48 PM]
Advertisement
Use the stencil buffer of course. Draw the hole as 1s in the stencil buffer and then draw the poly only where stencil test passes (!=1).


"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Or, you could use a texture with an alpha channel

My Website | Everything you need to know about 3D Graphics | Google | Search the Forums

[edited by - Luke Philpot on March 25, 2004 1:04:33 PM]
See what I am trying to do is make a doom type game with opengl. the problem I was having was making donut shaped sectors. What I originally though of doing was "ACTUALY" cutting a hole in a sector, basically breaking up 1 polygon into many polygons with a hole in it. So I just decided the easier thing to do would be to just simulate a whole by using one of the buffer techniques. I am going to look into the stencil buffer method.

Thanks luke and poppet.

This topic is closed to new replies.

Advertisement