BaseManager::BaseManager() : mGUI(nullptr), mInfo(nullptr), mFocusInfo(nullptr), mRoot(nullptr), mCamera(nullptr), mSceneManager(nullptr), mWindow(nullptr), mExit(false), mReset(true), mFastReset(false), mPluginCfgName("plugins.cfg"), mResourceXMLName("resources.xml"), mResourceFileName("mygui/MyGUI_Core.xml"), mNode(nullptr), mCoutSource(nullptr), mFrameCount(0) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; mResourceXMLName = macBundlePath()+"/Contents/Resources/"+mResourceXMLName; #else mResourcePath = "../"; mResourceXMLName = mResourcePath + mResourceXMLName; #endif }
void GraphicsImpl::setupResources() { // Load resource paths from config file Ogre::ConfigFile cf; cf.load(resourcePath + "resources.cfg"); // Go through all sections & settings in the file Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE // OS X does not set the working directory relative to the app, // In order to make things portable on OS X we need to provide // the loading with it's own bundle path location Ogre::ResourceGroupManager::getSingleton().addResourceLocation( Ogre::String(macBundlePath() + "/" + archName), typeName, secName); #else Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); #endif } } }
void GraphicsManager::setupResources() { ConfigFile configFile; configFile.load(m_resourcePath + "resources.cfg"); ConfigFile::SectionIterator secItr = configFile.getSectionIterator(); String secName, typeName, archName; while (secItr.hasMoreElements()) { secName = secItr.peekNextKey(); ConfigFile::SettingsMultiMap *settings = secItr.getNext(); ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); #else ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); #endif } } }
void BaseManager::addResourceLocation(const std::string& _name, const std::string& _group, const std::string& _type, bool _recursive) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE // OS X does not set the working directory relative to the app, In order to make things portable on OS X we need to provide the loading with it's own bundle path location Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Ogre::String(macBundlePath() + "/" + _name), _type, _group, _recursive); #else Ogre::ResourceGroupManager::getSingleton().addResourceLocation(_name, _type, _group, _recursive); #endif }
OgreApp::OgreApp(){ mRoot = 0; // Provide a nice cross platform solution for locating the configuration files // On windows files are searched for in the current working directory, on OS X however // you must provide the full path, the helper function macBundlePath does this for us. #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; #else mResourcePath = "../Resources/"; #endif }
OgrePong::OgrePong() { mPongFrameListener = 0; mRoot = 0; // Provide a nice cross platform solution for locating the configuration files // On windows files are searched for in the current working directory, on OS X however // you must provide the full path, the helper function macBundlePath does this for us. // (Note: This is not fully tested under IOS) #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; #else mResourcePath = ""; #endif }
Shader::Shader(const std::string &vertexFile, const std::string &fragmentFile, bool fromBundle): mProgram(0) { // load vertex shader std::string fileName = (fromBundle) ? macBundlePath() + "/" + vertexFile : vertexFile; FILE* file = fopen(fileName.c_str(), "rb"); if(!file) { printf("Failed to load vertex shader"); return; } fseek(file, 0, SEEK_END); long size = ftell(file); rewind(file); mVertexSource.resize(size); fread(&mVertexSource[0], 1, size, file); fclose(file); // load fragment shader fileName = (fromBundle) ? macBundlePath() + "/" + fragmentFile : fragmentFile; file = fopen(fileName.c_str(), "rb"); if(!file) { printf("Failed to load fragment shader"); return; } fseek(file, 0, SEEK_END); size = ftell(file); rewind(file); mFragmentSource.resize(size); fread(&mFragmentSource[0], 1, size, file); fclose(file); }
GraphicsManager::GraphicsManager() { m_initialized = false; m_root = 0; m_sceneManager = 0; m_window = 0; m_debugOverlayFrameListener = 0; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE m_resourcePath = macBundlePath() + "/Contents/Resources/"; #else m_resourcePath = ""; #endif setMaxFrameTime(COAJNR_GRAPHICS_FRAME_TIME); }
BasisManager::BasisManager() : mInputManager(0), mMouse(0), mKeyboard(0), mRoot(0), mCamera(0), mSceneMgr(0), mWindow(0), m_exit(false) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; #else mResourcePath = ""; #endif }
DefaultCore::DefaultCore(const std::string &projectName, const std::string &resourceDir) { // Build our personal directory location. #if SYS_PLATFORM == PLATFORM_APPLE _personalDirectory = std::string(getenv("HOME")) + "/Library/Application Support/" + projectName + "/"; #else # error This is not implemented. #endif // Format and create the project settings directory. FileSystem::FormatPath(_personalDirectory); if (!FileSystem::CreateDirectory(_personalDirectory)) { THROW(InternalError, "Could not make directory: " << _personalDirectory); } // Create the window and add it as the primary target. _mainWindow = new Window(projectName); // Load our options from disk. _optionsModule = new OptionsModule(_personalDirectory); _optionsModule->registerListener("video", this); _optionsModule->load(); // Setup the event pump. _eventPump = new EventPump(_mainWindow); _eventPump->addWindowListener(this); _eventPump->addMouseButtonListener(this); _eventPump->addMouseMotionListener(this); _eventPump->addKeyListener(this); // And create our audio system (do this AFTER window creation, because of SDL). _audioSystem = new AudioSystem(); // Wait until the window has been created, which gives us our GL context, to // intitialize Content. Content::Initialize(); // Setup the default resource directory. std::string basicDir = resourceDir.size() > 0 ? resourceDir : #if SYS_PLATFORM == PLATFORM_APPLE macBundlePath() + "/Contents/Resources/"; #else # error This is not implemented. #endif FileSystem::ChangeDirectory(basicDir); Content::AddResourceDir(basicDir); }
void TerrainTests::setUp() { // set up silent logging to not pollute output if(LogManager::getSingletonPtr()) OGRE_DELETE Ogre::LogManager::getSingletonPtr(); if(LogManager::getSingletonPtr() == 0) { LogManager* logManager = OGRE_NEW LogManager(); logManager->createLog("testTerrain.log", true, false); } LogManager::getSingleton().setLogDetail(LL_LOW); mRoot = OGRE_NEW Root(); mTerrainOpts = OGRE_NEW TerrainGlobalOptions(); // Load resource paths from config file ConfigFile cf; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); #else cf.load("resources.cfg"); #endif // Go through all sections & settings in the file ConfigFile::SectionIterator seci = cf.getSectionIterator(); String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); ConfigFile::SettingsMultiMap *settings = seci.getNext(); ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); } } mSceneMgr = mRoot->createSceneManager(ST_GENERIC); }
BaseManager::BaseManager() : mGUI(nullptr), mPlatform(nullptr), mInfo(nullptr), mFocusInfo(nullptr), mRoot(nullptr), mCamera(nullptr), mSceneManager(nullptr), mWindow(nullptr), mExit(false), mPluginCfgName("plugins.cfg"), mResourceXMLName("resources.xml"), mResourceFileName("MyGUI_Core.xml"), mNode(nullptr) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; #else mResourcePath = ""; #endif }
BaseManager::BaseManager() : mGUI(nullptr), mPlatform(nullptr), mRoot(nullptr), mCamera(nullptr), mSceneManager(nullptr), mWindow(nullptr), mExit(false), #ifdef _DEBUG // Gauss 27.10.2014 mPluginCfgName("plugins_d.cfg"), #else mPluginCfgName("plugins.cfg"), #endif mResourceXMLName("ResourcesBaseManager.xml"), mResourceFileName("MyGUI_Core.xml") { #if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE mResourcePath = macBundlePath() + "/Contents/Resources/"; #else mResourcePath = ""; #endif }
path_t locate_bin_directory(const logger* log, bool verbose) { // locate the binary and build its path #if KZH_PLATFORM == KZH_PLATFORM_LINUX // use binreloc and fs to build up our paths int brres = br_init(0); if (brres == 0) { if (verbose) { log->error() << "binreloc could not be initialised"; } throw std::runtime_error("Unable to resolve paths! binreloc could not be initialized"); } char *tmp_bin_path = br_find_exe_dir("."); path_t bin_path = path_t(tmp_bin_path).make_preferred(); free(tmp_bin_path); br_free(); return bin_path; #elif KZH_PLATFORM == KZH_PLATFORM_APPLE // use NSBundlePath() to build up our paths // return path_t(macBundlePath() + "/Contents/MacOS").make_preferred(); return path_t(macBundlePath()).make_preferred(); #else // Windows // use GetModuleFileName() and fs to build up our paths on Windows TCHAR szPath[MAX_PATH]; if (!GetModuleFileName(NULL, szPath, MAX_PATH)) { if (verbose) { log->error() << "Unable to resolve path: " << GetLastError();; } throw std::runtime_error("Unable to resolve paths! GetModuleFileName() failed. See the log for the error."); } return path_t(string_t(szPath)).remove_filename().make_preferred(); #endif }
std::string macPluginPath() { return macBundlePath() + "/Contents/Plugins/"; }