From 94ce95c679d111a69d6cc5e6f4126c8b64feabb8 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 25 Jul 2012 00:13:33 +0400 Subject: [PATCH 01/23] bug #348: works again on OS X --- CMakeLists.txt | 59 +++++++++++++++---------------- apps/launcher/graphicspage.cpp | 8 +++-- libs/openengine/ogre/renderer.cpp | 12 +++++-- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f124f1383e..05c53e6d61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,13 +227,41 @@ if (APPLE) ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) + + if (${OGRE_PLUGIN_DIR_REL}}) + set(OGRE_PLUGINS_REL_FOUND TRUE) + endif () + + if (${OGRE_PLUGIN_DIR_DBG}) + set(OGRE_PLUGINS_DBG_FOUND TRUE) + endif () + + if (${OGRE_PLUGINS_REL_FOUND}) + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) + 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}) + + configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist + "${APP_BUNDLE_DIR}/Contents/Info.plist") + + configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns + "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) endif (APPLE) # Set up Ogre plugin folder & debug suffix set(DEBUG_SUFFIX "") +add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") if (DEFINED CMAKE_BUILD_TYPE) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") + # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt) + if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE) set(DEBUG_SUFFIX "_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") else() @@ -275,35 +303,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") "${OpenMW_BINARY_DIR}/openmw.desktop") endif() -if (APPLE) - if (${OGRE_PLUGIN_DIR_REL}}) - set(OGRE_PLUGINS_REL_FOUND TRUE) - endif () - - if (${OGRE_PLUGIN_DIR_DBG}) - set(OGRE_PLUGINS_DBG_FOUND TRUE) - endif () - - if (${OGRE_PLUGINS_REL_FOUND}) - set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) - 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}) - - configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist - "${APP_BUNDLE_DIR}/Contents/Info.plist") - - configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns - "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) -endif (APPLE) - - # Compiler settings if (CMAKE_COMPILER_IS_GNUCC) add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 3c1d76f3d3..296ef2c3ea 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -116,11 +116,15 @@ bool GraphicsPage::setupOgre() } std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(glPlugin + ".so") || boost::filesystem::exists(glPlugin + ".dll")) + 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")) + if (boost::filesystem::exists(dxPlugin + ".so") || + boost::filesystem::exists(dxPlugin + ".dll") || + boost::filesystem::exists(dxPlugin + ".dylib")) mOgre->loadPlugin (dxPlugin); #ifdef ENABLE_PLUGIN_GL diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index e40bdf708a..58b363f7f5 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -112,15 +112,21 @@ void OgreRenderer::configure(const std::string &logPath, } std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX; - if (boost::filesystem::exists(glPlugin + ".so") || boost::filesystem::exists(glPlugin + ".dll")) + 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")) + 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")) + if (boost::filesystem::exists(cgPlugin + ".so") || + boost::filesystem::exists(cgPlugin + ".dll") || + boost::filesystem::exists(cgPlugin + ".dylib")) mRoot->loadPlugin (cgPlugin); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); From fbe9a94568d60b9742ab9216d803de18f2912625 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 01:53:50 +0400 Subject: [PATCH 02/23] bug #348: fixed OS X deployment just enable CMake option "OPENMW_OSX_DEPLOYMENT" and it will search plugins inside application bundle instead of Ogre prefix --- CMakeLists.txt | 17 +++++++------ apps/launcher/graphicspage.cpp | 17 ++++++------- components/CMakeLists.txt | 4 +++ components/ogreplugin/ogreplugin.cpp | 37 ++++++++++++++++++++++++++++ components/ogreplugin/ogreplugin.h | 12 +++++++++ libs/openengine/ogre/renderer.cpp | 23 ++++++----------- 6 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 components/ogreplugin/ogreplugin.cpp create mode 100644 components/ogreplugin/ogreplugin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 05c53e6d61..0bc6344c46 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 296ef2c3ea..f9f5c6dda8 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); + boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir)); - 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); + 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 efeb69caed..e16a860c43 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 0000000000..5516482aa3 --- /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 0000000000..bb1ea04e19 --- /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 58b363f7f5..20bb1f40fd 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); + boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir)); - 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); + pluginDir = absPluginPath.string(); - 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); + loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot); + loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot); + loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); if (rs == 0) From e9d4195500287266ee9a6e78006dae4141e3d7ea Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:03:34 +0400 Subject: [PATCH 03/23] removed cout spam --- libs/openengine/ogre/renderer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 20bb1f40fd..f8fed3899f 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -96,7 +96,6 @@ 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) From 0cdb651c5ece1bf5aebf55b9cd8d14ec1fbaf0b4 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:05:06 +0400 Subject: [PATCH 04/23] removed excess invocation --- apps/launcher/graphicspage.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index f9f5c6dda8..7d25f2df1f 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -122,7 +122,6 @@ bool GraphicsPage::setupOgre() loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre); - loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); #ifdef ENABLE_PLUGIN_GL mGLPlugin = new Ogre::GLPlugin(); From a0a086f69d7ea7feb35452b3475d96435126a8e7 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:11:14 +0400 Subject: [PATCH 05/23] fixed redefining macro --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bc6344c46..cbb895760e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,8 +263,6 @@ if (DEFINED CMAKE_BUILD_TYPE) if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE) set(DEBUG_SUFFIX "_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") - else() - add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") endif() endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") From 23e44a86c6c7be2b6373df3a0f0afefef8ec7ca7 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:13:57 +0400 Subject: [PATCH 06/23] another attempt to fix --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbb895760e..b51ea68ea7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,12 +257,13 @@ endif (APPLE) # Set up Ogre plugin folder & debug suffix set(DEBUG_SUFFIX "") -add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") if (DEFINED CMAKE_BUILD_TYPE) # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt) if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE) set(DEBUG_SUFFIX "_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") + else() + add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") endif() endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") From b0b206423285180f0e84a0a2214ccb84d339de43 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:31:30 +0400 Subject: [PATCH 07/23] always add debug suffix in plugin loader also removed cout spam --- components/ogreplugin/ogreplugin.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/ogreplugin/ogreplugin.cpp b/components/ogreplugin/ogreplugin.cpp index 5516482aa3..ce61f344dd 100644 --- a/components/ogreplugin/ogreplugin.cpp +++ b/components/ogreplugin/ogreplugin.cpp @@ -6,10 +6,11 @@ #include bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { + pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX; #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(); + pluginName = pluginName + verStream.str(); #endif std::string pluginExt; @@ -24,9 +25,6 @@ bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &o #endif std::string pluginPath = pluginDir + "/" + pluginName + pluginExt; - - std::cout << "loading plugin: " << pluginPath << std::endl; - if (boost::filesystem::exists(pluginPath)) { ogreRoot.loadPlugin(pluginPath); return true; From 7161361b520fdb895ba42270613e00c3c4457e68 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:38:37 +0400 Subject: [PATCH 08/23] cleanup --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b51ea68ea7..f2decb8f7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,11 +256,9 @@ endif (APPLE) # Set up Ogre plugin folder & debug suffix -set(DEBUG_SUFFIX "") if (DEFINED CMAKE_BUILD_TYPE) # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt) if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE) - set(DEBUG_SUFFIX "_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") else() add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") From a84d8e83cd04e7bfaa25ec7b0e566ef9b0026bd2 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 28 Jul 2012 02:39:49 +0400 Subject: [PATCH 09/23] add const specifier to first argument, also made it reference --- components/ogreplugin/ogreplugin.cpp | 2 +- components/ogreplugin/ogreplugin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/ogreplugin/ogreplugin.cpp b/components/ogreplugin/ogreplugin.cpp index ce61f344dd..329cd1ea97 100644 --- a/components/ogreplugin/ogreplugin.cpp +++ b/components/ogreplugin/ogreplugin.cpp @@ -5,7 +5,7 @@ #include -bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { +bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE std::ostringstream verStream; diff --git a/components/ogreplugin/ogreplugin.h b/components/ogreplugin/ogreplugin.h index bb1ea04e19..d9b00e576d 100644 --- a/components/ogreplugin/ogreplugin.h +++ b/components/ogreplugin/ogreplugin.h @@ -7,6 +7,6 @@ namespace Ogre { class Root; } -extern bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot); +extern bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot); #endif \ No newline at end of file From 90de02b901bde3e62bdf6438998f2365a3704e1f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jul 2012 11:43:28 +0200 Subject: [PATCH 10/23] Issue #350: console only script instructions --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 9 ++- apps/openmw/engine.hpp | 4 + apps/openmw/main.cpp | 10 ++- apps/openmw/mwgui/console.cpp | 10 ++- apps/openmw/mwgui/console.hpp | 5 +- apps/openmw/mwgui/window_manager.cpp | 4 +- apps/openmw/mwgui/window_manager.hpp | 2 +- apps/openmw/mwscript/consoleextensions.cpp | 24 ++++++ apps/openmw/mwscript/consoleextensions.hpp | 25 ++++++ apps/openmw/mwscript/docs/vmformat.txt | 13 +++- apps/openmw/mwscript/extensions.cpp | 18 ++++- apps/openmw/mwscript/extensions.hpp | 8 +- apps/openmw/mwscript/userextensions.cpp | 91 ++++++++++++++++++++++ apps/openmw/mwscript/userextensions.hpp | 25 ++++++ 15 files changed, 230 insertions(+), 20 deletions(-) create mode 100644 apps/openmw/mwscript/consoleextensions.cpp create mode 100644 apps/openmw/mwscript/consoleextensions.hpp create mode 100644 apps/openmw/mwscript/userextensions.cpp create mode 100644 apps/openmw/mwscript/userextensions.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 8e424ad56c..556b9a1ba2 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -39,7 +39,7 @@ add_openmw_dir (mwscript locals scriptmanager compilercontext interpretercontext cellextensions miscextensions guiextensions soundextensions skyextensions statsextensions containerextensions aiextensions controlextensions extensions globalscripts ref dialogueextensions - animationextensions transformationextensions + animationextensions transformationextensions consoleextensions userextensions ) add_openmw_dir (mwsound diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ab5b630711..d224ab71b9 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -129,6 +129,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mCompileAll (false) , mScriptContext (0) , mFSStrict (false) + , mScriptConsoleMode (false) , mCfgMgr(configurationManager) { std::srand ( std::time(NULL) ); @@ -326,7 +327,8 @@ void OMW::Engine::go() MWScript::registerExtensions (mExtensions); mEnvironment.setWindowManager (new MWGui::WindowManager( - mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"))); + mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"), + mScriptConsoleMode)); // Create sound system mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); @@ -490,3 +492,8 @@ void OMW::Engine::setFallbackValues(std::map fallbackMa { mFallbackMap = fallbackMap; } + +void OMW::Engine::setScriptConsoleMode (bool enabled) +{ + mScriptConsoleMode = enabled; +} diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 031cae5510..01b2dd8d6a 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -73,6 +73,7 @@ namespace OMW bool mCompileAll; std::string mFocusName; std::map mFallbackMap; + bool mScriptConsoleMode; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; @@ -158,6 +159,9 @@ namespace OMW void setFallbackValues(std::map map); + /// Enable console-only script functionality + void setScriptConsoleMode (bool enabled); + private: Files::ConfigurationManager& mCfgMgr; }; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 993ec66239..c54c5969b7 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -124,12 +124,15 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-verbose", bpo::value()->implicit_value(true) ->default_value(false), "verbose script output") - ("new-game", bpo::value()->implicit_value(true) - ->default_value(false), "activate char gen/new game mechanics") - ("script-all", bpo::value()->implicit_value(true) ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") + ("script-console", bpo::value()->implicit_value(true) + ->default_value(false), "enable console-only script functionality") + + ("new-game", bpo::value()->implicit_value(true) + ->default_value(false), "activate char gen/new game mechanics") + ("fs-strict", bpo::value()->implicit_value(true) ->default_value(false), "strict file system handling (no case folding)") @@ -249,6 +252,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); engine.setFallbackValues(variables["fallback"].as().mMap); + engine.setScriptConsoleMode (variables["script-console"].as()); return true; } diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 4101165c19..39f36d28a0 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -105,9 +105,10 @@ namespace MWGui } } - Console::Console(int w, int h, const Compiler::Extensions& extensions) + Console::Console(int w, int h, bool consoleOnlyScripts) : Layout("openmw_console.layout"), - mCompilerContext (MWScript::CompilerContext::Type_Console) + mCompilerContext (MWScript::CompilerContext::Type_Console), + mConsoleOnlyScripts (consoleOnlyScripts) { setCoord(10,10, w-10, h/2); @@ -126,7 +127,8 @@ namespace MWGui history->setVisibleVScroll(true); // compiler - mCompilerContext.setExtensions (&extensions); + MWScript::registerExtensions (mExtensions, mConsoleOnlyScripts); + mCompilerContext.setExtensions (&mExtensions); } void Console::enable() @@ -246,7 +248,7 @@ namespace MWGui { ConsoleInterpreterContext interpreterContext (*this, mPtr); Interpreter::Interpreter interpreter; - MWScript::installOpcodes (interpreter); + MWScript::installOpcodes (interpreter, mConsoleOnlyScripts); std::vector code; output.getCode (code); interpreter.run (&code[0], code.size(), interpreterContext); diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index eadf4aa4ea..b01ebf7fa7 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "../mwscript/compilercontext.hpp" @@ -24,8 +25,10 @@ namespace MWGui { private: + Compiler::Extensions mExtensions; MWScript::CompilerContext mCompilerContext; std::vector mNames; + bool mConsoleOnlyScripts; bool compile (const std::string& cmd, Compiler::Output& output); @@ -62,7 +65,7 @@ namespace MWGui StringList::iterator current; std::string editString; - Console(int w, int h, const Compiler::Extensions& extensions); + Console(int w, int h, bool consoleOnlyScripts); void enable(); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index aa0595b852..25f0fc097c 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -41,7 +41,7 @@ using namespace MWGui; WindowManager::WindowManager( - const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath) + const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts) : mGuiManager(NULL) , mHud(NULL) , mMap(NULL) @@ -113,7 +113,7 @@ WindowManager::WindowManager( mMenu = new MainMenu(w,h); mMap = new MapWindow(*this); mStatsWindow = new StatsWindow(*this); - mConsole = new Console(w,h, extensions); + mConsole = new Console(w,h, consoleOnlyScripts); mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index adab799426..51fde071d0 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -94,7 +94,7 @@ namespace MWGui typedef std::vector FactionList; typedef std::vector SkillList; - WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath); + WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, bool consoleOnlyScripts); virtual ~WindowManager(); /** diff --git a/apps/openmw/mwscript/consoleextensions.cpp b/apps/openmw/mwscript/consoleextensions.cpp new file mode 100644 index 0000000000..00b4f74e54 --- /dev/null +++ b/apps/openmw/mwscript/consoleextensions.cpp @@ -0,0 +1,24 @@ + +#include "consoleextensions.hpp" + +#include + +#include +#include +#include + +namespace MWScript +{ + namespace Console + { + void registerExtensions (Compiler::Extensions& extensions) + { + + } + + void installOpcodes (Interpreter::Interpreter& interpreter) + { + + } + } +} diff --git a/apps/openmw/mwscript/consoleextensions.hpp b/apps/openmw/mwscript/consoleextensions.hpp new file mode 100644 index 0000000000..b10bf06a8d --- /dev/null +++ b/apps/openmw/mwscript/consoleextensions.hpp @@ -0,0 +1,25 @@ +#ifndef GAME_SCRIPT_CONSOLEEXTENSIONS_H +#define GAME_SCRIPT_CONSOLEEXTENSIONS_H + +namespace Compiler +{ + class Extensions; +} + +namespace Interpreter +{ + class Interpreter; +} + +namespace MWScript +{ + /// \brief Script functionality limited to the console + namespace Console + { + void registerExtensions (Compiler::Extensions& extensions); + + void installOpcodes (Interpreter::Interpreter& interpreter); + } +} + +#endif diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index b979420dd2..3ca93d4b2b 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -169,5 +169,14 @@ op 0x2000164: SetScale op 0x2000165: SetScale, explicit reference op 0x2000166: SetAngle op 0x2000167: SetAngle, explicit reference -opcodes 0x2000168-0x3ffffff unused - +op 0x2000168: GetScale +op 0x2000169: GetScale, explicit reference +op 0x200016a: GetAngle +op 0x200016b: GetAngle, explicit reference +op 0x200016c: user1 (console only, requires --script-console switch) +op 0x200016d: user2 (console only, requires --script-console switch) +op 0x200016e: user3, explicit reference (console only, requires --script-console switch) +op 0x200016f: user3 (implicit reference, console only, requires --script-console switch) +op 0x2000170: user4, explicit reference (console only, requires --script-console switch) +op 0x2000171: user4 (implicit reference, console only, requires --script-console switch) +opcodes 0x2000172-0x3ffffff unused diff --git a/apps/openmw/mwscript/extensions.cpp b/apps/openmw/mwscript/extensions.cpp index b7425aca0b..1b15608202 100644 --- a/apps/openmw/mwscript/extensions.cpp +++ b/apps/openmw/mwscript/extensions.cpp @@ -16,10 +16,12 @@ #include "dialogueextensions.hpp" #include "animationextensions.hpp" #include "transformationextensions.hpp" +#include "consoleextensions.hpp" +#include "userextensions.hpp" namespace MWScript { - void registerExtensions (Compiler::Extensions& extensions) + void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly) { Cell::registerExtensions (extensions); Misc::registerExtensions (extensions); @@ -33,9 +35,15 @@ namespace MWScript Dialogue::registerExtensions (extensions); Animation::registerExtensions (extensions); Transformation::registerExtensions (extensions); + + if (consoleOnly) + { + Console::registerExtensions (extensions); + User::registerExtensions (extensions); + } } - void installOpcodes (Interpreter::Interpreter& interpreter) + void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly) { Interpreter::installOpcodes (interpreter); Cell::installOpcodes (interpreter); @@ -50,5 +58,11 @@ namespace MWScript Dialogue::installOpcodes (interpreter); Animation::installOpcodes (interpreter); Transformation::installOpcodes (interpreter); + + if (consoleOnly) + { + Console::installOpcodes (interpreter); + User::installOpcodes (interpreter); + } } } diff --git a/apps/openmw/mwscript/extensions.hpp b/apps/openmw/mwscript/extensions.hpp index 9738367a0f..cb1aaf9db2 100644 --- a/apps/openmw/mwscript/extensions.hpp +++ b/apps/openmw/mwscript/extensions.hpp @@ -13,9 +13,11 @@ namespace Interpreter namespace MWScript { - void registerExtensions (Compiler::Extensions& extensions); - - void installOpcodes (Interpreter::Interpreter& interpreter); + void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly = false); + ///< \param consoleOnly include console only extensions + + void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly = false); + ///< \param consoleOnly include console only opcodes } #endif diff --git a/apps/openmw/mwscript/userextensions.cpp b/apps/openmw/mwscript/userextensions.cpp new file mode 100644 index 0000000000..9c97388159 --- /dev/null +++ b/apps/openmw/mwscript/userextensions.cpp @@ -0,0 +1,91 @@ + +#include "userextensions.hpp" + +#include + +#include +#include +#include +#include + +#include "ref.hpp" + +namespace MWScript +{ + /// Temporary script extensions. + /// + /// \attention Do not commit changes to this file to a git repository! + namespace User + { + class OpUser1 : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + runtime.getContext().report ("user1: not in use"); + } + }; + + class OpUser2 : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + runtime.getContext().report ("user2: not in use"); + } + }; + + template + class OpUser3 : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { +// MWWorld::Ptr ptr = R()(runtime); + + runtime.getContext().report ("user3: not in use"); + } + }; + + template + class OpUser4 : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { +// MWWorld::Ptr ptr = R()(runtime); + + runtime.getContext().report ("user4: not in use"); + } + }; + + const int opcodeUser1 = 0x200016c; + const int opcodeUser2 = 0x200016d; + const int opcodeUser3 = 0x200016e; + const int opcodeUser3Explicit = 0x200016f; + const int opcodeUser4 = 0x2000170; + const int opcodeUser4Explicit = 0x2000171; + + void registerExtensions (Compiler::Extensions& extensions) + { + extensions.registerInstruction ("user1", "", opcodeUser1); + extensions.registerInstruction ("user2", "", opcodeUser2); + extensions.registerInstruction ("user3", "", opcodeUser3, opcodeUser3); + extensions.registerInstruction ("user4", "", opcodeUser4, opcodeUser4); + } + + void installOpcodes (Interpreter::Interpreter& interpreter) + { + interpreter.installSegment5 (opcodeUser1, new OpUser1); + interpreter.installSegment5 (opcodeUser2, new OpUser2); + interpreter.installSegment5 (opcodeUser3, new OpUser3); + interpreter.installSegment5 (opcodeUser3Explicit, new OpUser3); + interpreter.installSegment5 (opcodeUser4, new OpUser4); + interpreter.installSegment5 (opcodeUser4Explicit, new OpUser4); + } + } +} diff --git a/apps/openmw/mwscript/userextensions.hpp b/apps/openmw/mwscript/userextensions.hpp new file mode 100644 index 0000000000..3642eb5f49 --- /dev/null +++ b/apps/openmw/mwscript/userextensions.hpp @@ -0,0 +1,25 @@ +#ifndef GAME_SCRIPT_USEREXTENSIONS_H +#define GAME_SCRIPT_USEREXTENSIONS_H + +namespace Compiler +{ + class Extensions; +} + +namespace Interpreter +{ + class Interpreter; +} + +namespace MWScript +{ + /// \brief Temporaty script functionality limited to the console + namespace User + { + void registerExtensions (Compiler::Extensions& extensions); + + void installOpcodes (Interpreter::Interpreter& interpreter); + } +} + +#endif From 23f8595b8767f97492e9aeb67d82a8a8cbd81543 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jul 2012 11:57:19 +0200 Subject: [PATCH 11/23] Issue #352: refactored script execution in console --- apps/openmw/mwgui/console.cpp | 49 +++++++++++++++++++---------------- apps/openmw/mwgui/console.hpp | 2 ++ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 39f36d28a0..fdcc676041 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -175,6 +175,32 @@ namespace MWGui print("#FF2222" + msg + "\n"); } + void Console::execute (const std::string& command) + { + // Log the command + print("#FFFFFF> " + command + "\n"); + + Compiler::Locals locals; + Compiler::Output output (locals); + + if (compile (command + "\n", output)) + { + try + { + ConsoleInterpreterContext interpreterContext (*this, mPtr); + Interpreter::Interpreter interpreter; + MWScript::installOpcodes (interpreter, mConsoleOnlyScripts); + std::vector code; + output.getCode (code); + interpreter.run (&code[0], code.size(), interpreterContext); + } + catch (const std::exception& error) + { + printError (std::string ("An exception has been thrown: ") + error.what()); + } + } + } + void Console::keyPress(MyGUI::WidgetPtr _sender, MyGUI::KeyCode key, MyGUI::Char _char) @@ -236,28 +262,7 @@ namespace MWGui current = command_history.end(); editString.clear(); - // Log the command - print("#FFFFFF> " + cm + "\n"); - - Compiler::Locals locals; - Compiler::Output output (locals); - - if (compile (cm + "\n", output)) - { - try - { - ConsoleInterpreterContext interpreterContext (*this, mPtr); - Interpreter::Interpreter interpreter; - MWScript::installOpcodes (interpreter, mConsoleOnlyScripts); - std::vector code; - output.getCode (code); - interpreter.run (&code[0], code.size(), interpreterContext); - } - catch (const std::exception& error) - { - printError (std::string ("An exception has been thrown: ") + error.what()); - } - } + execute (cm); command->setCaption(""); } diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index b01ebf7fa7..f587fefed7 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -89,6 +89,8 @@ namespace MWGui /// Error message void printError(const std::string &msg); + void execute (const std::string& command); + private: void keyPress(MyGUI::WidgetPtr _sender, From fd6c155118fbe469fb78fc584eb3fbf98df7a80f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jul 2012 12:37:46 +0200 Subject: [PATCH 12/23] Issue #352: added --script-run switch --- apps/openmw/engine.cpp | 8 ++++++++ apps/openmw/engine.hpp | 4 ++++ apps/openmw/main.cpp | 6 ++++++ apps/openmw/mwgui/console.cpp | 16 ++++++++++++++++ apps/openmw/mwgui/console.hpp | 2 ++ apps/openmw/mwgui/window_manager.cpp | 5 +++++ apps/openmw/mwgui/window_manager.hpp | 2 ++ 7 files changed, 43 insertions(+) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index d224ab71b9..5e9aedf66a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -390,6 +390,9 @@ void OMW::Engine::go() << std::endl; } + if (!mStartupScript.empty()) + MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript); + // Start the main rendering loop mOgre->start(); @@ -497,3 +500,8 @@ void OMW::Engine::setScriptConsoleMode (bool enabled) { mScriptConsoleMode = enabled; } + +void OMW::Engine::setStartupScript (const std::string& path) +{ + mStartupScript = path; +} diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 01b2dd8d6a..57402c91e2 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -74,6 +74,7 @@ namespace OMW std::string mFocusName; std::map mFallbackMap; bool mScriptConsoleMode; + std::string mStartupScript; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; @@ -162,6 +163,9 @@ namespace OMW /// Enable console-only script functionality void setScriptConsoleMode (bool enabled); + /// Set path for a script that is run on startup in the console. + void setStartupScript (const std::string& path); + private: Files::ConfigurationManager& mCfgMgr; }; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index c54c5969b7..fb1657ad4e 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -130,6 +130,11 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-console", bpo::value()->implicit_value(true) ->default_value(false), "enable console-only script functionality") + ("script-run", bpo::value()->default_value(""), + "set a file that is execute in the console on startup\n\n" + "Note: The file contains a list of script lines, but not a complete scripts. " + "That means no begin/end and no variable declarations.") + ("new-game", bpo::value()->implicit_value(true) ->default_value(false), "activate char gen/new game mechanics") @@ -253,6 +258,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setAnimationVerbose(variables["anim-verbose"].as()); engine.setFallbackValues(variables["fallback"].as().mMap); engine.setScriptConsoleMode (variables["script-console"].as()); + engine.setStartupScript (variables["script-run"].as()); return true; } diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index fdcc676041..86c8940a19 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -2,6 +2,7 @@ #include "console.hpp" #include +#include #include #include @@ -201,6 +202,21 @@ namespace MWGui } } + void Console::executeFile (const std::string& path) + { + std::ifstream stream (path.c_str()); + + if (!stream.is_open()) + printError ("failed to open file: " + path); + else + { + std::string line; + + while (std::getline (stream, line)) + execute (line); + } + } + void Console::keyPress(MyGUI::WidgetPtr _sender, MyGUI::KeyCode key, MyGUI::Char _char) diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index f587fefed7..1893b01486 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -91,6 +91,8 @@ namespace MWGui void execute (const std::string& command); + void executeFile (const std::string& command); + private: void keyPress(MyGUI::WidgetPtr _sender, diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 25f0fc097c..659af04470 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -740,3 +740,8 @@ bool WindowManager::getWorldMouseOver() { return mHud->getWorldMouseOver(); } + +void WindowManager::executeInConsole (const std::string& path) +{ + mConsole->executeFile (path); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 51fde071d0..3653615a69 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -237,6 +237,8 @@ namespace MWGui void processChangedSettings(const Settings::CategorySettingVector& changed); + void executeInConsole (const std::string& path); + private: OEngine::GUI::MyGUIManager *mGuiManager; HUD *mHud; From 2ccecd839bdac85672cd3aa861cfa95f25c27f46 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jul 2012 12:43:23 +0200 Subject: [PATCH 13/23] improved the help text for --script-run; updated readme.txt --- apps/openmw/main.cpp | 2 +- readme.txt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index fb1657ad4e..0ca9dd6d9b 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -131,7 +131,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ->default_value(false), "enable console-only script functionality") ("script-run", bpo::value()->default_value(""), - "set a file that is execute in the console on startup\n\n" + "select a file that is executed in the console on startup\n\n" "Note: The file contains a list of script lines, but not a complete scripts. " "That means no begin/end and no variable declarations.") diff --git a/readme.txt b/readme.txt index ded9bcd7bc..ce3d115e37 100644 --- a/readme.txt +++ b/readme.txt @@ -66,9 +66,16 @@ Allowed options: --debug [=arg(=1)] (=0) debug mode --nosound [=arg(=1)] (=0) disable all sounds --script-verbose [=arg(=1)] (=0) verbose script output - --new-game [=arg(=1)] (=0) activate char gen/new game mechanics --script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scri pts) at startup + --script-console [=arg(=1)] (=0) enable console-only script functionality + --script-run arg select a file that is executed in the consol + e on startup + + Note: The file contains a list of script + lines, but not a complete scripts. That mean + s no begin/end and no variable declarations. + --new-game [=arg(=1)] (=0) activate char gen/new game mechanics --fs-strict [=arg(=1)] (=0) strict file system handling (no case folding ) --encoding arg (=win1252) Character encoding used in OpenMW game messa From e7a1ab9fa627e5509d0611d86b07e0ed9b65d5ce Mon Sep 17 00:00:00 2001 From: Michael Mc Donnell Date: Mon, 30 Jul 2012 15:04:14 -0400 Subject: [PATCH 14/23] Define OGRE_PLUGIN_DEBUG_SUFFIX in all cases. --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea0c41fe25..9ac6419ba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,14 +235,13 @@ endif (APPLE) # Set up Ogre plugin folder & debug suffix set(DEBUG_SUFFIX "") -if (DEFINED CMAKE_BUILD_TYPE) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(DEBUG_SUFFIX "_d") - add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") - else() - add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") - endif() +if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DEBUG_SUFFIX "_d") + add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") +else() + add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") 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}") From b05dfeae70302bd4b44d30a16c8beecd81aebc26 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 31 Jul 2012 01:00:53 +0400 Subject: [PATCH 15/23] bug #348: cleanup moved files to appropriate component, moved function to namespace, added docs --- apps/launcher/graphicspage.cpp | 6 +-- components/CMakeLists.txt | 6 +-- .../{ogreplugin => files}/ogreplugin.cpp | 6 ++- components/files/ogreplugin.hpp | 50 +++++++++++++++++++ components/ogreplugin/ogreplugin.h | 12 ----- libs/openengine/ogre/renderer.cpp | 8 +-- 6 files changed, 63 insertions(+), 25 deletions(-) rename components/{ogreplugin => files}/ogreplugin.cpp (95%) create mode 100644 components/files/ogreplugin.hpp delete mode 100644 components/ogreplugin/ogreplugin.h diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 7d25f2df1f..c3c39cffce 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #include "graphicspage.hpp" #include "naturalsort.hpp" @@ -120,8 +120,8 @@ bool GraphicsPage::setupOgre() pluginDir = absPluginPath.string(); - loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); - loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre); + Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre); + Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre); #ifdef ENABLE_PLUGIN_GL mGLPlugin = new Ogre::GLPlugin(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index e16a860c43..c0585d5ee5 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -52,7 +52,7 @@ add_component_dir (misc add_component_dir (files linuxpath windowspath macospath fixedpath multidircollection collections fileops configurationmanager - filelibrary + filelibrary ogreplugin ) add_component_dir (compiler @@ -66,10 +66,6 @@ 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/files/ogreplugin.cpp similarity index 95% rename from components/ogreplugin/ogreplugin.cpp rename to components/files/ogreplugin.cpp index 329cd1ea97..d0e80f68d5 100644 --- a/components/ogreplugin/ogreplugin.cpp +++ b/components/files/ogreplugin.cpp @@ -1,10 +1,12 @@ -#include "ogreplugin.h" +#include "ogreplugin.hpp" #include #include #include +namespace Files { + bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE @@ -32,4 +34,6 @@ bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre:: else { return false; } +} + } \ No newline at end of file diff --git a/components/files/ogreplugin.hpp b/components/files/ogreplugin.hpp new file mode 100644 index 0000000000..a6d2a35c98 --- /dev/null +++ b/components/files/ogreplugin.hpp @@ -0,0 +1,50 @@ +/** + * Open Morrowind - an opensource Elder Scrolls III: Morrowind + * engine implementation. + * + * Copyright (C) 2011 Open Morrowind Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file components/files/ogreplugin.hpp */ + +#ifndef COMPONENTS_FILES_OGREPLUGIN_H +#define COMPONENTS_FILES_OGREPLUGIN_H + +#include + +namespace Ogre { + class Root; +} + +/** + * \namespace Files + */ +namespace Files { + +/** + * \brief Loads Ogre plugin with given name. + * + * \param pluginDir absolute path to plugins + * \param pluginName plugin name, for example "RenderSystem_GL" + * \param ogreRoot Ogre::Root instance + * + * \return whether plugin was located or not + */ +bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot); + +} + +#endif /* COMPONENTS_FILES_OGREPLUGIN_H */ \ No newline at end of file diff --git a/components/ogreplugin/ogreplugin.h b/components/ogreplugin/ogreplugin.h deleted file mode 100644 index d9b00e576d..0000000000 --- a/components/ogreplugin/ogreplugin.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef OGREPLUGIN_H -#define OGREPLUGIN_H - -#include - -namespace Ogre { - class Root; -} - -extern bool loadOgrePlugin(const 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 f8fed3899f..7fff2a8b45 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -11,7 +11,7 @@ #include -#include +#include #include #include @@ -117,9 +117,9 @@ void OgreRenderer::configure(const std::string &logPath, pluginDir = absPluginPath.string(); - loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot); - loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot); - loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot); + Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot); + Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot); + Files::loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); if (rs == 0) From 03cccee0e4eb7f57a039559308cfe8f25ce5b0f1 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 31 Jul 2012 10:51:34 +0400 Subject: [PATCH 16/23] bug #348: workaround for boost older than 1.44 --- components/files/ogreplugin.cpp | 2 -- components/files/ogreplugin.hpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/files/ogreplugin.cpp b/components/files/ogreplugin.cpp index d0e80f68d5..c434114b37 100644 --- a/components/files/ogreplugin.cpp +++ b/components/files/ogreplugin.cpp @@ -3,8 +3,6 @@ #include #include -#include - namespace Files { bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) { diff --git a/components/files/ogreplugin.hpp b/components/files/ogreplugin.hpp index a6d2a35c98..d8469aa4b1 100644 --- a/components/files/ogreplugin.hpp +++ b/components/files/ogreplugin.hpp @@ -25,10 +25,25 @@ #include +#include +#include + namespace Ogre { class Root; } +#if (BOOST_VERSION <= 104300) +#error BOOST_VERSION +namespace boost { +namespace filesystem { +path absolute(const path& p, const path& base=current_path()) { + // call obsolete version of this function on older boost + return complete(p, base); +} +} +} +#endif /* (BOOST_VERSION <= 104300) */ + /** * \namespace Files */ From 32d2326b4dddc0420cc5df23a89de17cf76677fa Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 31 Jul 2012 18:15:09 +0400 Subject: [PATCH 17/23] Update components/files/ogreplugin.hpp removed #error directive --- components/files/ogreplugin.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/components/files/ogreplugin.hpp b/components/files/ogreplugin.hpp index d8469aa4b1..7a0b5841e9 100644 --- a/components/files/ogreplugin.hpp +++ b/components/files/ogreplugin.hpp @@ -33,7 +33,6 @@ namespace Ogre { } #if (BOOST_VERSION <= 104300) -#error BOOST_VERSION namespace boost { namespace filesystem { path absolute(const path& p, const path& base=current_path()) { From 3b776cb3ca5ef6417cb965daf60a95be96c09555 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 1 Aug 2012 00:01:32 +0400 Subject: [PATCH 18/23] fixed submodule version --- extern/shiny | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/shiny b/extern/shiny index 5546a5bd84..164bc8d3bf 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit 5546a5bd8474ef328dfedae2df42126cdaf9515f +Subproject commit 164bc8d3bfe860bd16ad89c0bd1b59f465c9bb24 From 15a16aeba1c2b7fd0ba3e47b14fd673a17295524 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Aug 2012 04:11:16 +0200 Subject: [PATCH 19/23] Fixed DirectX HLSL shaders and re-enabled them in the gui --- apps/openmw/mwgui/settingswindow.cpp | 12 ++++------ apps/openmw/mwrender/renderingmanager.cpp | 16 ++++++------- files/materials/core.h | 29 +++++++++++++---------- files/materials/objects.shaderset | 4 ++-- files/materials/terrain.shaderset | 4 ++-- files/materials/underwater.h | 10 ++++---- files/materials/water.shader | 11 +++++---- files/materials/water.shaderset | 4 ++-- 8 files changed, 46 insertions(+), 44 deletions(-) diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index d8b0c96d74..4488096fe9 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -75,9 +75,9 @@ namespace return boost::lexical_cast(xaspect) + " : " + boost::lexical_cast(yaspect); } - bool hasGLSL () + std::string hlslGlsl () { - return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos); + return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl"; } } @@ -393,12 +393,9 @@ namespace MWGui std::string val = static_cast(_sender)->getCaption(); if (val == "off") { - if (hasGLSL ()) - val = "glsl"; - else - val = "cg"; + val = hlslGlsl(); } - else if (val == "glsl") + else if (val == hlslGlsl()) val = "cg"; else val = "off"; @@ -411,6 +408,7 @@ namespace MWGui // water shader not supported with object shaders off mWaterShaderButton->setCaptionWithReplacing("#{sOff}"); + mUnderwaterButton->setCaptionWithReplacing("#{sOff}"); mWaterShaderButton->setEnabled(false); mReflectObjectsButton->setEnabled(false); mReflectActorsButton->setEnabled(false); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ae0e572199..a4b2e8489c 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -43,12 +43,14 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const :mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0) { // select best shader mode - if (Settings::Manager::getString("shader mode", "General") == "") + bool openGL = (Ogre::Root::getSingleton ().getRenderSystem ()->getName().find("OpenGL") != std::string::npos); + + // glsl is only supported in opengl mode and hlsl only in direct3d mode. + if (Settings::Manager::getString("shader mode", "General") == "" + || (openGL && Settings::Manager::getString("shader mode", "General") == "hlsl") + || (!openGL && Settings::Manager::getString("shader mode", "General") == "glsl")) { - if (Ogre::Root::getSingleton ().getRenderSystem ()->getName().find("OpenGL") == std::string::npos) - Settings::Manager::setString("shader mode", "General", "cg"); - else - Settings::Manager::setString("shader mode", "General", "glsl"); + Settings::Manager::setString("shader mode", "General", openGL ? "glsl" : "hlsl"); } mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5); @@ -74,10 +76,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mFactory->setCurrentLanguage (lang); mFactory->loadAllFiles(); - //The fog type must be set before any terrain objects are created as if the - //fog type is set to FOG_NONE then the initially created terrain won't have any fog - configureFog(1, ColourValue(1,1,1)); - // Set default mipmap level (NB some APIs ignore this) TextureManager::getSingleton().setDefaultNumMipmaps(Settings::Manager::getInt("num mipmaps", "General")); diff --git a/files/materials/core.h b/files/materials/core.h index 6e27d349c2..cba7167770 100644 --- a/files/materials/core.h +++ b/files/materials/core.h @@ -1,20 +1,20 @@ -#if SH_HLSL == 1 - #error "HLSL is unsupported" -#endif - -#if SH_CG == 1 +#if SH_HLSL == 1 || SH_CG == 1 #define shTexture2D sampler2D #define shSample(tex, coord) tex2D(tex, coord) + #define shCubicSample(tex, coord) texCUBE(tex, coord) #define shLerp(a, b, t) lerp(a, b, t) #define shSaturate(a) saturate(a) #define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name) + + #define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name) #define shMatrixMult(m, v) mul(m, v) #define shUniform(type, name) , uniform type name + #define shTangentInput(type) , in type tangent : TANGENT #define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1) #define shInput(type, name) , in type name : TEXCOORD@shCounter(1) #define shOutput(type, name) , out type name : TEXCOORD@shCounter(2) @@ -65,9 +65,10 @@ #define float4 vec4 #define int2 ivec2 #define int3 ivec3 - #define int4 ivec4/ + #define int4 ivec4 #define shTexture2D sampler2D #define shSample(tex, coord) texture2D(tex, coord) + #define shCubicSample(tex, coord) textureCube(tex, coord) #define shLerp(a, b, t) mix(a, b, t) #define shSaturate(a) clamp(a, 0.0, 1.0) @@ -75,11 +76,14 @@ #define shSampler2D(name) uniform sampler2D name; @shUseSampler(name) + #define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name) + #define shMatrixMult(m, v) (m * v) #define shOutputPosition gl_Position #define float4x4 mat4 + #define float3x3 mat3 // GLSL 1.3 #if 0 @@ -89,8 +93,8 @@ #define shOutputColour(num) oColor##num - - + #define shTangentInput(type) in type tangent; + #define shVertexInput(type, name) in type name; #define shInput(type, name) in type name; #define shOutput(type, name) out type name; @@ -101,7 +105,7 @@ #ifdef SH_VERTEX_SHADER #define SH_BEGIN_PROGRAM \ - in float4 shInputPosition; + in float4 vertex; #define SH_START_PROGRAM \ void main(void) @@ -126,10 +130,11 @@ #if 1 // automatically recognized by ogre when the input name equals this - #define shInputPosition gl_Vertex + #define shInputPosition vertex #define shOutputColour(num) gl_FragData[num] + #define shTangentInput(type) attribute type tangent; #define shVertexInput(type, name) attribute type name; #define shInput(type, name) varying type name; #define shOutput(type, name) varying type name; @@ -140,8 +145,8 @@ #ifdef SH_VERTEX_SHADER - #define SH_BEGIN_PROGRAM - + #define SH_BEGIN_PROGRAM \ + attribute vec4 vertex; #define SH_START_PROGRAM \ void main(void) diff --git a/files/materials/objects.shaderset b/files/materials/objects.shaderset index ccb975fe91..028c15ce8a 100644 --- a/files/materials/objects.shaderset +++ b/files/materials/objects.shaderset @@ -3,7 +3,7 @@ shader_set openmw_objects_vertex source objects.shader type vertex profiles_cg vs_2_0 vp40 arbvp1 - profiles_hlsl vs_2_0 + profiles_hlsl vs_3_0 vs_2_0 } shader_set openmw_objects_fragment @@ -11,5 +11,5 @@ shader_set openmw_objects_fragment source objects.shader type fragment profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1 - profiles_hlsl ps_2_0 + profiles_hlsl ps_3_0 ps_2_0 } diff --git a/files/materials/terrain.shaderset b/files/materials/terrain.shaderset index be8ecd7d83..a72f2358fd 100644 --- a/files/materials/terrain.shaderset +++ b/files/materials/terrain.shaderset @@ -3,7 +3,7 @@ shader_set terrain_vertex source terrain.shader type vertex profiles_cg vs_2_0 vp40 arbvp1 - profiles_hlsl vs_2_0 + profiles_hlsl vs_3_0 vs_2_0 } shader_set terrain_fragment @@ -11,5 +11,5 @@ shader_set terrain_fragment source terrain.shader type fragment profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1 - profiles_hlsl ps_2_0 + profiles_hlsl ps_3_0 ps_2_0 } diff --git a/files/materials/underwater.h b/files/materials/underwater.h index fe19ff93b9..18052a98da 100644 --- a/files/materials/underwater.h +++ b/files/materials/underwater.h @@ -28,7 +28,7 @@ float3 intercept(float3 lineP, float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer) { - float2 nCoord = float2(0.0); + float2 nCoord = float2(0,0); bend *= WAVE_CHOPPYNESS; nCoord = coords * (WAVE_SCALE * 0.05) + windDir * timer * (windSpeed*0.04); float3 normal0 = 2.0 * shSample(tex, nCoord + float2(-timer*0.015,-timer*0.05)).rgb - 1.0; @@ -55,8 +55,8 @@ float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, floa float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer) { bend *= WAVE_CHOPPYNESS; - float3 col = float3(0.0); - float2 nCoord = float2(0.0); //normal coords + float3 col = float3(0,0,0); + float2 nCoord = float2(0,0); //normal coords nCoord = coords * (WAVE_SCALE * 0.025) + windDir * timer * (windSpeed*0.03); col += shSample(tex,nCoord + float2(-timer*0.005,-timer*0.01)).rgb*0.20; @@ -102,11 +102,11 @@ float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, /// \todo sunFade // float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth; - float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth; + float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth; float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z; float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z; //caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth; - caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*causticdepth; + caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth; caustics *= 3; diff --git a/files/materials/water.shader b/files/materials/water.shader index 2145919b0e..08a19ace93 100644 --- a/files/materials/water.shader +++ b/files/materials/water.shader @@ -198,7 +198,7 @@ float depth = shSample(depthMap, screenCoords).x * far - depthPassthrough; float shoreFade = shSaturate(depth / 50.0); - float2 nCoord = float2(0.0); + float2 nCoord = float2(0,0); nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04); float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0; @@ -238,12 +238,12 @@ // sunlight scattering float3 pNormal = float3(0,1,0); - vec3 lR = reflect(lVec, lNormal); - vec3 llR = reflect(lVec, pNormal); + float3 lR = reflect(lVec, lNormal); + float3 llR = reflect(lVec, pNormal); float s = shSaturate(dot(lR, vVec)*2.0-1.2); float lightScatter = shSaturate(dot(-lVec,lNormal)*0.7+0.3) * s * SCATTER_AMOUNT * waterSunFade_sunHeight.x * shSaturate(1.0-exp(-waterSunFade_sunHeight.y)); - float3 scatterColour = shLerp(vec3(SCATTER_COLOUR)*vec3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); + float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); // fresnel float ior = (cameraPos.y>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air @@ -284,7 +284,7 @@ waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0); float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0; float3 waterext = float3(0.6, 0.9, 1.0);//water extinction - watercolour = mix(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); + watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT))); float darkness = VISIBILITY*2.0; darkness = clamp((cameraPos.y+darkness)/darkness,0.2,1.0); @@ -299,6 +299,7 @@ shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue); } + shOutputColour(0).w = 1; } #endif diff --git a/files/materials/water.shaderset b/files/materials/water.shaderset index 754ac8e49f..5e070a45a9 100644 --- a/files/materials/water.shaderset +++ b/files/materials/water.shaderset @@ -3,7 +3,7 @@ shader_set water_vertex source water.shader type vertex profiles_cg vs_2_0 vp40 arbvp1 - profiles_hlsl vs_2_0 + profiles_hlsl vs_3_0 vs_2_0 } shader_set water_fragment @@ -11,5 +11,5 @@ shader_set water_fragment source water.shader type fragment profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1 - profiles_hlsl ps_2_0 + profiles_hlsl ps_3_0 ps_2_0 } From f8e54b401bc0b65a8bda04f0e332775c1f9a81f9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 1 Aug 2012 09:09:00 +0200 Subject: [PATCH 20/23] fixed linkage problem --- components/files/ogreplugin.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/files/ogreplugin.hpp b/components/files/ogreplugin.hpp index 7a0b5841e9..c5292b3a21 100644 --- a/components/files/ogreplugin.hpp +++ b/components/files/ogreplugin.hpp @@ -35,7 +35,7 @@ namespace Ogre { #if (BOOST_VERSION <= 104300) namespace boost { namespace filesystem { -path absolute(const path& p, const path& base=current_path()) { +inline path absolute(const path& p, const path& base=current_path()) { // call obsolete version of this function on older boost return complete(p, base); } @@ -50,7 +50,7 @@ namespace Files { /** * \brief Loads Ogre plugin with given name. - * + * * \param pluginDir absolute path to plugins * \param pluginName plugin name, for example "RenderSystem_GL" * \param ogreRoot Ogre::Root instance @@ -61,4 +61,4 @@ bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre:: } -#endif /* COMPONENTS_FILES_OGREPLUGIN_H */ \ No newline at end of file +#endif /* COMPONENTS_FILES_OGREPLUGIN_H */ From 18fd14ff75441a8f2464dfedf1676bb14dd69efb Mon Sep 17 00:00:00 2001 From: Michael Mc Donnell Date: Mon, 30 Jul 2012 14:18:02 -0400 Subject: [PATCH 21/23] Workaround for FindMyGUI.cmake path space bug on Windows. See bug 353 http://bugs.openmw.org/issues/353 --- cmake/FindMyGUI.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/FindMyGUI.cmake b/cmake/FindMyGUI.cmake index 7278fe2007..e2fefac7dc 100644 --- a/cmake/FindMyGUI.cmake +++ b/cmake/FindMyGUI.cmake @@ -128,9 +128,11 @@ ELSE (WIN32) #Unix ENDIF (WIN32) #Do some preparation -SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS) -SEPARATE_ARGUMENTS(MYGUI_LIBRARIES) -SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES) +IF (NOT WIN32) # This does not work on Windows for paths with spaces in them + SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS) + SEPARATE_ARGUMENTS(MYGUI_LIBRARIES) + SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES) +ENDIF (NOT WIN32) SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${FREETYPE_LIBRARIES}) From e9aac4512b8563d5b5e65e9c05ecfd2502a8207f Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 30 Jul 2012 19:45:40 +0200 Subject: [PATCH 22/23] Build fix for Windows Fixes a number of places where uint was used and not defined. This commit was originally authored by gus. It rebased by Michael Mc Donnell to take recent commit fixes into account. --- apps/openmw/mwrender/terrainmaterial.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 1a2d96a144..9ef4652f63 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -86,15 +86,15 @@ namespace MWRender normalMap->setProperty ("direct_texture", sh::makeProperty (new sh::StringValue(terrain->getTerrainNormalMap ()->getName()))); normalMap->setProperty ("tex_address_mode", sh::makeProperty (new sh::StringValue("clamp"))); - uint maxLayers = getMaxLayers(terrain); - uint numBlendTextures = std::min(terrain->getBlendTextureCount(maxLayers), terrain->getBlendTextureCount()); - uint numLayers = std::min(maxLayers, static_cast(terrain->getLayerCount())); + Ogre::uint maxLayers = getMaxLayers(terrain); + Ogre::uint numBlendTextures = std::min(terrain->getBlendTextureCount(maxLayers), terrain->getBlendTextureCount()); + Ogre::uint numLayers = std::min(maxLayers, static_cast(terrain->getLayerCount())); p->mShaderProperties.setProperty ("num_layers", sh::makeProperty(new sh::StringValue(Ogre::StringConverter::toString(numLayers)))); p->mShaderProperties.setProperty ("num_blendmaps", sh::makeProperty(new sh::StringValue(Ogre::StringConverter::toString(numBlendTextures)))); // blend maps - for (uint i = 0; i < numBlendTextures; ++i) + for (Ogre::uint i = 0; i < numBlendTextures; ++i) { sh::MaterialInstanceTextureUnit* blendTex = p->createTextureUnit ("blendMap" + Ogre::StringConverter::toString(i)); blendTex->setProperty ("direct_texture", sh::makeProperty (new sh::StringValue(terrain->getBlendTextureName(i)))); @@ -102,7 +102,7 @@ namespace MWRender } // layer maps - for (uint i = 0; i < numLayers; ++i) + for (Ogre::uint i = 0; i < numLayers; ++i) { sh::MaterialInstanceTextureUnit* diffuseTex = p->createTextureUnit ("diffuseMap" + Ogre::StringConverter::toString(i)); diffuseTex->setProperty ("direct_texture", sh::makeProperty (new sh::StringValue(terrain->getLayerTextureName(i, 0)))); @@ -111,7 +111,7 @@ namespace MWRender } // shadow - for (uint i = 0; i < 3; ++i) + for (Ogre::uint i = 0; i < 3; ++i) { sh::MaterialInstanceTextureUnit* shadowTex = p->createTextureUnit ("shadowMap" + Ogre::StringConverter::toString(i)); shadowTex->setProperty ("content_type", sh::makeProperty (new sh::StringValue("shadow"))); From 7f802a22b5a68437709b473310c81d6055ff9784 Mon Sep 17 00:00:00 2001 From: Michael Mc Donnell Date: Wed, 1 Aug 2012 17:50:42 -0400 Subject: [PATCH 23/23] Compare with stream position instead of int. Fixes compilation of Debug build on Windows. --- components/bsa/bsa_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bsa/bsa_file.cpp b/components/bsa/bsa_file.cpp index 053191c9b8..1700e1aabb 100644 --- a/components/bsa/bsa_file.cpp +++ b/components/bsa/bsa_file.cpp @@ -200,7 +200,7 @@ void BSAFile::readHeader() input.read(&stringBuf[0], stringBuf.size()); // Check our position - assert(input.tellg() == static_cast (12+dirsize)); + assert(input.tellg() == std::streampos(12+dirsize)); // Calculate the offset of the data buffer. All file offsets are // relative to this. 12 header bytes + directory + hash table