diff --git a/CMakeLists.txt b/CMakeLists.txt index 05c53e6d6..0bc6344c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,9 @@ option(USE_FFMPEG "use ffmpeg for sound" OFF) option(USE_AUDIERE "use audiere for sound" OFF) option(USE_MPG123 "use mpg123 + libsndfile for sound" ON) +# OS X deployment +option(OPENMW_OSX_DEPLOYMENT OFF) + find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") # Location of morrowind data files @@ -241,12 +244,8 @@ if (APPLE) else () set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) endif () - - set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") - -# set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR}) -# set(OGRE_PLUGIN_DIR "") -# set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2}) + + #set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist "${APP_BUNDLE_DIR}/Contents/Info.plist") @@ -270,7 +269,11 @@ if (DEFINED CMAKE_BUILD_TYPE) endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}") -add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") +if (APPLE AND OPENMW_OSX_DEPLOYMENT) + add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins") +else() + add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") +endif() add_subdirectory(files/) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 296ef2c3e..f9f5c6dda 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "graphicspage.hpp" #include "naturalsort.hpp" @@ -115,17 +116,13 @@ bool GraphicsPage::setupOgre() #endif } - std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(glPlugin + ".so") || - boost::filesystem::exists(glPlugin + ".dll") || - boost::filesystem::exists(glPlugin + ".dylib")) - mOgre->loadPlugin (glPlugin); - - std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(dxPlugin + ".so") || - boost::filesystem::exists(dxPlugin + ".dll") || - boost::filesystem::exists(dxPlugin + ".dylib")) - mOgre->loadPlugin (dxPlugin); + boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir)); + + pluginDir = absPluginPath.string(); + + loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); + loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre); + loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); #ifdef ENABLE_PLUGIN_GL mGLPlugin = new Ogre::GLPlugin(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index efeb69cae..e16a860c4 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -66,6 +66,10 @@ add_component_dir (interpreter miscopcodes opcodes runtime scriptopcodes spatialopcodes types ) +add_component_dir (ogreplugin + ogreplugin +) + include_directories(${BULLET_INCLUDE_DIRS}) add_library(components STATIC ${COMPONENT_FILES}) diff --git a/components/ogreplugin/ogreplugin.cpp b/components/ogreplugin/ogreplugin.cpp new file mode 100644 index 000000000..5516482aa --- /dev/null +++ b/components/ogreplugin/ogreplugin.cpp @@ -0,0 +1,37 @@ +#include "ogreplugin.h" + +#include +#include + +#include + +bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + std::ostringstream verStream; + verStream << "." << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH; + pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX + verStream.str(); +#endif + + std::string pluginExt; +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + pluginExt = ".dll"; +#endif +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + pluginExt = ".dylib"; +#endif +#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX + pluginExt = ".so"; +#endif + + std::string pluginPath = pluginDir + "/" + pluginName + pluginExt; + + std::cout << "loading plugin: " << pluginPath << std::endl; + + if (boost::filesystem::exists(pluginPath)) { + ogreRoot.loadPlugin(pluginPath); + return true; + } + else { + return false; + } +} \ No newline at end of file diff --git a/components/ogreplugin/ogreplugin.h b/components/ogreplugin/ogreplugin.h new file mode 100644 index 000000000..bb1ea04e1 --- /dev/null +++ b/components/ogreplugin/ogreplugin.h @@ -0,0 +1,12 @@ +#ifndef OGREPLUGIN_H +#define OGREPLUGIN_H + +#include + +namespace Ogre { + class Root; +} + +extern bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot); + +#endif \ No newline at end of file diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 58b363f7f..20bb1f40f 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -11,6 +11,8 @@ #include +#include + #include #include #include @@ -94,6 +96,7 @@ void OgreRenderer::configure(const std::string &logPath, loadPlugins(); #endif + std::cout << "current path is: " << boost::filesystem::current_path() << std::endl; std::string pluginDir; const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR"); if (pluginEnv) @@ -111,23 +114,13 @@ void OgreRenderer::configure(const std::string &logPath, #endif } - std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(glPlugin + ".so") || - boost::filesystem::exists(glPlugin + ".dll") || - boost::filesystem::exists(glPlugin + ".dylib")) - mRoot->loadPlugin (glPlugin); - - std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(dxPlugin + ".so") || - boost::filesystem::exists(dxPlugin + ".dll") || - boost::filesystem::exists(dxPlugin + ".dylib")) - mRoot->loadPlugin (dxPlugin); - - std::string cgPlugin = std::string(pluginDir) + "/Plugin_CgProgramManager" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(cgPlugin + ".so") || - boost::filesystem::exists(cgPlugin + ".dll") || - boost::filesystem::exists(cgPlugin + ".dylib")) - mRoot->loadPlugin (cgPlugin); + boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir)); + + pluginDir = absPluginPath.string(); + + loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot); + loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot); + loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); if (rs == 0)