View Full Version : stencil buffer
06-12-2002, 07:59 AM
I have a bunch of different objects in the scene that I need to use the stencil buffer to fill their interiors. I have a different texture to overlay for each one. The problem is, I don't want one texture to write on top of another object's stencil.
Should I use glClearStencil before drawing each one? That sounds slow.
Is there a better way?
06-12-2002, 08:37 AM
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glClearStencil is used to tell OpenGL what value the stencil should be cleared to, when you use the above.
06-12-2002, 10:57 AM
I think I will still have the same problem though. I'll try to explain better:
Say that I have 2 stenciled areas and I want a different texture drawn for each stencil. The stencils might be close together and when I draw my big texture, it will draw into the other stencil.
How do I avoid this?
I could clear the stencil buffer before drawing each stencil but that doesn't seem very optimal. I want to generate all of my stencils and THEN draw them all with different textures.
06-12-2002, 02:07 PM
When you draw each area you can specify a replace in stencil op with a ref value in stencil func.
Then when you want to fill you can perform a stencil equals test with a ref value that is equal to the region value used earlier for the area you want to fill.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.