/** * Initialize an EGL context for the current display. */ int Engine::initDisplay() { if( !mInitializedResources ) { LOGI("INIT_RESOURCES"); mGlContext->Init( mApp->window ); loadResources(); mInitializedResources = true; } else { LOGI("RESOURCES_ALREADY_INITIALIZED"); // initialize OpenGL ES and EGL if( EGL_SUCCESS != mGlContext->Resume( mApp->window ) ) { LOGI("RESUME_CONTEXT"); unloadResources(); loadResources(); } } glEnable( GL_CULL_FACE ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); mScreenWidth = mGlContext->GetScreenWidth(); mScreenHeight = mGlContext->GetScreenHeight(); glViewport( 0, 0, mScreenWidth, mScreenHeight ); mCamera.initView(); mCamera.update(); return 0; }
bool BResourceManager::loadResources(int nbr) { if (_newConfFile == false && _loaded == _total) return false; //Log::debug("DEBUT LOAD NEW_CONF = %i LOADED = %i/%i", _newConfFile, _loaded, _total); if (_index == 0 ) { _total = boost::get<int>(BConfigLoader::instance()->conf()["resources_count"]); unloadResources(BConfigLoader::instance()->confToDelete()); initIterators(); _index = 1; } for (; _current != _end && nbr > 0; nbr--, ++_current) { switch (_type) { case IMAGE: { BRRawData data = boost::get<BRRawData>(_current->second); loadImage(data.path, data.path); } break; case FONT: { BRRawData data = boost::get<BRRawData>(_current->second); loadFont(data.name, data.path, data.other.fontsize); } break; case SOUND_BGM: { BRRawData data = boost::get<BRRawData>(_current->second); loadSound(data); } break; case SOUND_EFFECT: { BRRawData data = boost::get<BRRawData>(_current->second); loadSound(data); } break; } _loaded++; } //Log::debug("After for Loaded = %i, Total = %i", _loaded, _total); if (_loaded < _total && nbr > 0) { _type += 1; if (initIterators()) loadResources(nbr); //return 0; } _newConfFile = _loaded < _total; //Log::debug("Loaded = %i, Total = %i", _loaded, _total); return _loaded < _total; }
void Module::unload() { leave(); unloadArea(); unloadIFO(); unloadResources(); _module.clear(); }
/************************************************************************* Destructor for scheme objects *************************************************************************/ Scheme::~Scheme(void) { unloadResources(); char addr_buff[32]; sprintf(addr_buff, "(%p)", static_cast<void*>(this)); Logger::getSingleton().logEvent("GUI scheme '" + d_name + "' has been " "unloaded (object destructor). " + addr_buff, Informative); }
void ResourceManager::shutdown() { for (auto texture : _textures) { delete texture.second; } for (auto item : _datFilesItems) { delete item.second; } for (auto dat : _datFiles) { delete dat; } unloadResources(); }
void Module::unload(bool completeUnload) { leaveArea(); unloadArea(); if (completeUnload) { unloadPC(); unloadTexturePack(); } unloadIFO(); unloadResources(); _eventQueue.clear(); _delayedActions.clear(); _newModule.clear(); _hasModule = false; _module.clear(); _entryLocation.clear(); _entryLocationType = kObjectTypeAll; }
/** * Just the current frame in the display. */ void Engine::drawFrame() { if(!mHasFocus) return; float dt = mTimer.tick(); mCollisionManager.update(dt); mContainer.update(dt); mDice.update( dt ); glViewport(0, 0, mShadowMap.SHADOW_WIDTH, mShadowMap.SHADOW_HEIGHT); glBindFramebuffer(GL_FRAMEBUFFER, mShadowMap.mDepthMapFBO); glClear(GL_DEPTH_BUFFER_BIT); glCullFace(GL_FRONT); mDice.drawToShadowMap(mShadowMap); mContainer.drawToShadowMap(mShadowMap); glBindFramebuffer(GL_FRAMEBUFFER, 0); glCullFace(GL_BACK); glViewport(0, 0, mScreenWidth, mScreenHeight); glClearColor( 0.5f, 0.5f, 0.5f, 1.f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); mDice.draw(mShadowMap); mContainer.draw(mShadowMap); //mQuad.draw(mShadowMap); // debug quad from shadow maps perspective // Swap if( EGL_SUCCESS != mGlContext->Swap() ) { LOGI("RELOAD"); unloadResources(); loadResources(); } }
void ResourceManager::shutdown() { unloadResources(); }
ResourceManager::~ResourceManager() { unloadResources(); }
/************************************************************************* Destructor for scheme objects *************************************************************************/ Scheme::~Scheme(void) { unloadResources(); Logger::getSingleton().logEvent((utf8*)"GUI scheme '" + d_name + "' has been unloaded.", Informative); }
void Vt::Scene::SceneManager::_unloadResources() { for (auto & scene : mScenes) { scene.second->_unload(); } unloadResources(); }
bool SimInterior::loadShape(const char* fileName) { // setFilename returns false if the filename is invalid, OR if the filename // is the same as the one already set. In either case, we exit wo/ doing // any work... // if (setFilename(fileName) == false) { return false; } // NOTE: This function is VERY poor on error checking, there are only a few // asserts in ITRInstance(). Maybe restructure to be a bit more robust? // ResourceManager *rm = SimResource::get(manager); Resource<ITRShape> itrShape; bool missionLit; // check if we need to try and find the missionlit ver if( rm->findFile( fileName ) ) { missionLit = missionLitName(); itrShape = rm->load( fileName); } else { if( !missionLitName() ) return( false ); String base = String(fileName); getBaseFilename( base ); if( rm->findFile( base.c_str() ) ) itrShape = rm->load(base.c_str()); missionLit = false; } if( !bool( itrShape ) ) return( false ); // If we make it to here, then all is cool, nuke the old resources... // unloadResources(); ITRInstance* pInstance = new ITRInstance(rm, itrShape, 0); if( missionLit ) pInstance->setMissionLit(); renderImage.instance = pInstance; // Set the geometry for the database and collision image. Note that this // is the highest level of state 0 for the interior. May have to change // the collision image geometry pointer on detail level change, probably // will only change the database pointer on state switches... // updateBoundingBox(); SimContainer* root = NULL; root = findObject(manager,SimRootContainerId,root); root->addObject(this); getInstance()->getAutoStartIDs(animatingLights); SimSet* pITRTimerSet = dynamic_cast<SimSet*>(manager->findObject(SimITRTimerSetId)); if (pITRTimerSet == NULL) manager->addObject(new SimTimerSet(1.0f/15.0f, SimITRTimerSetId)); bool timerSuccess = addToSet(SimITRTimerSetId); AssertFatal(timerSuccess == true, "Could not add to SimITRTimerSet"); return true; }