Hello,
yes thanks this seems to be what I want but the pixels are only intermittently transparent within the hole!
Under certain circumstances almost the whole hole is there with irregular areas not ‘hole’.
It changes as the viewing angle changes.
I have tried all combinations of
//glDisable(GL_TEXTURE_2D);
//glBindTexture(GL_TEXTURE_2D, texture);
and nothing works.
Stranglely, it seems to not work at all if I drop the DepthFunc.
I have:
int InitGL()
{
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glPointSize(NORM_WIDTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glPolygonMode( GL_BACK, GL_FILL );
glPolygonMode( GL_FRONT, GL_FILL );
…
}
DrawGLScene()
{ /* draw scene underneath */
glPushMatrix();
glTranslatef(0.0, 0.4, 0.0);
//glDisable(GL_TEXTURE_2D);
glColorMask(0,0,0,0);
glEnable(GL_STENCIL_TEST);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilMask(GL_TRUE);
glStencilFunc(GL_NEVER, 1, 1);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
glColor3f( 1.0f, 1.0f, 1.0f );
//glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_TRIANGLES);
glVertex3f(0.5, 0.0, 0.5);
glVertex3f(-0.5,0.0, 0.5);
glVertex3f(-0.5,0.0, -0.5);
glVertex3f(0.5, 0.0, 0.5);
glVertex3f(0.5, 0.0, -0.5);
glVertex3f(-0.5,0.0, -0.5);
glEnd();
glStencilMask(GL_TRUE);
glStencilFunc(GL_EQUAL, 0, 1);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_TRUE);
glClear(GL_STENCIL_BUFFER_BIT);
glColor3f( 1.0f, 1.0f, 1.0f );
glBindTexture(GL_TEXTURE_2D, 0);
//glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glVertex3f(-3.0f,0.0f,-3.0f);
glVertex3f( 3.0f,0.0f,-3.0f);
glVertex3f( 3.0f,0.0f, 3.0f);
glVertex3f(-3.0f,0.0f,-3.0f);
glVertex3f(-3.0f,0.0f, 3.0f);
glVertex3f( 3.0f,0.0f, 3.0f);
glEnd();
return 1;
}