void Stage::run(void) { initGL(); initShadowMaps(); m_lastTime = glfwGetTime(); m_running = true; while (m_running) { double currentTime = glfwGetTime(); // limit fps if (m_framerate == 0 || currentTime - m_timer > 1.0f / float(m_framerate)) { update(currentTime); if (m_camera != 0) render(); } } }
void VarianceShadowMapHandler::render(RenderAction *a, DrawEnv *pEnv) { const ShadowStageData::LightStore &vLights = _pStageData->getLights(); const ShadowStageData::NodeStore &vTransparents = _pStageData->getTransparents(); const ShadowStageData::LStateStore &vLightStates = _pStageData->getLightStates(); if(_pStageData->getShadowMaps().size() != vLights.size()) { initShadowMaps(); } if(_bShadowMapsConfigured == false) { configureShadowMaps(); } if(_uiMapSize != _pStage->getMapSize()) { updateShadowMapSize(); } if(_pSceneFBO == NULL) initSceneFBO(pEnv, false); if(_width != pEnv->getPixelWidth () || _height != pEnv->getPixelHeight() ) { updateSceneFBOSize(pEnv, false); } commitChanges(); //Used for ShadowFactorMap _firstRun = 1; if(_pStage->getMapAutoUpdate() == true || _pStage->_trigger_update == true ) { createColorMapFBO(a, pEnv); //deactivate transparent Nodes for(UInt32 t = 0;t < vTransparents.size();++t) { vTransparents[t]->setTravMask(0); } createShadowMapsFBO(a, pEnv); // switch on all transparent geos for(UInt32 t = 0;t < vTransparents.size();++t) { vTransparents[t]->setTravMask(TypeTraits<UInt32>::BitsSet); } //filterShadowMaps(pEnv); UInt32 uiActiveLightCount = 0; for(UInt32 i = 0;i < vLights.size();i++) { if(vLightStates[i] != 0) { if(_pStage->getGlobalShadowIntensity() != 0.0 || vLights[i].second->getShadowIntensity() != 0.0) { createShadowFactorMapFBO(a, pEnv, i, uiActiveLightCount); ++uiActiveLightCount; } } } _pStage->_trigger_update = false; } setupDrawCombineMap1(a); }