From b7eb7ff8e3d3bdafb500346117db13a907e00646 Mon Sep 17 00:00:00 2001 From: k1ll Date: Thu, 15 Mar 2012 15:51:39 +0100 Subject: [PATCH 1/4] Added support for linking static Ogre libraries and plugins into the launcher and openmw. --- CMakeLists.txt | 10 +++- apps/launcher/CMakeLists.txt | 10 ++++ apps/launcher/graphicspage.cpp | 13 +++++ apps/launcher/graphicspage.hpp | 14 ++++++ apps/openmw/CMakeLists.txt | 10 ++++ cmake/FindOGRE.cmake | 84 +++++++++++++++---------------- libs/openengine/ogre/renderer.cpp | 34 +++++++++++++ libs/openengine/ogre/renderer.hpp | 40 +++++++++++++++ 8 files changed, 172 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9c60e554..bfa6dd8b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,8 +189,16 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) find_package(OpenAL REQUIRED) find_package(Bullet REQUIRED) +IF(OGRE_STATIC) +find_package(Cg REQUIRED) +IF(WIN32) +set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS}) +ELSE(WIN32) +set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) include_directories("." - ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE + ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_PLUGIN_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR} ${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index a34ad7429..fd736e011 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -53,6 +53,15 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) include(${QT_USE_FILE}) # Main executable +IF(OGRE_STATIC) +IF(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ELSE(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_GL_LIBRARIES}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) add_executable(omwlauncher ${GUI_TYPE} ${LAUNCHER} @@ -63,6 +72,7 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} components ) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index b7d397f06..95b38d53e 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -186,7 +186,11 @@ void GraphicsPage::setupOgre() try { + #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) + mOgre = new Ogre::Root("", file.fileName().toStdString(), "./launcherOgre.log"); + #else mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log"); + #endif } catch(Ogre::Exception &ex) { @@ -207,6 +211,15 @@ void GraphicsPage::setupOgre() return; } + #ifdef ENABLE_PLUGIN_GL + mGLPlugin = new Ogre::GLPlugin(); + mOgre->installPlugin(mGLPlugin); + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + mD3D9Plugin = new Ogre::D3D9Plugin(); + mOgre->installPlugin(mD3D9Plugin); + #endif + // Get the available renderers and put them in the combobox const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers(); diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index bdfd4f038..6a91a0628 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -8,6 +8,14 @@ #include #include +// Static plugin headers +#ifdef ENABLE_PLUGIN_GL +# include "OgreGLPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_Direct3D9 +# include "OgreD3D9Plugin.h" +#endif + class QComboBox; class QCheckBox; class QStackedWidget; @@ -32,6 +40,12 @@ private: Ogre::RenderSystem *mSelectedRenderSystem; Ogre::RenderSystem *mOpenGLRenderSystem; Ogre::RenderSystem *mDirect3DRenderSystem; + #ifdef ENABLE_PLUGIN_GL + Ogre::GLPlugin* mGLPlugin; + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + Ogre::D3D9Plugin* mD3D9Plugin; + #endif QComboBox *mRendererComboBox; diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 77f465b4c..6d33298df 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -57,6 +57,15 @@ add_openmw_dir (mwmechanics ) # Main executable +IF(OGRE_STATIC) +IF(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ELSE(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) add_executable(openmw ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${COMPONENT_FILES} @@ -72,6 +81,7 @@ add_definitions(${SOUND_DEFINE}) target_link_libraries(openmw ${OGRE_LIBRARIES} + ${OGRE_STATIC_PLUGINS} ${OIS_LIBRARIES} ${Boost_LIBRARIES} ${OPENAL_LIBRARY} diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 917a8653e..fd292ddeb 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -18,7 +18,7 @@ # Once done, this will define # # OGRE_FOUND - system has OGRE -# OGRE_INCLUDE_DIRS - the OGRE include directories +# OGRE_INCLUDE_DIRS - the OGRE include directories # OGRE_LIBRARIES - link these to use the OGRE core # OGRE_BINARY_REL - location of the main Ogre binary (win32 non-static only, release) # OGRE_BINARY_DBG - location of the main Ogre binaries (win32 non-static only, debug) @@ -28,15 +28,14 @@ # Plugin_BSPSceneManager, Plugin_CgProgramManager, # Plugin_OctreeSceneManager, Plugin_OctreeZone, # Plugin_ParticleFX, Plugin_PCZSceneManager, -# RenderSystem_GL, RenderSystem_Direct3D9, +# RenderSystem_GL, RenderSystem_Direct3D9, RenderSystem_Direct3D10, # Paging, Terrain # # For each of these components, the following variables are defined: # - # OGRE_${COMPONENT}_FOUND - ${COMPONENT} is available # OGRE_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT} -# OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} +# OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} # OGRE_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release) # OGRE_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug) # @@ -113,7 +112,7 @@ if (OGRE_PREFIX_SOURCE AND OGRE_PREFIX_BUILD) set(OGRE_BIN_SEARCH_PATH ${dir}/bin ${OGRE_BIN_SEARCH_PATH}) set(OGRE_BIN_SEARCH_PATH ${dir}/Samples/Common/bin ${OGRE_BIN_SEARCH_PATH}) endforeach(dir) - + if (OGRE_PREFIX_DEPENDENCIES_DIR) set(OGRE_INC_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/include ${OGRE_INC_SEARCH_PATH}) set(OGRE_LIB_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/lib ${OGRE_LIB_SEARCH_PATH}) @@ -125,12 +124,12 @@ else() endif () # redo search if any of the environmental hints changed -set(OGRE_COMPONENTS Paging Terrain +set(OGRE_COMPONENTS Paging Terrain Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX - RenderSystem_Direct3D11 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES RenderSystem_GLES2) -set(OGRE_RESET_VARS - OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR + RenderSystem_Direct3D10 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES) +set(OGRE_RESET_VARS + OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR) foreach (comp ${OGRE_COMPONENTS}) @@ -145,7 +144,7 @@ clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS}) # try to locate Ogre via pkg-config use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}") -if(NOT OGRE_BUILD_PLATFORM_APPLE_IOS) +if(NOT OGRE_BUILD_PLATFORM_IPHONE) # try to find framework on OSX findpkg_framework(OGRE) else() @@ -236,7 +235,6 @@ if (OGRE_STATIC) find_package(Freetype QUIET) find_package(OpenGL QUIET) find_package(OpenGLES QUIET) - find_package(OpenGLES2 QUIET) find_package(ZLIB QUIET) find_package(ZZip QUIET) if (UNIX AND NOT APPLE) @@ -246,26 +244,28 @@ if (OGRE_STATIC) set(X11_FOUND FALSE) endif () endif () - if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) + if (APPLE AND NOT OGRE_BUILD_PLATFORM_IPHONE) find_package(Cocoa QUIET) find_package(Carbon QUIET) - find_package(CoreVideo QUIET) - if (NOT Cocoa_FOUND OR NOT Carbon_FOUND OR NOT CoreVideo_FOUND) + if (NOT Cocoa_FOUND OR NOT Carbon_FOUND) set(OGRE_DEPS_FOUND FALSE) endif () endif () - if (APPLE AND OGRE_BUILD_PLATFORM_APPLE_IOS) + if (APPLE AND OGRE_BUILD_PLATFORM_IPHONE) find_package(iPhoneSDK QUIET) if (NOT iPhoneSDK_FOUND) set(OGRE_DEPS_FOUND FALSE) endif () endif () - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} ) - - if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} ${Carbon_LIBRARIES} ${Cocoa_LIBRARIES}) - endif() + #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} + # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} + # ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) + set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} + ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} + ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) if (NOT ZLIB_FOUND OR NOT ZZip_FOUND) set(OGRE_DEPS_FOUND FALSE) @@ -309,7 +309,7 @@ if (OGRE_STATIC) endif () endif () endif () - + if (NOT OGRE_DEPS_FOUND) pkg_message(OGRE "Could not find all required dependencies for the Ogre package.") set(OGRE_FOUND FALSE) @@ -341,7 +341,7 @@ endif() # Find Ogre components ######################################################### -set(OGRE_COMPONENT_SEARCH_PATH_REL +set(OGRE_COMPONENT_SEARCH_PATH_REL ${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_BIN_SEARCH_PATH} @@ -393,17 +393,17 @@ macro(ogre_find_plugin PLUGIN HEADER) set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES}) set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") endif() - + # strip RenderSystem_ or Plugin_ prefix from plugin name string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN}) string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP}) - + # header files for plugins are not usually needed, but find them anyway if they are present set(OGRE_PLUGIN_PATH_SUFFIXES - PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} + PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN}) - find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} - HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} + find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} + HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} PATH_SUFFIXES ${OGRE_PLUGIN_PATH_SUFFIXES}) # find link libraries for plugins set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") @@ -429,7 +429,7 @@ macro(ogre_find_plugin PLUGIN HEADER) if (OGRE_${PLUGIN}_FOUND) if (NOT OGRE_PLUGIN_DIR_REL OR NOT OGRE_PLUGIN_DIR_DBG) if (WIN32) - set(OGRE_PLUGIN_SEARCH_PATH_REL + set(OGRE_PLUGIN_SEARCH_PATH_REL ${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_BIN_SEARCH_PATH} @@ -445,12 +445,12 @@ macro(ogre_find_plugin PLUGIN HEADER) PATH_SUFFIXES "" bin bin/debug debug) elseif (UNIX) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH) - set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)" FORCE) + set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH) - set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)" FORCE) + set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") endif () endif () - + # find binaries if (NOT OGRE_STATIC) if (WIN32) @@ -459,7 +459,7 @@ macro(ogre_find_plugin PLUGIN HEADER) endif() mark_as_advanced(OGRE_${PLUGIN}_REL OGRE_${PLUGIN}_DBG) endif() - + endif () if (TMP_CMAKE_LIB_PREFIX) @@ -475,8 +475,8 @@ ogre_find_plugin(Plugin_OctreeSceneManager OgreOctreeSceneManager.h PlugIns/Octr ogre_find_plugin(Plugin_ParticleFX OgreParticleFXPrerequisites.h PlugIns/ParticleFX/include) ogre_find_plugin(RenderSystem_GL OgreGLRenderSystem.h RenderSystems/GL/include) ogre_find_plugin(RenderSystem_GLES OgreGLESRenderSystem.h RenderSystems/GLES/include) -ogre_find_plugin(RenderSystem_GLES2 OgreGLES2RenderSystem.h RenderSystems/GLES2/include) ogre_find_plugin(RenderSystem_Direct3D9 OgreD3D9RenderSystem.h RenderSystems/Direct3D9/include) +ogre_find_plugin(RenderSystem_Direct3D10 OgreD3D10RenderSystem.h RenderSystems/Direct3D10/include) ogre_find_plugin(RenderSystem_Direct3D11 OgreD3D11RenderSystem.h RenderSystems/Direct3D11/include) if (OGRE_STATIC) @@ -484,26 +484,28 @@ if (OGRE_STATIC) if (NOT DirectX_FOUND) set(OGRE_RenderSystem_Direct3D9_FOUND FALSE) endif () + if (NOT DirectX_D3D10_FOUND) + set(OGRE_RenderSystem_Direct3D10_FOUND FALSE) + endif () if (NOT DirectX_D3D11_FOUND) set(OGRE_RenderSystem_Direct3D11_FOUND FALSE) endif () if (NOT OPENGL_FOUND) set(OGRE_RenderSystem_GL_FOUND FALSE) endif () - if (NOT OPENGLES_FOUND) + if (NOT OPENGLES_FOUND AND NOT OPENGLES2_FOUND) set(OGRE_RenderSystem_GLES_FOUND FALSE) endif () - if (NOT OPENGLES2_FOUND) - set(OGRE_RenderSystem_GLES2_FOUND FALSE) - endif () if (NOT Cg_FOUND) set(OGRE_Plugin_CgProgramManager_FOUND FALSE) endif () - + set(OGRE_RenderSystem_Direct3D9_LIBRARIES ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${DirectX_LIBRARIES} ) - + set(OGRE_RenderSystem_Direct3D10_LIBRARIES ${OGRE_RenderSystem_Direct3D10_LIBRARIES} + ${DirectX_D3D10_LIBRARIES} + ) set(OGRE_RenderSystem_Direct3D11_LIBRARIES ${OGRE_RenderSystem_Direct3D11_LIBRARIES} ${DirectX_D3D11_LIBRARIES} ) @@ -513,9 +515,6 @@ if (OGRE_STATIC) set(OGRE_RenderSystem_GLES_LIBRARIES ${OGRE_RenderSystem_GLES_LIBRARIES} ${OPENGLES_LIBRARIES} ) - set(OGRE_RenderSystem_GLES2_LIBRARIES ${OGRE_RenderSystem_GLES2_LIBRARIES} - ${OPENGLES2_LIBRARIES} - ) set(OGRE_Plugin_CgProgramManager_LIBRARIES ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ) @@ -540,3 +539,4 @@ set(OGRE_MEDIA_SEARCH_SUFFIX clear_if_changed(OGRE_PREFIX_WATCH OGRE_MEDIA_DIR) find_path(OGRE_MEDIA_DIR NAMES packs/cubemapsJS.zip HINTS ${OGRE_MEDIA_SEARCH_PATH} PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX}) + diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index ecded08d8..f2a23c831 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -26,6 +26,35 @@ void OgreRenderer::start() mRoot->startRendering(); } +bool OgreRenderer::loadPlugins() +{ + #ifdef ENABLE_PLUGIN_GL + mGLPlugin = new Ogre::GLPlugin(); + mRoot->installPlugin(mGLPlugin); + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + mD3D9Plugin = new Ogre::D3D9Plugin(); + mRoot->installPlugin(mD3D9Plugin); + #endif + #ifdef ENABLE_PLUGIN_CgProgramManager + mCgPlugin = new Ogre::CgPlugin(); + mRoot->installPlugin(mCgPlugin); + #endif + #ifdef ENABLE_PLUGIN_OctreeSceneManager + mOctreePlugin = new Ogre::OctreePlugin(); + mRoot->installPlugin(mOctreePlugin); + #endif + #ifdef ENABLE_PLUGIN_ParticleFX + mParticleFXPlugin = new Ogre::ParticleFXPlugin(); + mRoot->installPlugin(mParticleFXPlugin); + #endif + #ifdef ENABLE_PLUGIN_BSPSceneManager + mBSPPlugin = new Ogre::BspSceneManagerPlugin(); + mRoot->installPlugin(mBSPPlugin); + #endif + return true; +} + void OgreRenderer::update(float dt) { mFader->update(dt); @@ -59,7 +88,12 @@ bool OgreRenderer::configure(bool showConfig, // Disable logging log->setDebugOutputEnabled(false); +#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) || defined(ENABLE_PLUGIN_BSPSceneManager) + mRoot = new Root("", cfgPath, ""); + loadPlugins(); +#else mRoot = new Root(pluginCfg, cfgPath, ""); +#endif // Show the configuration dialog and initialise the system, if the // showConfig parameter is specified. The settings are stored in diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index f48383cbc..fa7435501 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -7,6 +7,26 @@ #include +// Static plugin headers +#ifdef ENABLE_PLUGIN_CgProgramManager +# include "OgreCgPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_OctreeSceneManager +# include "OgreOctreePlugin.h" +#endif +#ifdef ENABLE_PLUGIN_ParticleFX +# include "OgreParticleFXPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_BSPSceneManager +# include "OgreBspSceneManagerPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_GL +# include "OgreGLPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_Direct3D9 +# include "OgreD3D9Plugin.h" +#endif + namespace Ogre { class Root; @@ -27,6 +47,24 @@ namespace Render Ogre::SceneManager *mScene; Ogre::Camera *mCamera; Ogre::Viewport *mView; + #ifdef ENABLE_PLUGIN_CgProgramManager + Ogre::CgPlugin* mCgPlugin; + #endif + #ifdef ENABLE_PLUGIN_OctreeSceneManager + Ogre::OctreePlugin* mOctreePlugin; + #endif + #ifdef ENABLE_PLUGIN_ParticleFX + Ogre::ParticleFXPlugin* mParticleFXPlugin; + #endif + #ifdef ENABLE_PLUGIN_BSPSceneManager + Ogre::BspSceneManagerPlugin* mBSPPlugin; + #endif + #ifdef ENABLE_PLUGIN_GL + Ogre::GLPlugin* mGLPlugin; + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + Ogre::D3D9Plugin* mD3D9Plugin; + #endif Fader* mFader; bool logging; @@ -68,6 +106,8 @@ namespace Render /// Start the main rendering loop void start(); + + bool loadPlugins(); void update(float dt); From c5bbbee9c1ffaa0c956335fd682f5bb88d8d72e4 Mon Sep 17 00:00:00 2001 From: k1ll Date: Thu, 15 Mar 2012 21:37:55 +0100 Subject: [PATCH 2/4] Added needed cmake files and added a comment to clarify the changes in FindOgre.cmake --- cmake/FindCg.cmake | 53 +++++++++++++++++++++++++++++++++++++++ cmake/FindFreeImage.cmake | 47 ++++++++++++++++++++++++++++++++++ cmake/FindOGRE.cmake | 1 + cmake/FindZZip.cmake | 48 +++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 cmake/FindCg.cmake create mode 100644 cmake/FindFreeImage.cmake create mode 100644 cmake/FindZZip.cmake diff --git a/cmake/FindCg.cmake b/cmake/FindCg.cmake new file mode 100644 index 000000000..4bd348c46 --- /dev/null +++ b/cmake/FindCg.cmake @@ -0,0 +1,53 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find Cg +# Once done, this will define +# +# Cg_FOUND - system has Cg +# Cg_INCLUDE_DIRS - the Cg include directories +# Cg_LIBRARIES - link these to use Cg + +include(FindPkgMacros) +findpkg_begin(Cg) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(Cg_HOME) +getenv_path(OGRE_SOURCE) +getenv_path(OGRE_HOME) + +# construct search paths +set(Cg_PREFIX_PATH ${Cg_HOME} ${ENV_Cg_HOME} + ${OGRE_SOURCE}/Dependencies + ${ENV_OGRE_SOURCE}/Dependencies + ${OGRE_HOME} ${ENV_OGRE_HOME} + /opt/nvidia-cg-toolkit) +create_search_paths(Cg) +# redo search if prefix path changed +clear_if_changed(Cg_PREFIX_PATH + Cg_LIBRARY_FWK + Cg_LIBRARY_REL + Cg_LIBRARY_DBG + Cg_INCLUDE_DIR +) + +set(Cg_LIBRARY_NAMES Cg) +get_debug_names(Cg_LIBRARY_NAMES) + +use_pkgconfig(Cg_PKGC Cg) + +findpkg_framework(Cg) + +find_path(Cg_INCLUDE_DIR NAMES cg.h HINTS ${Cg_FRAMEWORK_INCLUDES} ${Cg_INC_SEARCH_PATH} ${Cg_PKGC_INCLUDE_DIRS} PATH_SUFFIXES Cg) +find_library(Cg_LIBRARY_REL NAMES ${Cg_LIBRARY_NAMES} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(Cg_LIBRARY_DBG NAMES ${Cg_LIBRARY_NAMES_DBG} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(Cg_LIBRARY) + +findpkg_finish(Cg) +add_parent_dir(Cg_INCLUDE_DIRS Cg_INCLUDE_DIR) diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake new file mode 100644 index 000000000..3b21a17d6 --- /dev/null +++ b/cmake/FindFreeImage.cmake @@ -0,0 +1,47 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find FreeImage +# Once done, this will define +# +# FreeImage_FOUND - system has FreeImage +# FreeImage_INCLUDE_DIRS - the FreeImage include directories +# FreeImage_LIBRARIES - link these to use FreeImage + +include(FindPkgMacros) +findpkg_begin(FreeImage) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(FREEIMAGE_HOME) + +# construct search paths +set(FreeImage_PREFIX_PATH ${FREEIMAGE_HOME} ${ENV_FREEIMAGE_HOME}) +create_search_paths(FreeImage) +# redo search if prefix path changed +clear_if_changed(FreeImage_PREFIX_PATH + FreeImage_LIBRARY_FWK + FreeImage_LIBRARY_REL + FreeImage_LIBRARY_DBG + FreeImage_INCLUDE_DIR +) + +set(FreeImage_LIBRARY_NAMES freeimage) +get_debug_names(FreeImage_LIBRARY_NAMES) + +use_pkgconfig(FreeImage_PKGC freeimage) + +findpkg_framework(FreeImage) + +find_path(FreeImage_INCLUDE_DIR NAMES FreeImage.h HINTS ${FreeImage_INC_SEARCH_PATH} ${FreeImage_PKGC_INCLUDE_DIRS}) +find_library(FreeImage_LIBRARY_REL NAMES ${FreeImage_LIBRARY_NAMES} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(FreeImage_LIBRARY_DBG NAMES ${FreeImage_LIBRARY_NAMES_DBG} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(FreeImage_LIBRARY) + +findpkg_finish(FreeImage) + diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index fd292ddeb..2c07a4d55 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -258,6 +258,7 @@ if (OGRE_STATIC) endif () endif () + #Removed FWK because it normally is unnecessary and would break the build when not available #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} diff --git a/cmake/FindZZip.cmake b/cmake/FindZZip.cmake new file mode 100644 index 000000000..68fe043f3 --- /dev/null +++ b/cmake/FindZZip.cmake @@ -0,0 +1,48 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find zziplib +# Once done, this will define +# +# ZZip_FOUND - system has ZZip +# ZZip_INCLUDE_DIRS - the ZZip include directories +# ZZip_LIBRARIES - link these to use ZZip + +include(FindPkgMacros) +findpkg_begin(ZZip) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(ZZIP_HOME) + + +# construct search paths +set(ZZip_PREFIX_PATH ${ZZIP_HOME} ${ENV_ZZIP_HOME}) +create_search_paths(ZZip) +# redo search if prefix path changed +clear_if_changed(ZZip_PREFIX_PATH + ZZip_LIBRARY_FWK + ZZip_LIBRARY_REL + ZZip_LIBRARY_DBG + ZZip_INCLUDE_DIR +) + +set(ZZip_LIBRARY_NAMES zzip zziplib) +get_debug_names(ZZip_LIBRARY_NAMES) + +use_pkgconfig(ZZip_PKGC zziplib) + +findpkg_framework(ZZip) + +find_path(ZZip_INCLUDE_DIR NAMES zzip/zzip.h HINTS ${ZZip_INC_SEARCH_PATH} ${ZZip_PKGC_INCLUDE_DIRS}) +find_library(ZZip_LIBRARY_REL NAMES ${ZZip_LIBRARY_NAMES} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(ZZip_LIBRARY_DBG NAMES ${ZZip_LIBRARY_NAMES_DBG} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(ZZip_LIBRARY) + +findpkg_finish(ZZip) + From 7d81422c2753353b5c913aacd6787a054fbb1c84 Mon Sep 17 00:00:00 2001 From: k1ll Date: Fri, 16 Mar 2012 19:17:10 +0100 Subject: [PATCH 3/4] Better fix for the Framework problem. --- cmake/FindOGRE.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 2c07a4d55..78d0ef24e 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -144,7 +144,7 @@ clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS}) # try to locate Ogre via pkg-config use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}") -if(NOT OGRE_BUILD_PLATFORM_IPHONE) +if(NOT OGRE_BUILD_PLATFORM_IPHONE AND APPLE) # try to find framework on OSX findpkg_framework(OGRE) else() @@ -258,12 +258,7 @@ if (OGRE_STATIC) endif () endif () - #Removed FWK because it normally is unnecessary and would break the build when not available - #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} - # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} - # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} - # ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) From b83b7d0650cdd77a8da0568cd70c4ed4de64470a Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 17 Mar 2012 20:03:37 +0100 Subject: [PATCH 4/4] Added OGRE_STATIC as cmake option and removed the code for the BSPSceneManager plugin. --- CMakeLists.txt | 2 ++ libs/openengine/ogre/renderer.cpp | 6 +----- libs/openengine/ogre/renderer.hpp | 6 ------ 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfa6dd8b0..e5256aa7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VE configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") +option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE) + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index f2a23c831..4ded3343f 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -48,10 +48,6 @@ bool OgreRenderer::loadPlugins() mParticleFXPlugin = new Ogre::ParticleFXPlugin(); mRoot->installPlugin(mParticleFXPlugin); #endif - #ifdef ENABLE_PLUGIN_BSPSceneManager - mBSPPlugin = new Ogre::BspSceneManagerPlugin(); - mRoot->installPlugin(mBSPPlugin); - #endif return true; } @@ -88,7 +84,7 @@ bool OgreRenderer::configure(bool showConfig, // Disable logging log->setDebugOutputEnabled(false); -#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) || defined(ENABLE_PLUGIN_BSPSceneManager) +#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) mRoot = new Root("", cfgPath, ""); loadPlugins(); #else diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index fa7435501..6516b0a80 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -17,9 +17,6 @@ #ifdef ENABLE_PLUGIN_ParticleFX # include "OgreParticleFXPlugin.h" #endif -#ifdef ENABLE_PLUGIN_BSPSceneManager -# include "OgreBspSceneManagerPlugin.h" -#endif #ifdef ENABLE_PLUGIN_GL # include "OgreGLPlugin.h" #endif @@ -56,9 +53,6 @@ namespace Render #ifdef ENABLE_PLUGIN_ParticleFX Ogre::ParticleFXPlugin* mParticleFXPlugin; #endif - #ifdef ENABLE_PLUGIN_BSPSceneManager - Ogre::BspSceneManagerPlugin* mBSPPlugin; - #endif #ifdef ENABLE_PLUGIN_GL Ogre::GLPlugin* mGLPlugin; #endif