I want to clip part of a wall with the stencil buffer.I can rotate and translate the scene with the arrow keys. But the problem is that the stencil pattern is moved when i move the camera--It seems that this pattern has been attached to the viewr!Here's the code:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
| GL_STENCIL_BUFFER_BIT );
glLoadIdentity();
glRotatef( 360.0f - yrot, 0.0f, 1.0f, 0.0f );
glTranslatef( -xpos, -ypos , -zpos );
glDepthMask( GL_FALSE );
glStencilFunc( GL_NEVER, 1, 1 );
glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
glBegin( GL_QUADS );
glVertex3f( -0.5, -0.5,-2.0 );
glVertex3f( 0.5, -0.5,-2.0 );
glVertex3f( 0.5, 0.5,-2.0 );
glVertex3f( -0.5, 0.5,-2.0 );
glEnd();
glDepthMask( GL_TRUE );
glStencilMask( GL_FALSE );
glStencilFunc( GL_EQUAL, 1, 1 );
glColor3f( 1.0f, 0.0f, 0.0f );
glBegin( GL_QUADS );
glVertex3f( -1.0, -1.0,-2.0 );
glVertex3f( 1.0, -1.0,-2.0 );
glVertex3f( 1.0, 1.0,-2.0 );
glVertex3f( -1.0, 1.0,-2.0 );
glEnd();
I need a *fixed* pattern.So what should i do?
-Ehsan-



