i'm trying to draw stencil shadows with PSPGL but i can't get it working,
here is the code:
Code: Select all
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT |
GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDepthMask(GL_FALSE);
glDepthFunc(GL_LEQUAL);
glEnable(GL_STENCIL_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); // no color buffer drawing
glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFFL );
glColorMask(0, 0, 0, 0);
glEnable(GL_CULL_FACE);
glStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
glCullFace(GL_FRONT);
glBegin(GL_TRIANGLES);
s32 i;
for(i=0; i<count; ++i)
glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);
glEnd();
glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
glCullFace(GL_BACK);
glBegin(GL_TRIANGLES);
for(i=0; i<count; ++i)
glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);
glEnd();
glPopAttrib();