Does anyone have any example code to setup the stencil buffer, and draw stencil shadows correctly? I have got the stencil volumes created, and just need to render them now to look like shadows, instead of big solid volumes.
gldisable GL_LIGHTING glcolor3f 0,0,0 glPushAttrib(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT|GL_POLYGON_BIT|GL_STENCIL_BUFFER_BIT) glDisable( GL_LIGHTING )' Turn Off Lighting glDepthMask( GL_FALSE )' Turn Off Writing To The Depth-Buffer glDepthFunc( GL_LEQUAL )' glEnable( GL_STENCIL_TEST )' Turn On Stencil Buffer Testing glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE )' Don't Draw Into The Colour Buffer glStencilFunc( GL_ALWAYS, 1, HexToInt("0xFFFFFFFFL")) 'First Pass. Increase Stencil Value In The Shadow glFrontFace(GL_CCW) glStencilOp(GL_KEEP,GL_KEEP,GL_INCR) lightlink.shadowvolume.draw() 'Second Pass. Decrease Stencil Value In The Shadow glFrontFace(GL_CW) glStencilOp(GL_KEEP,GL_KEEP,GL_DECR) lightlink.shadowvolume.draw() glFrontFace( GL_CCW ); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE )' Enable Rendering To Colour Buffer For All Components 'Draw A Shadowing Rectangle Covering The Entire Screen glColor4f(0.0,0.0,0.0,0.4 ) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) glStencilFunc(GL_NOTEQUAL,0,HexToInt("0xFFFFFFFFL")) glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP) glPushMatrix() glLoadIdentity() gldisable GL_CULL_FACE glBegin(GL_QUADS); tformpoint 10,10,10,0,camera glvertex3f tformedx(),tformedy(),tformedz() tformpoint -10,10,10,0,camera glvertex3f tformedx(),tformedy(),tformedz() tformpoint -10,-10,10,0,camera glvertex3f tformedx(),tformedy(),tformedz() tformpoint 10,-10,10,0,camera glvertex3f tformedx(),tformedy(),tformedz() glEnd() glPopMatrix() glPopAttrib() glcolor3f 1,1,1 glenable GL_LIGHTING glenable GL_CULL_FACE gldisable GL_BLEND

