diff --git a/CMakeLists.txt b/CMakeLists.txt index d33dde844f..e8cfdcbdf2 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 0000000000..f651db6046 --- /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 0000000000..7e56601461 --- /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 c27d8871a7..e3bba8bfa2 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: