| 95 | } |
| 96 | |
| 97 | void ODApplication::startClient() |
| 98 | { |
| 99 | ResourceManager& resMgr = ResourceManager::getSingleton(); |
| 100 | |
| 101 | { |
| 102 | //NOTE: This prevents a segmentation fault from OpenGL on exit. |
| 103 | //Creating the object sets up an OpenAL context using a static object |
| 104 | //contained in a function. If this is done after initialising Ogre::Root |
| 105 | //the application segfaults on exit for some reason. |
| 106 | sf::Music m; |
| 107 | } |
| 108 | Random::initialize(); |
| 109 | //NOTE: The order of initialisation of the different "manager" classes is important, |
| 110 | //as many of them depend on each other. |
| 111 | OD_LOG_INF("Creating OGRE::Root instance; Plugins path: " + resMgr.getPluginsPath()); |
| 112 | |
| 113 | // N.B: We don't use any ogre.cfg file, hence setting the file path value to "". |
| 114 | Ogre::Root ogreRoot(resMgr.getPluginsPath(), ""); |
| 115 | |
| 116 | ConfigManager configManager(resMgr.getConfigPath(), resMgr.getUserCfgFile(), |
| 117 | resMgr.getSoundPath()); |
| 118 | |
| 119 | if (!configManager.initVideoConfig(ogreRoot)) |
| 120 | return; |
| 121 | |
| 122 | // Needed for the TextRenderer and the Render Manager |
| 123 | Ogre::OverlaySystem overlaySystem; |
| 124 | |
| 125 | Ogre::RenderWindow* renderWindow = ogreRoot.initialise(true, "OpenDungeons " + VERSION); |
| 126 | |
| 127 | //NOTE: This is currently done here as it has to be done after initialising mRoot, |
| 128 | // but before running initialiseAllResourceGroups() |
| 129 | resMgr.setupOgreResources(ogreRoot.getRenderSystem()->getNativeShadingLanguageVersion()); |
| 130 | |
| 131 | // Setup Icon (On Windows) |
| 132 | // NOTE: On linux at least, the icon is usually handled through desktop files. |
| 133 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
| 134 | #define IDI_ICON1 1 // See dist/icon.rc to know the resource number. |
| 135 | HWND hwnd; |
| 136 | renderWindow->getCustomAttribute("WINDOW", static_cast<void*>(&hwnd)); |
| 137 | HINSTANCE hInst = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); |
| 138 | SetClassLong(hwnd, GCL_HICON, reinterpret_cast<LONG>(LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)))); |
| 139 | #endif |
| 140 | |
| 141 | //Initialise RTshader system |
| 142 | // IMPORTANT: This needs to be initialized BEFORE the resource groups. |
| 143 | // eg: Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups(); |
| 144 | // but after the render window, eg: mRoot->initialise(); |
| 145 | // This advice was taken from here: |
| 146 | // http://www.ogre3d.org/forums/viewtopic.php?p=487445#p487445 |
| 147 | if (!Ogre::RTShader::ShaderGenerator::initialize()) |
| 148 | { |
| 149 | OD_LOG_ERR("FATAL:" |
| 150 | "Failed to initialize the Real Time Shader System, exiting"); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups(); |
nothing calls this directly
no test coverage detected