So, I've been following nehe's guide to creating shadows, and for whatever reason the shadows just aren't rendering. Not having an excellent understanding of things like the stencil-buffer means I'm sort of learning things as I go along. I hate outsourcing my debugging, but I'm kind of stumped here. does anybody know what's wrong?
[source lang=cpp]glEnable(GL_CULL_FACE);glCullFace(GL_FRONT);glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );glDisable( GL_LIGHTING );glDepthMask( GL_FALSE );glDepthFunc( GL_LEQUAL );glEnable( GL_STENCIL_TEST );glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );glStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFFL );glFrontFace( GL_CCW );glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );//shadow volume quad drawing code here//I've checked to make sure that the code to draw the volume is running//so I thought I'd spare you thatglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);glColor4f(0.0f, 0.0f, 0.0f, 0.4f);glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);glPushMatrix();glLoadIdentity();glMatrixMode(GL_PROJECTION);glOrtho(0, 1, 1, 0, 0, 1);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(0, 1); glVertex2i(1, 1); glVertex2i(1, 0);glEnd();glEnable(GL_DEPTH_TEST);glPopMatrix();glPopAttrib();glEnable(GL_LIGHTING);glDisable(GL_STENCIL_TEST);glShadeModel(GL_SMOOTH);glDisable(GL_CULL_FACE);[/source]
And I run that every frame. I have a feeling it's a problem in how I arranged the various gl*() commands. Only the large, screen-covering shadow is drawing with no parts being cut out.