MCPcopy Create free account
hub / github.com/OpenMW/openmw / prepareEngine

Method prepareEngine

apps/openmw/engine.cpp:723–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721}
722
723void OMW::Engine::prepareEngine()
724{
725 mStateManager = std::make_unique<MWState::StateManager>(mCfgMgr.getUserDataPath() / "saves", mContentFiles);
726 mEnvironment.setStateManager(*mStateManager);
727
728 const bool stereoEnabled = Settings::stereo().mStereoEnabled || osg::DisplaySettings::instance().get()->getStereo();
729 mStereoManager = std::make_unique<Stereo::Manager>(
730 mViewer, stereoEnabled, Settings::camera().mNearClip, Settings::camera().mViewingDistance);
731
732 osg::ref_ptr<osg::Group> rootNode(new osg::Group);
733 mViewer->setSceneData(rootNode);
734
735 createWindow();
736
737 mVFS = std::make_unique<VFS::Manager>();
738
739 VFS::registerArchives(mVFS.get(), mFileCollections, mArchives, true, &mEncoder.get()->getStatelessEncoder());
740
741 mResourceSystem = std::make_unique<Resource::ResourceSystem>(
742 mVFS.get(), Settings::cells().mCacheExpiryDelay, &mEncoder.get()->getStatelessEncoder());
743 mResourceSystem->getSceneManager()->getShaderManager().setMaxTextureUnits(mGlMaxTextureImageUnits);
744 mResourceSystem->getSceneManager()->setUnRefImageDataAfterApply(
745 false); // keep to Off for now to allow better state sharing
746 mResourceSystem->getSceneManager()->setFilterSettings(Settings::general().mTextureMagFilter,
747 Settings::general().mTextureMinFilter, Settings::general().mTextureMipmap,
748 static_cast<float>(Settings::general().mAnisotropy));
749 mEnvironment.setResourceSystem(*mResourceSystem);
750
751 mWorkQueue = new SceneUtil::WorkQueue(Settings::cells().mPreloadNumThreads);
752 mUnrefQueue = std::make_unique<SceneUtil::UnrefQueue>();
753
754 mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(mWorkQueue,
755 new SceneUtil::WriteScreenshotToFileOperation(mCfgMgr.getScreenshotPath(),
756 Settings::general().mScreenshotFormat,
757 Settings::general().mNotifyOnSavedScreenshot ? std::function<void(std::string)>(ScreenCaptureMessageBox{})
758 : std::function<void(std::string)>(IgnoreString{})));
759
760 mScreenCaptureHandler = new osgViewer::ScreenCaptureHandler(mScreenCaptureOperation);
761
762 mViewer->addEventHandler(mScreenCaptureHandler);
763
764 mL10nManager = std::make_unique<L10n::Manager>(mVFS.get());
765 mL10nManager->setPreferredLocales(Settings::general().mPreferredLocales, Settings::general().mGmstOverridesL10n);
766 mEnvironment.setL10nManager(*mL10nManager);
767
768 mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");
769 mEnvironment.setLuaManager(*mLuaManager);
770
771 // Create input and UI first to set up a bootstrapping environment for
772 // showing a loading screen and keeping the window responsive while doing so
773
774 const auto keybinderUser = mCfgMgr.getUserConfigPath() / "input_v3.xml";
775 bool keybinderUserExists = std::filesystem::exists(keybinderUser);
776 if (!keybinderUserExists)
777 {
778 const auto input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml");
779 if (std::filesystem::exists(input2))
780 {

Callers

nothing calls this directly

Calls 15

registerArchivesFunction · 0.85
LogClass · 0.85
registerExtensionsFunction · 0.85
compileAllFunction · 0.85
setStateManagerMethod · 0.80
setMaxTextureUnitsMethod · 0.80
getSceneManagerMethod · 0.80
setFilterSettingsMethod · 0.80
setResourceSystemMethod · 0.80
setL10nManagerMethod · 0.80
setLuaManagerMethod · 0.80

Tested by

no test coverage detected