From 99cfb8cda28217710369cda38bb18c0a51c3f3d7 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 13:48:23 +0400 Subject: [PATCH 1/9] OS X: this CMake parameters can be set in CMake invocation, no need to hardcode them in CMakeLists.txt --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6014dff6..2665ebdab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,6 @@ if (APPLE) set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app") set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}") - - set(CMAKE_EXE_LINKER_FLAGS "-F /Library/Frameworks") - set(CMAKE_SHARED_LINKER_FLAGS "-F /Library/Frameworks") - set(CMAKE_MODULE_LINKER_FLAGS "-F /Library/Frameworks") endif (APPLE) # Macros From 87853f406626310554210976bfb84301c643cf30 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 13:52:57 +0400 Subject: [PATCH 2/9] =?UTF-8?q?OS=20X:=20consider=20Ogre=20CG=20plugin=20a?= =?UTF-8?q?s=20used=20only=20if=20it=E2=80=99s=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2665ebdab..9f4523d4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,8 +246,12 @@ if (APPLE) # List used Ogre plugins SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL} ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} - ${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) + + if (OGRE_Plugin_CgProgramManager_FOUND) + set(USED_OGRE_PLUGINS ${USED_OGRE_PLUGINS} + ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}) + endif () if (${OGRE_PLUGIN_DIR_REL}}) set(OGRE_PLUGINS_REL_FOUND TRUE) From 89c60b065c1fa4ea7e728d250af1001383c7544d Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 14:19:48 +0400 Subject: [PATCH 3/9] OS X: looks like OGRE_Plugin_CgProgramManager_FOUND is not reliable --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f4523d4f..e1a591b27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,7 +248,9 @@ if (APPLE) ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) - if (OGRE_Plugin_CgProgramManager_FOUND) + # Actually we must use OGRE_Plugin_CgProgramManager_FOUND but it's + # not reliable and equals TRUE even if there's no Ogre Cg plugin + if (Cg_FOUND) set(USED_OGRE_PLUGINS ${USED_OGRE_PLUGINS} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}) endif () From 874ecee079d509b9d173a35c724a660b380f5642 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 14:20:13 +0400 Subject: [PATCH 4/9] OS X: do not enforce static boost, this can be set externally anyway --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a591b27..61c6f1f58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,10 +190,6 @@ if (MSVC10) set(PLATFORM_INCLUDE_DIR "") endif() -if (APPLE) - set(Boost_USE_STATIC_LIBS ON) -endif (APPLE) - # Dependencies # Fix for not visible pthreads functions for linker with glibc 2.15 From 73c6aba4d05370e6433c42ea4af534224e4e3377 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 12 Dec 2013 15:20:04 +0400 Subject: [PATCH 5/9] OS X: Ogre plugins are now installed in OpenCS bundle too. Generalized plugin install routine. --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61c6f1f58..f53d73813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -689,9 +689,9 @@ if (APPLE) set(OPENMW_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") - set(OPENCS_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/OpenCS.app") + set(OPENCS_BUNDLE_NAME "OpenCS.app") + set(OPENCS_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${OPENCS_BUNDLE_NAME}") - set(PLUGINS "") set(ABSOLUTE_PLUGINS "") foreach (PLUGIN ${USED_OGRE_PLUGINS}) @@ -699,12 +699,25 @@ if (APPLE) set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS}) endforeach () - set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins") - install(FILES ${ABSOLUTE_PLUGINS} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins" COMPONENT Runtime) - foreach (PLUGIN ${ABSOLUTE_PLUGINS}) - get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) - set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") - endforeach () + # installs used plugins in bundle at given path (bundle_path must be relative to ${CMAKE_INSTALL_PREFIX}) + # and returns list of install paths for all installed plugins + function (install_plugins_for_bundle bundle_path plugins_var) + set(RELATIVE_PLUGIN_INSTALL_BASE "${bundle_path}/Contents/Plugins") + install(FILES ${ABSOLUTE_PLUGINS} DESTINATION ${RELATIVE_PLUGIN_INSTALL_BASE} COMPONENT Runtime) + + set(PLUGINS "") + set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${RELATIVE_PLUGIN_INSTALL_BASE}") + + foreach (PLUGIN ${ABSOLUTE_PLUGINS}) + get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) + set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") + endforeach () + + set(${plugins_var} ${PLUGINS} PARENT_SCOPE) + endfunction (install_plugins_for_bundle) + + install_plugins_for_bundle("${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}" PLUGINS) + install_plugins_for_bundle("${INSTALL_SUBDIR}/${OPENCS_BUNDLE_NAME}" OPENCS_PLUGINS) #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail set(DIRS "") @@ -752,7 +765,7 @@ if (APPLE) set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"${OPENMW_APP}\" \"${PLUGINS}\" \"${DIRS}\") - fixup_bundle(\"${OPENCS_APP}\" \"\" \"${DIRS}\") + fixup_bundle(\"${OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime) include(CPack) endif (APPLE) From fc21dd1f3afc44ba13a3c868690964b6b636daf9 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 14 Dec 2013 17:21:20 +0400 Subject: [PATCH 6/9] Music playback on OS X >= 10.9 works again. Fixes bug #1041. --- apps/openmw/mwsound/openal_output.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 4ee754b35..868b4bdbd 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -316,8 +316,23 @@ void OpenAL_SoundStream::play() throwALerror(); mSamplesQueued = 0; - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); + int srate; + ChannelConfig chans; + SampleType sampleType; + + mDecoder->getInfo(&srate, &chans, &sampleType); + + // Use exactly one sample of silence. + // This is required for OpenAL implementations that don't accept empty buffer data. + // (like one in OS X 10.9) + ALuint sampleSize = framesToBytes(1, chans, sampleType); + std::vector silenceSample(sampleSize); + + if (sampleType == SampleType_UInt8) + std::fill(silenceSample.begin(), silenceSample.end(), 0x80); + + for(ALuint i = 0;i < sNumBuffers;i++) + alBufferData(mBuffers[i], mFormat, &silenceSample[0], sampleSize, mSampleRate); throwALerror(); alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); From 892ff93489fc21ab731e1fe5663f2db8c3babf03 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 24 Dec 2013 23:28:12 +0400 Subject: [PATCH 7/9] OS X: attempt to fix #1045 --- CMakeLists.txt | 3 ++- components/ogreinit/ogreinit.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f53d73813..04e75e94e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,8 @@ endif() add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}") add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}") if (APPLE AND OPENMW_OSX_DEPLOYMENT) - add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins") + # make it empty so plugin loading code can check this and try to find plugins inside app bundle + add_definitions(-DOGRE_PLUGIN_DIR="") else() add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}") endif() diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index c8fc621c7..46424a29a 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -6,6 +6,10 @@ #include #include +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include +#endif + #include #include "ogreplugin.hpp" @@ -127,6 +131,9 @@ namespace OgreInit #endif #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE pluginDir = OGRE_PLUGIN_DIR; + // if path is not specified try to find plugins inside the app bundle + if (pluginDir.empty()) + pluginDir = Ogre::macPluginPath(); #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX pluginDir = OGRE_PLUGIN_DIR_REL; From 9fabae51981ca43eca252336ab9d3bdcf5ef8190 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 24 Dec 2013 23:59:59 +0400 Subject: [PATCH 8/9] OS X: force Cocoa API for Ogre windows in OpenCS --- apps/opencs/editor.cpp | 3 +++ apps/opencs/view/render/scenewidget.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1c1e37c2d..a1de75053 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -225,6 +225,9 @@ int CS::Editor::run() params.insert(std::make_pair("FSAA", "0")); params.insert(std::make_pair("vsync", "false")); params.insert(std::make_pair("hidden", "true")); +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + params.insert(std::make_pair("macAPI", "cocoa")); +#endif Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index c8b37e9bb..8cbfc72c6 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -66,6 +66,10 @@ namespace CSVRender params.insert(std::make_pair("title", windowTitle.str())); params.insert(std::make_pair("FSAA", "0")); // TODO setting params.insert(std::make_pair("vsync", "false")); // TODO setting +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + params.insert(std::make_pair("macAPI", "cocoa")); + params.insert(std::make_pair("macAPICocoaUseNSView", "true")); +#endif mWindow = Ogre::Root::getSingleton().createRenderWindow(windowTitle.str(), this->width(), this->height(), false, ¶ms); mWindow->addViewport(mCamera)->setBackgroundColour(Ogre::ColourValue(0.3,0.3,0.3,1)); From bc90443aeb0b98e18787918e3f289af84b9e39d0 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 8 Jan 2014 18:07:58 +0400 Subject: [PATCH 9/9] Revert "Music playback on OS X >= 10.9 works again. Fixes bug #1041." This reverts commit fc21dd1f3afc44ba13a3c868690964b6b636daf9. --- apps/openmw/mwsound/openal_output.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 868b4bdbd..4ee754b35 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -316,23 +316,8 @@ void OpenAL_SoundStream::play() throwALerror(); mSamplesQueued = 0; - int srate; - ChannelConfig chans; - SampleType sampleType; - - mDecoder->getInfo(&srate, &chans, &sampleType); - - // Use exactly one sample of silence. - // This is required for OpenAL implementations that don't accept empty buffer data. - // (like one in OS X 10.9) - ALuint sampleSize = framesToBytes(1, chans, sampleType); - std::vector silenceSample(sampleSize); - - if (sampleType == SampleType_UInt8) - std::fill(silenceSample.begin(), silenceSample.end(), 0x80); - - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, &silenceSample[0], sampleSize, mSampleRate); + for(ALuint i = 0;i < sNumBuffers;i++) + alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); throwALerror(); alSourceQueueBuffers(mSource, sNumBuffers, mBuffers);