| 12 | const std::string BaseManager::MyGuiResourceGroup = "MyGuiResourceGroup"; |
| 13 | |
| 14 | bool BaseManager::createRender(int _width, int _height, bool _windowed) |
| 15 | { |
| 16 | Ogre::String pluginsPath; |
| 17 | |
| 18 | #ifndef OGRE_STATIC_LIB |
| 19 | pluginsPath = "plugins.cfg"; |
| 20 | #endif |
| 21 | |
| 22 | mRoot = new Ogre::Root(pluginsPath, "ogre.cfg", "Ogre.log"); |
| 23 | auto renderSystem = mRoot->getRenderSystemByName(mRoot->getAvailableRenderers()[0]->getName()); |
| 24 | mRoot->setRenderSystem(renderSystem); |
| 25 | |
| 26 | mWindow = mRoot->initialise(false); |
| 27 | |
| 28 | SDL_SysWMinfo wmInfo; |
| 29 | SDL_VERSION(&wmInfo.version) |
| 30 | if (SDL_GetWindowWMInfo(mSdlWindow, &wmInfo) == SDL_FALSE) |
| 31 | { |
| 32 | OGRE_EXCEPT( |
| 33 | Ogre::Exception::ERR_INTERNAL_ERROR, |
| 34 | "Couldn't get WM Info! (SDL2)", |
| 35 | "BaseManager::createRender"); |
| 36 | } |
| 37 | |
| 38 | Ogre::NameValuePairList params; |
| 39 | if (mEnableVSync) |
| 40 | params["vsync"] = "true"; |
| 41 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX |
| 42 | params["parentWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.x11.window)); |
| 43 | #elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
| 44 | params["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.win.window)); |
| 45 | #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
| 46 | params["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.cocoa.window)); |
| 47 | #endif |
| 48 | mWindow = mRoot->createRenderWindow("MainRenderWindow", _width, _height, false, ¶ms); |
| 49 | |
| 50 | mSceneManager = mRoot->createSceneManager(); |
| 51 | |
| 52 | mCamera = mSceneManager->createCamera("BaseCamera"); |
| 53 | mCamera->setNearClipDistance(5); |
| 54 | |
| 55 | mCameraNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); |
| 56 | mCameraNode->attachObject(mCamera); |
| 57 | mCameraNode->setPosition(400, 400, 400); |
| 58 | mCameraNode->setFixedYawAxis(true); |
| 59 | mCameraNode->lookAt(Ogre::Vector3(0, 150, 0), Ogre::Node::TransformSpace::TS_WORLD); |
| 60 | |
| 61 | // Create one viewport, entire window |
| 62 | Ogre::Viewport* vp = mWindow->addViewport(mCamera); |
| 63 | // Alter the camera aspect ratio to match the viewport |
| 64 | mCamera->setAspectRatio((float)vp->getActualWidth() / (float)vp->getActualHeight()); |
| 65 | |
| 66 | // Set default mipmap level (NB some APIs ignore this) |
| 67 | Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); |
| 68 | |
| 69 | Ogre::Light* light = mSceneManager->createLight("MainLight"); |
| 70 | light->setType(Ogre::Light::LT_DIRECTIONAL); |
| 71 | Ogre::Vector3 vec(-0.3f, -0.3f, -0.3f); |
nothing calls this directly
no test coverage detected