void ShadowScene::render(){ ShaderManager & shaderManager = ShaderManager::getInstance(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, iWindowWidth, iWindowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, float(iWindowWidth)/float(iWindowHeight), 0.4, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); m_pCam->lookAt(); shaderManager.getShader("light")->Activate(); shaderManager.getShader("light")->setUniformMatrix4fv("eyematrix",shadowmatrix); shaderManager.getShader("light")->Desactivate(); renderEnvironment(false); glPopMatrix(); }
void ShadowScene::preRender(){ //Render the depth on a texture, form light point of view glViewport(0, 0, (GLint)iShadowMapWidth, (GLint)iShadowMapHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(spotCutOff0*2.0+fallOff0*2.0, float(iShadowMapWidth)/float(iShadowMapHeight), 0.4, 1000.0); glGetFloatv(GL_PROJECTION_MATRIX,projectionMatrix); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); m_pShadowMapFBO->activate(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glPushMatrix(); glLoadIdentity(); //light point of view glTranslatef(-m_fLightDistance[0],-m_fLightDistance[1],-m_fLightDistance[2]); glRotatef(-fAngle,0.0,1.0,0.0); glTranslatef(-m_fLightPosition[0],-m_fLightPosition[1],-m_fLightPosition[2]); glGetFloatv(GL_MODELVIEW_MATRIX,modelviewMatrix); glPushMatrix(); glLoadIdentity(); glMultMatrixf (projectionMatrix); glMultMatrixf (modelviewMatrix); glGetFloatv(GL_MODELVIEW_MATRIX, shadowmatrix); glPopMatrix(); glCullFace(GL_FRONT); renderEnvironment(true); glCullFace(GL_BACK); glPopMatrix(); m_pShadowMapFBO->desactivate(); }
/** * Deals with screen events. Must be called every time the screen is redraw. */ void display( void ) { glClearColor( fabs( colorGrid - 1.0 ), fabs( colorGrid - 1.0 ), fabs( colorGrid - 1.0 ), 1.0 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); renderGrid( ); glPushMatrix( ); { path = 0; renderEnvironment( ); renderTree( env.getValidPaths()->_root, 0); } glPopMatrix( ); glutSwapBuffers( ); }