Appreciate the reply, perhaps I should post the code to answer the questions.
It is a work in progress , but working code as originally posted.
I did add
glClearStencil(0x0); without affecting the problem.
What are you calling "frame 0 and 1 ??
It is same as making two passes at the function ???
I noticed I am not disabling the stencil.
int OpenGL_Stencil(int (*Stencil)(int), int parameter = 0) {
#ifdef TRACK_STATE
printf("\nTRACKING ENTRY stenmcil %i function %s @line %d ",
system_state, __FUNCTION__,
__LINE__);
#endif
// clear all three buffers - not neccessary , default
glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//enable stencil test
glEnable(GL_STENCIL_TEST);
// turn off writing to color buffer
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// enable only to verify the stencil
//glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// setup stencil function
glStencilFunc(GL_ALWAYS, 1, 1);
// setup stencil operation
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); //
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// get stencil
// TODO need parameter here to verify stencil
parameter = Stencil(parameter); // TOK parameter);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
//
// switch keep area
if (parameter == 0) {
printf("\nStencil full circle parameter %i @function %s @line %i",
parameter, __FUNCTION__, __LINE__);
glStencilFunc(GL_EQUAL, 1, 1);
} // keep inside circle
else {
printf("\nStencil last circle parameter %i @function %s @line %i",
parameter, __FUNCTION__, __LINE__);
glStencilFunc(GL_NOTEQUAL, 1, 1);
} // keep all outside of stencil
//
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glutSwapBuffers();
// BUG does not update until passive mouse move
printf(" \nEXIT @function %s @line %i @time %s ", __FUNCTION__, __LINE__,__TIME__);
#ifdef TRACK_STATE
printf(
"\nTRACKING EXIT stencil %i function %s @line %d ",
system_state, __FUNCTION__,
__LINE__);
#endif
return parameter;
}