I am having a bit of trouble with shadows in OpenGL. The models have a shadow on every face, OpenGL gives it a darkness through which direction the face is pointing from the source of light. I noticed that the light just passes through the faces, meaning if two planes where right next to each other and a light source is on one side, the plane on the farther side is still light up.
How would I stop this from happening? I need some shadow code that works for the entire 3D environment.
private static void setUpLighting() {
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModel(GL_LIGHT_MODEL_AMBIENT, BufferTools.asFlippedFloatBuffer(new float[]{0.05f,
0.05f, 0.05f, 1f}));
glLight(GL_LIGHT0, GL_POSITION,
BufferTools.asFlippedFloatBuffer(new float[]{0, 0, 0, 1}));
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glEnable(GL_TEXTURE_2D);
}