[Orxonox-commit 3545] r8231 - in code/branches/kicklib/src: . libraries/core

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Apr 11 06:39:04 CEST 2011


Author: rgrieder
Date: 2011-04-11 06:39:04 +0200 (Mon, 11 Apr 2011)
New Revision: 8231

Modified:
   code/branches/kicklib/src/SpecialConfig.h.in
   code/branches/kicklib/src/libraries/core/GraphicsManager.cc
   code/branches/kicklib/src/libraries/core/GraphicsManager.h
Log:
Attempt to fix Ogre plugins for Orxonox installations on Windows.

Modified: code/branches/kicklib/src/SpecialConfig.h.in
===================================================================
--- code/branches/kicklib/src/SpecialConfig.h.in	2011-04-11 01:37:14 UTC (rev 8230)
+++ code/branches/kicklib/src/SpecialConfig.h.in	2011-04-11 04:39:04 UTC (rev 8231)
@@ -91,30 +91,12 @@
     const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";
 
     // OGRE PLUGINS
-    // Apple has trouble finding OGRE plugins because of its install-name convention
-    // Adopting the executable_path structure for later use in app bundles
 #ifdef NDEBUG
     const char ogrePlugins[] = "@OGRE_PLUGINS_RELEASE@";
-#  ifdef DEPENDENCY_PACKAGE_ENABLE
-#    ifdef ORXONOX_PLATFORM_APPLE
-       const char ogrePluginsDirectory[] = "@executable_path/../Plugins";
-#    else
-       const char ogrePluginsDirectory[] = ".";
-#    endif
-#  else
     const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_RELEASE@";
-#  endif
 #else
     const char ogrePlugins[] = "@OGRE_PLUGINS_DEBUG@";
-#  ifdef DEPENDENCY_PACKAGE_ENABLE
-#    ifdef ORXONOX_PLATFORM_APPLE
-       const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";
-#    else
-       const char ogrePluginsDirectory[] = ".";
-#    endif
-#  else
     const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";
-#  endif
 #endif
 } }
 

Modified: code/branches/kicklib/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/kicklib/src/libraries/core/GraphicsManager.cc	2011-04-11 01:37:14 UTC (rev 8230)
+++ code/branches/kicklib/src/libraries/core/GraphicsManager.cc	2011-04-11 04:39:04 UTC (rev 8231)
@@ -29,6 +29,7 @@
 
 #include "GraphicsManager.h"
 
+#include <cstdlib>
 #include <fstream>
 #include <sstream>
 #include <boost/filesystem.hpp>
@@ -60,13 +61,6 @@
 #include "XMLFile.h"
 #include "command/ConsoleCommand.h"
 
-// Differentiate Boost Filesystem v2 and v3
-#if (BOOST_FILESYSTEM_VERSION < 3)
-#  define BF_NATIVE_STRING file_string
-#else
-#  define BF_NATIVE_STRING string
-#endif
-
 namespace orxonox
 {
     static const std::string __CC_printScreen_name = "printScreen";
@@ -147,8 +141,6 @@
     {
         SetConfigValue(ogreConfigFile_,  "ogre.cfg")
             .description("Location of the Ogre config file");
-        SetConfigValue(ogrePluginsDirectory_, specialConfig::ogrePluginsDirectory)
-            .description("Folder where the Ogre plugins are located.");
         SetConfigValue(ogrePlugins_, specialConfig::ogrePlugins)
             .description("Comma separated list of all plugins to load.");
         SetConfigValue(ogreLogFile_,     "ogre.log")
@@ -240,16 +232,29 @@
 
     void GraphicsManager::loadOgrePlugins()
     {
-        // just to make sure the next statement doesn't segfault
-        if (ogrePluginsDirectory_.empty())
-            ogrePluginsDirectory_ = '.';
+        // Plugin path can have many different locations...
+        std::string pluginPath = specialConfig::ogrePluginsDirectory;
+#ifdef DEPENDENCY_PACKAGE_ENABLE
+        if (!PathConfig::isDevelopmentRun())
+        {
+#  if defined(ORXONOX_PLATFORM_WINDOWS)
+            pluginPath = PathConfig::getExecutablePathString();
+#  elif defined(ORXONOX_PLATFORM_APPLE)
+            // TODO: Where are the plugins being installed to?
+            pluginPath = PathConfig::getExecutablePathString();
+#  endif
+        }
+#endif
 
-        boost::filesystem::path folder(ogrePluginsDirectory_);
+        // Add OGRE plugin path to the environment. That way one plugin could
+        // also depend on another without problems on Windows
+        std::string pathVariable(getenv("PATH"));
+        putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + pluginPath).c_str()));
+
         // Do some SubString magic to get the comma separated list of plugins
         SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, '{', '}', false, '\0');
-        // Use backslash paths on Windows! file_string() already does that though.
         for (unsigned int i = 0; i < plugins.size(); ++i)
-            ogreRoot_->loadPlugin((folder / plugins[i]).BF_NATIVE_STRING());
+            ogreRoot_->loadPlugin(plugins[i]);
     }
 
     void GraphicsManager::loadRenderer()

Modified: code/branches/kicklib/src/libraries/core/GraphicsManager.h
===================================================================
--- code/branches/kicklib/src/libraries/core/GraphicsManager.h	2011-04-11 01:37:14 UTC (rev 8230)
+++ code/branches/kicklib/src/libraries/core/GraphicsManager.h	2011-04-11 04:39:04 UTC (rev 8231)
@@ -109,7 +109,6 @@
 
         // config values
         std::string         ogreConfigFile_;           //!< ogre config filename
-        std::string         ogrePluginsDirectory_;     //!< Directory where the Ogre plugins are located
         std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
         std::string         ogreLogFile_;              //!< log filename for Ogre log messages
         int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonox debug level for LL_TRIVIAL




More information about the Orxonox-commit mailing list