From adf54cb735bc13d1363dbfd67a1b35a0477e6ba1 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 15 Jun 2013 13:54:24 +0400 Subject: [PATCH 1/5] SDL2 input: compilation fixed --- libs/openengine/ogre/renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 193e094bc..f27858a78 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -308,7 +308,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& // Windows code winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); break; -#elif MACOS +#elif __APPLE__ case SDL_SYSWM_COCOA: //required to make OGRE play nice with our window params.insert(std::make_pair("macAPI", "cocoa")); From 3fded2d8bf4c8f0e8eb78cc3487512acc0057ee0 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 15 Jun 2013 13:55:09 +0400 Subject: [PATCH 2/5] Removed custom Carbon message pump --- libs/openengine/ogre/renderer.cpp | 51 ------------------------------- libs/openengine/ogre/renderer.hpp | 21 ------------- 2 files changed, 72 deletions(-) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index f27858a78..c27d8871a 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -23,29 +23,9 @@ #include #include -#if defined(__APPLE__) && !defined(__LP64__) -#include -#endif - using namespace Ogre; using namespace OEngine::Render; - -#if defined(__APPLE__) && !defined(__LP64__) - -CustomRoot::CustomRoot(const Ogre::String& pluginFileName, - const Ogre::String& configFileName, - const Ogre::String& logFileName) -: Ogre::Root(pluginFileName, configFileName, logFileName) -{} - -bool CustomRoot::isQueuedEnd() const -{ - return mQueuedEnd; -} - -#endif - void OgreRenderer::cleanup() { delete mFader; @@ -68,34 +48,7 @@ void OgreRenderer::cleanup() void OgreRenderer::start() { - //TODO: Check if we still need to do this if we're using SDL's - //message pump -#if defined(__APPLE__) && !defined(__LP64__) - // OSX Carbon Message Pump - do { - EventRef event = NULL; - EventTargetRef targetWindow; - targetWindow = GetEventDispatcherTarget(); - - // If we are unable to get the target then we no longer care about events. - if (!targetWindow) return; - - // Grab the next event while possible - while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &event) == noErr) - { - // Dispatch the event - SendEventToEventTarget(event, targetWindow); - ReleaseEvent(event); - } - - if (!mRoot->renderOneFrame()) { - break; - } - - } while (!mRoot->isQueuedEnd()); -#else mRoot->startRendering(); -#endif } void OgreRenderer::loadPlugins() @@ -188,11 +141,7 @@ void OgreRenderer::configure(const std::string &logPath, // Disable logging log->setDebugOutputEnabled(false); -#if defined(__APPLE__) && !defined(__LP64__) - mRoot = new CustomRoot("", "", ""); -#else mRoot = new Root("", "", ""); -#endif #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) loadPlugins(); diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index 8b73675c3..0cd0e74e8 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -27,18 +27,12 @@ #include "OgreTexture.h" #include -#if defined(__APPLE__) && !defined(__LP64__) -#include -#endif - struct SDL_Window; struct SDL_Surface; namespace Ogre { -#if !defined(__APPLE__) || defined(__LP64__) class Root; -#endif class RenderWindow; class SceneManager; class Camera; @@ -60,26 +54,11 @@ namespace OEngine std::string icon; }; -#if defined(__APPLE__) && !defined(__LP64__) - class CustomRoot : public Ogre::Root { - public: - bool isQueuedEnd() const; - - CustomRoot(const Ogre::String& pluginFileName = "plugins.cfg", - const Ogre::String& configFileName = "ogre.cfg", - const Ogre::String& logFileName = "Ogre.log"); - }; -#endif - class Fader; class OgreRenderer { -#if defined(__APPLE__) && !defined(__LP64__) - CustomRoot *mRoot; -#else Ogre::Root *mRoot; -#endif Ogre::RenderWindow *mWindow; SDL_Window *mSDLWindow; SDL_Surface *mWindowIconSurface; From 6abb7a18b0ef96980a97528c13ada45dabaff470 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 15 Jun 2013 14:40:18 +0400 Subject: [PATCH 3/5] SDL2 input: seems to work on OS X, has some input issues though --- CMakeLists.txt | 5 +++++ libs/openengine/ogre/osx_utils.h | 14 ++++++++++++++ libs/openengine/ogre/osx_utils.mm | 16 ++++++++++++++++ libs/openengine/ogre/renderer.cpp | 8 ++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 libs/openengine/ogre/osx_utils.h create mode 100644 libs/openengine/ogre/osx_utils.mm diff --git a/CMakeLists.txt b/CMakeLists.txt index d33dde844..e8cfdcbdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,11 @@ set(OENGINE_OGRE ${LIBDIR}/openengine/ogre/selectionbuffer.cpp ${LIBDIR}/openengine/ogre/imagerotate.cpp ) + +if (APPLE) + set(OENGINE_OGRE ${OENGINE_OGRE} ${LIBDIR}/openengine/ogre/osx_utils.mm) +endif () + set(OENGINE_GUI ${LIBDIR}/openengine/gui/manager.cpp ) diff --git a/libs/openengine/ogre/osx_utils.h b/libs/openengine/ogre/osx_utils.h new file mode 100644 index 000000000..f651db604 --- /dev/null +++ b/libs/openengine/ogre/osx_utils.h @@ -0,0 +1,14 @@ +#ifndef OENGINE_OGRE_OSX_UTILS_H +#define OENGINE_OGRE_OSX_UTILS_H + +#include + +namespace OEngine { +namespace Render { + +extern unsigned long WindowContentViewHandle(SDL_SysWMinfo &info); + +} +} + +#endif diff --git a/libs/openengine/ogre/osx_utils.mm b/libs/openengine/ogre/osx_utils.mm new file mode 100644 index 000000000..7e5660146 --- /dev/null +++ b/libs/openengine/ogre/osx_utils.mm @@ -0,0 +1,16 @@ +#include "osx_utils.h" + +#import + +namespace OEngine { +namespace Render { + +unsigned long WindowContentViewHandle(SDL_SysWMinfo &info) +{ + NSWindow *window = info.info.cocoa.window; + NSView *view = [window contentView]; + return (unsigned long)view; +} + +} +} diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index c27d8871a..e3bba8bfa 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -23,6 +23,10 @@ #include #include +#ifdef __MACOSX__ +#include "osx_utils.h" +#endif + using namespace Ogre; using namespace OEngine::Render; @@ -257,13 +261,13 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& // Windows code winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); break; -#elif __APPLE__ +#elif __MACOSX__ case SDL_SYSWM_COCOA: //required to make OGRE play nice with our window params.insert(std::make_pair("macAPI", "cocoa")); params.insert(std::make_pair("macAPICocoaUseNSView", "true")); - winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.cocoa.window); + winHandle = Ogre::StringConverter::toString(WindowContentViewHandle(wmInfo)); break; #else case SDL_SYSWM_X11: From 5984a158462b0d7a7763629f6ec15fe428f75c40 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 15 Jun 2013 14:47:33 +0400 Subject: [PATCH 4/5] We don't need Carbon on OS X anymore --- apps/esmtool/CMakeLists.txt | 5 ----- apps/openmw/CMakeLists.txt | 3 +-- apps/openmw/mwinput/inputmanagerimp.cpp | 10 ---------- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 5c588fb29..1d0026215 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -17,11 +17,6 @@ target_link_libraries(esmtool components ) -#if (APPLE) -# find_library(CARBON_FRAMEWORK Carbon) -# target_link_libraries(openmw ${CARBON_FRAMEWORK}) -#endif (APPLE) - if (BUILD_WITH_CODE_COVERAGE) add_definitions (--coverage) target_link_libraries(esmtool gcov) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 47bebe78c..ddb08f0b0 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -131,10 +131,9 @@ endif() if(APPLE) - find_library(CARBON_FRAMEWORK Carbon) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) - target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) + target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) if (FFMPEG_FOUND) find_library(COREVIDEO_FRAMEWORK CoreVideo) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 203123d5b..669957c4c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1,9 +1,5 @@ #include "inputmanagerimp.hpp" -#if defined(__APPLE__) && !defined(__LP64__) -#include -#endif - #include #include @@ -56,12 +52,6 @@ namespace MWInput , mOverencumberedMessageDelay(0.f) , mAlwaysRunActive(false) { -#if defined(__APPLE__) && !defined(__LP64__) - // Give the application window focus to receive input events - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - SetFrontProcess(&psn); -#endif Ogre::RenderWindow* window = ogre.getWindow (); From 9807eacb5866966d64ae053c0f9b3d9eefbb680f Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 15 Jun 2013 15:17:29 +0400 Subject: [PATCH 5/5] Removed obsolete OIS workaround --- apps/openmw/mwinput/inputmanagerimp.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 669957c4c..6098ff90b 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -420,16 +420,6 @@ namespace MWInput MWBase::Environment::get().getWindowManager()->enterPressed(); } - //TODO: Check if we need this with SDL - /* -#ifdef __APPLE__ // filter \016 symbol for F-keys on OS X - if ((arg.key >= SDLK_F1 && arg.key <= SDLK_F10) || - (arg.key >= SDLK_F11 && arg.key <= SDLK_F15)) { - text = 0; - } -#endif - */ - OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), text);