I don't get it. :?
Here is my brief code for realtime shadow.
while (true)
{
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
World.renderScene(FrameBuffer);
for (int i=0;i<VisList.getMaxSize();i++)
{
VisList.getData(i,data);
if (IsShadowReceiver(data))
{
//render the face and the shadow
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 0x1, 0);
glEnable(GL_DEPTH_TEST);
//draw the face with stencil mask
World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
glDisable(GL_DEPTH_TEST);
//projective shadow
glStencilFunc(GL_EQUAL, 1, 1);
glEnable(GL_BLEND);
list=shadowpolygon(data,lightpos); //find the object that cast a shadow on this face
for (int j=0;j<list.length;j++)
{
shadowmatrix(matrix,data,lightpos); //create the matrix to project a shadow polygon on the face
GL11.glPushMatrix();
GL11.glMultMatrix(matrix);
mydraw(list[j]); //draw the projective shadow
GL11.glPopMatrix();
}
glDisable(GL_BLEND);
//remove the stencil mask
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
} else
{
//no shadow just render the face
World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
}
}
FrameBuffer.update();
FrameBuffer.updateGLOnly();
Thread.yield();
}
Any suggestion?