Randall, sorry for not providing the code in the first post. Here it is:
// Drawing for Shadow Mapping
GLfloat ratio = ( GLfloat )window_width / ( GLfloat )window_height;
GLfloat light_look_at[] = {0.0f, 0.0f , 0.0f };
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, shader->shadow_fbo);
glUseProgramObjectARB(0);
glViewport(0,0, shader->shadow_map_width, shader->shadow_map_height);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glOrtho( 0.0f, shader->shadow_map_width, 0.0f, shader->shadow_map_height , 300, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( env->light_position[0] + translatex, env->light_position[1], env->light_position[2] + translatez , light_look_at[0] + translatex, light_look_at[1], light_look_at[2]+translatez, 0.0, up , 0.0);
glCullFace(GL_FRONT);
drawWorld();
setTextureMatrix();
//------ Draw Scene
glViewport(0,0, window_width, window_height);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCullFace(GL_BACK);
checkOpenGLErrors();
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 45.0f, ratio, 0.1f, 10000.0f );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
drawCompleteWorld();
And the setTextureMatrix() is:
void setTextureMatrix( )
{
static double modelView[16];
static double projection[16];
const GLdouble bias[16] = {
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0};
glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glMatrixMode(GL_TEXTURE);
glActiveTextureARB(GL_TEXTURE7);
glLoadIdentity();
glLoadMatrixd(bias);
glMultMatrixd (projection);
glMultMatrixd (modelView);
glMatrixMode(GL_MODELVIEW);
}
Remdul, thank you, I added the line as well as tried to disable the debugging but no effect.
Thanks arekkusu, I am taking a look at the specification now.