mindbreaker
11-09-2011, 11:35 AM
Hi,
I'm in the middle of porting some HLSL shaders to opengl (with CG) and I'm struggling a bit with the correct opengl stencil statements...
I have to states that need to be set for the stencil buffer :
//first one
StencilEnable = true;
StencilPass = REPLACE;
StencilRef = 1;
//second
StencilEnable = true;
StencilPass = KEEP;
StencilFunc = EQUAL;
StencilRef = 1;
I thought it would be this but it looks wrong sometimes. Withing my directX project, I'm clearing the backbuffer with stencil value 0
//first one
glClearStencil(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
//second one
glClearStencil(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
So, can anybody verify if this is correct (and what would needed to be changed)?
Thx!!
I'm in the middle of porting some HLSL shaders to opengl (with CG) and I'm struggling a bit with the correct opengl stencil statements...
I have to states that need to be set for the stencil buffer :
//first one
StencilEnable = true;
StencilPass = REPLACE;
StencilRef = 1;
//second
StencilEnable = true;
StencilPass = KEEP;
StencilFunc = EQUAL;
StencilRef = 1;
I thought it would be this but it looks wrong sometimes. Withing my directX project, I'm clearing the backbuffer with stencil value 0
//first one
glClearStencil(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
//second one
glClearStencil(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
So, can anybody verify if this is correct (and what would needed to be changed)?
Thx!!