GL_ARB_shadow
drawShadowCasters()
The only shadow caster in the scene is a single quad that is rotating to show that the shadow map is working correctly. There is a switch that is passed in to draw with color or not. When we are creating the depth map, we have no need to define any colors as it is just a wasted function call.
void drawShadowCasters(bool color)
{
glPushMatrix();
{
glRotatef(rotation, 0.0, 0.0, 1.0);
if(color) glColor3f(1.0,0.0,0.0);
glBegin(GL_QUADS);
{
glVertex3f(-1.0, -1.0, 0.5);
glVertex3f(1.0, -1.0, 0.5);
glVertex3f(1.0, 1.0, 0.5);
glVertex3f(-1.0, 1.0, 0.5);
}
glEnd();
}
glPopMatrix();
}
drawShadowRecievers()
Here is the rest of the scene. This method does not need to be called during the shadow map creation, but needs to be called when rendering the final scene with shadows. It consists of four quads at various locations to show the shadows.
void drawShadowRecievers()
{
glBegin(GL_QUADS);
{
glColor3f(0.0, 0.0 ,1.0);
glVertex3f(0.0, 0.0, -2.0);
glVertex3f(-3.0, 0.0, -2.0);
glVertex3f(-3.0, -3.0, -2.0);
glVertex3f(0.0, -3.0, -2.0);
glColor3f(0.0, 1.0 ,1.0);
glVertex3f(0.0, 0.0, -1.0);
glVertex3f(3.0, 0.0, -1.0);
glVertex3f(3.0, -3.0, -1.0);
glVertex3f(0.0, -3.0, -1.0);
glColor3f(1.0, 0.0 ,1.0);
glVertex3f(0.0, 0.0, -1.5);
glVertex3f(-3.0, 0.0, -1.5);
glVertex3f(-3.0, 3.0, -1.5);
glVertex3f(0.0, 3.0, -1.5);
glColor3f(1.0, 1.0 ,0.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(3.0, 0.0, 0.0);
glVertex3f(3.0, 3.0, 0.0);
glVertex3f(0.0, 3.0, 0.0);
}
glEnd();
}