mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 21:11:39 +00:00
Changed: #947 adds very basic mac cocoa support (cmake -DWITH_COCOA:bool=YES)
This commit is contained in:
parent
622a0d6cb2
commit
7eff40e417
24 changed files with 11233 additions and 73 deletions
|
@ -92,13 +92,17 @@ IF(WITH_3D)
|
||||||
IF(WITH_DRIVER_OPENGL)
|
IF(WITH_DRIVER_OPENGL)
|
||||||
FIND_PACKAGE(OpenGL)
|
FIND_PACKAGE(OpenGL)
|
||||||
IF(NOT WIN32)
|
IF(NOT WIN32)
|
||||||
FIND_PACKAGE(X11)
|
IF(APPLE)
|
||||||
FIND_PACKAGE(XF86VidMode)
|
FIND_LIBRARY(CARBON NAMES Carbon)
|
||||||
|
IF(WITH_COCOA)
|
||||||
|
FIND_LIBRARY(COCOA NAMES Cocoa)
|
||||||
|
ENDIF(WITH_COCOA)
|
||||||
|
ENDIF(APPLE)
|
||||||
|
IF(NOT WITH_COCOA)
|
||||||
|
FIND_PACKAGE(X11)
|
||||||
|
FIND_PACKAGE(XF86VidMode)
|
||||||
|
ENDIF(NOT WITH_COCOA)
|
||||||
ENDIF(NOT WIN32)
|
ENDIF(NOT WIN32)
|
||||||
IF(APPLE)
|
|
||||||
# TODO: remove Carbon as soon as Cocoa Support is stable on Mac
|
|
||||||
FIND_LIBRARY(CARBON NAMES Carbon)
|
|
||||||
ENDIF(APPLE)
|
|
||||||
ENDIF(WITH_DRIVER_OPENGL)
|
ENDIF(WITH_DRIVER_OPENGL)
|
||||||
|
|
||||||
IF(WITH_CEGUI)
|
IF(WITH_CEGUI)
|
||||||
|
|
|
@ -79,6 +79,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
|
||||||
OPTION(WITH_TESTS "Build NeL Unit Tests" ON )
|
OPTION(WITH_TESTS "Build NeL Unit Tests" ON )
|
||||||
OPTION(WITH_GTK "With GTK Support" OFF)
|
OPTION(WITH_GTK "With GTK Support" OFF)
|
||||||
OPTION(WITH_QT "With QT Support" OFF)
|
OPTION(WITH_QT "With QT Support" OFF)
|
||||||
|
OPTION(WITH_COCOA "Build with native Mac OS X Cocoa support" OFF)
|
||||||
OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF)
|
OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF)
|
||||||
ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
|
ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
|
||||||
|
|
||||||
|
@ -128,6 +129,9 @@ MACRO(NL_SETUP_BUILD)
|
||||||
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -O6")
|
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -O6")
|
||||||
SET(NL_RELEASEDEBUG_CFLAGS "-DNL_RELEASE_DEBUG -g -finline-functions -O3 ")
|
SET(NL_RELEASEDEBUG_CFLAGS "-DNL_RELEASE_DEBUG -g -finline-functions -O3 ")
|
||||||
SET(NL_NONE_CFLAGS "-DNL_RELEASE -g -finline-functions -O2 ")
|
SET(NL_NONE_CFLAGS "-DNL_RELEASE -g -finline-functions -O2 ")
|
||||||
|
IF(WITH_COCOA)
|
||||||
|
SET(PLATFORM_CFLAGS "-DNL_MAC_NATIVE")
|
||||||
|
ENDIF(WITH_COCOA)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
# Determine host CPU
|
# Determine host CPU
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
FILE(GLOB SRC *.cpp *.h *.def)
|
FILE(GLOB SRC *.cpp *.h *.def)
|
||||||
|
IF(WITH_COCOA)
|
||||||
|
FILE(GLOB MAC_SRC mac/*.h mac/*.m mac/*.mm mac/*.cpp)
|
||||||
|
SET(SRC ${SRC} ${MAC_SRC})
|
||||||
|
ENDIF(WITH_COCOA)
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(NLDRV_OGL_LIB "nel_drv_opengl_win")
|
SET(NLDRV_OGL_LIB "nel_drv_opengl_win")
|
||||||
|
@ -25,19 +29,24 @@ IF(WIN32)
|
||||||
LINK_FLAGS "/NODEFAULTLIB:libcmt")
|
LINK_FLAGS "/NODEFAULTLIB:libcmt")
|
||||||
ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS)
|
ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS)
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
# NOTE: I know, those hardcoded things are evil. But FindOpenGL on Mac simply
|
|
||||||
# does not look for X11's OpenGL, just for the native one.
|
|
||||||
# TODO: FIXME remove as soon as Cocoa Support is stable on Mac
|
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
INCLUDE_DIRECTORIES("/usr/X11/include")
|
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${CARBON})
|
||||||
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${CARBON} "-L/usr/X11/lib" "-lGL")
|
IF(WITH_COCOA)
|
||||||
|
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${COCOA})
|
||||||
|
ELSE(WITH_COCOA)
|
||||||
|
# NOTE: I know, those hardcoded things are evil. But FindOpenGL on Mac
|
||||||
|
# simply does not look for X11's OpenGL, just for the native one.
|
||||||
|
INCLUDE_DIRECTORIES("/usr/X11/include")
|
||||||
|
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} "-L/usr/X11/lib" "-lGL")
|
||||||
|
ENDIF(WITH_COCOA)
|
||||||
|
ELSE(APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_LIBRARIES})
|
||||||
|
IF(XF86VidMode_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR})
|
||||||
|
ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS})
|
||||||
|
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY})
|
||||||
|
ENDIF(XF86VidMode_FOUND)
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_LIBRARIES})
|
|
||||||
IF(XF86VidMode_FOUND)
|
|
||||||
INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS})
|
|
||||||
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY})
|
|
||||||
ENDIF(XF86VidMode_FOUND)
|
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
|
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
|
||||||
|
|
|
@ -27,12 +27,18 @@
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <windowsx.h>
|
# include <windowsx.h>
|
||||||
# include <string>
|
# include <string>
|
||||||
#else // NL_OS_UNIX
|
# include <GL/gl.h>
|
||||||
# include <GL/glx.h>
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# define GL_GLEXT_LEGACY
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# include "mac/glext.h"
|
||||||
|
# include "mac/cocoa_adapter.h"
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
# include <GL/gl.h>
|
||||||
|
# include <GL/glx.h>
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include "nel/3d/viewport.h"
|
#include "nel/3d/viewport.h"
|
||||||
#include "nel/3d/scissor.h"
|
#include "nel/3d/scissor.h"
|
||||||
|
@ -282,15 +288,18 @@ CDriverGL::CDriverGL()
|
||||||
_hDC = NULL;
|
_hDC = NULL;
|
||||||
_NeedToRestaureGammaRamp = false;
|
_NeedToRestaureGammaRamp = false;
|
||||||
_Interval = 1;
|
_Interval = 1;
|
||||||
#elif defined (NL_OS_UNIX) // NL_OS_WINDOWS
|
|
||||||
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
NL3D::MAC::ctor();
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
cursor = None;
|
cursor = None;
|
||||||
|
|
||||||
#ifdef XF86VIDMODE
|
# ifdef XF86VIDMODE
|
||||||
// zero the old screen mode
|
// zero the old screen mode
|
||||||
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
|
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
|
||||||
#endif //XF86VIDMODE
|
|
||||||
|
|
||||||
|
# endif //XF86VIDMODE
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
||||||
_FullScreen= false;
|
_FullScreen= false;
|
||||||
|
@ -412,6 +421,10 @@ CDriverGL::~CDriverGL()
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGL_CDriverGLDtor)
|
H_AUTO_OGL(CDriverGL_CDriverGLDtor)
|
||||||
release();
|
release();
|
||||||
|
|
||||||
|
#if defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
NL3D::MAC::dtor();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -460,7 +473,11 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc)
|
||||||
|
|
||||||
// ati specific : try to retrieve driver version
|
// ati specific : try to retrieve driver version
|
||||||
retrieveATIDriverVersion();
|
retrieveATIDriverVersion();
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
|
||||||
|
return NL3D::MAC::init(windowIcon, exitFunc);
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
dpy = XOpenDisplay(NULL);
|
dpy = XOpenDisplay(NULL);
|
||||||
if (dpy == NULL)
|
if (dpy == NULL)
|
||||||
|
@ -1024,7 +1041,11 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
|
||||||
nlinfo(e.what());
|
nlinfo(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
|
||||||
|
NL3D::MAC::setDisplay(wnd, mode, show, resizeable);
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
static int sAttribList16bpp[] =
|
static int sAttribList16bpp[] =
|
||||||
{
|
{
|
||||||
|
@ -1611,7 +1632,11 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
||||||
_WindowX = clientRect.left;
|
_WindowX = clientRect.left;
|
||||||
_WindowY = clientRect.top;
|
_WindowY = clientRect.top;
|
||||||
_FullScreen = !mode.Windowed;
|
_FullScreen = !mode.Windowed;
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
// TODO linux version !!!
|
// TODO linux version !!!
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -1643,7 +1668,11 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
|
||||||
}
|
}
|
||||||
#elif defined(NL_OS_MAC)
|
#elif defined(NL_OS_MAC)
|
||||||
getMacModes(modes);
|
getMacModes(modes);
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
# ifdef XF86VIDMODE
|
# ifdef XF86VIDMODE
|
||||||
int nmodes;
|
int nmodes;
|
||||||
|
@ -1691,8 +1720,13 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
|
||||||
mode.Frequency= devmode.dmDisplayFrequency,
|
mode.Frequency= devmode.dmDisplayFrequency,
|
||||||
mode.Width= (uint16)devmode.dmPelsWidth;
|
mode.Width= (uint16)devmode.dmPelsWidth;
|
||||||
mode.Height= (uint16)devmode.dmPelsHeight;
|
mode.Height= (uint16)devmode.dmPelsHeight;
|
||||||
#elif defined(NL_OS_MAC)
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Temporary Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Temporary Mac Implementation");
|
||||||
|
mode.Depth = 24;
|
||||||
|
|
||||||
|
#elif defined(NL_OS_MAC)
|
||||||
/*
|
/*
|
||||||
TODO this is just a hack to get the ryzom client running on mac os x x11.
|
TODO this is just a hack to get the ryzom client running on mac os x x11.
|
||||||
the implementation below relies on the vidmode extension which is not
|
the implementation below relies on the vidmode extension which is not
|
||||||
|
@ -1734,7 +1768,12 @@ void CDriverGL::setWindowTitle(const ucstring &title)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
SetWindowTextW(_hWnd,(WCHAR*)title.c_str());
|
SetWindowTextW(_hWnd,(WCHAR*)title.c_str());
|
||||||
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
XTextProperty text_property;
|
XTextProperty text_property;
|
||||||
char *t = (char*)title.toUtf8().c_str();
|
char *t = (char*)title.toUtf8().c_str();
|
||||||
XStringListToTextProperty(&t, 1, &text_property);
|
XStringListToTextProperty(&t, 1, &text_property);
|
||||||
|
@ -1749,7 +1788,12 @@ void CDriverGL::setWindowPos(uint32 x, uint32 y)
|
||||||
_WindowY = (sint32)y;
|
_WindowY = (sint32)y;
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
SetWindowPos(_hWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
|
SetWindowPos(_hWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
|
||||||
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
XMoveWindow(dpy, win, _WindowX, _WindowY);
|
XMoveWindow(dpy, win, _WindowX, _WindowY);
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
@ -1759,7 +1803,11 @@ void CDriverGL::showWindow(bool show)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
ShowWindow (_hWnd, show ? SW_SHOW:SW_HIDE);
|
ShowWindow (_hWnd, show ? SW_SHOW:SW_HIDE);
|
||||||
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
if (show)
|
if (show)
|
||||||
XMapWindow(dpy, win);
|
XMapWindow(dpy, win);
|
||||||
else
|
else
|
||||||
|
@ -1822,6 +1870,12 @@ bool CDriverGL::activate()
|
||||||
{
|
{
|
||||||
wglMakeCurrent(_hDC,_hRC);
|
wglMakeCurrent(_hDC,_hRC);
|
||||||
}
|
}
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Temporary Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Temporary Mac Implementation");
|
||||||
|
|
||||||
|
// already done in setDisplay, not needed here - unclean! FIXME
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
GLXContext nctx=glXGetCurrentContext();
|
GLXContext nctx=glXGetCurrentContext();
|
||||||
if (nctx != NULL && nctx!=ctx)
|
if (nctx != NULL && nctx!=ctx)
|
||||||
|
@ -1985,8 +2039,13 @@ bool CDriverGL::swapBuffers()
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
SwapBuffers(_hDC);
|
SwapBuffers(_hDC);
|
||||||
#else // NL_OS_WINDOWS
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
NL3D::MAC::swapBuffers();
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
glXSwapBuffers(dpy, win);
|
glXSwapBuffers(dpy, win);
|
||||||
|
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
// Activate the default texture environnments for all stages.
|
// Activate the default texture environnments for all stages.
|
||||||
|
@ -2128,7 +2187,11 @@ bool CDriverGL::release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)// NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
#ifdef XF86VIDMODE
|
#ifdef XF86VIDMODE
|
||||||
if(_FullScreen)
|
if(_FullScreen)
|
||||||
|
@ -2225,7 +2288,14 @@ void CDriverGL::setupViewport (const class CViewport& viewport)
|
||||||
int clientWidth = _WindowWidth;
|
int clientWidth = _WindowWidth;
|
||||||
int clientHeight = _WindowHeight;
|
int clientHeight = _WindowHeight;
|
||||||
|
|
||||||
#else // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Temporary Mac Implementation"
|
||||||
|
// nlwarning("OpenGL Driver: Temporary Mac Implementation");
|
||||||
|
|
||||||
|
int clientWidth = 1024;
|
||||||
|
int clientHeight = 768;
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
XWindowAttributes win_attributes;
|
XWindowAttributes win_attributes;
|
||||||
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
||||||
|
@ -2297,7 +2367,14 @@ void CDriverGL::setupScissor (const class CScissor& scissor)
|
||||||
int clientWidth = _WindowWidth;
|
int clientWidth = _WindowWidth;
|
||||||
int clientHeight = _WindowHeight;
|
int clientHeight = _WindowHeight;
|
||||||
|
|
||||||
#else // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
// nlwarning("OpenGL Driver: Temporary Mac Implementation");
|
||||||
|
|
||||||
|
int clientWidth = 1024;
|
||||||
|
int clientHeight = 768;
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
XWindowAttributes win_attributes;
|
XWindowAttributes win_attributes;
|
||||||
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
||||||
|
@ -2383,6 +2460,10 @@ void CDriverGL::showCursor(bool b)
|
||||||
while (ShowCursor(b) >= 0)
|
while (ShowCursor(b) >= 0)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
|
@ -2427,6 +2508,10 @@ void CDriverGL::setMousePos(float x, float y)
|
||||||
ClientToScreen (_hWnd, &pt);
|
ClientToScreen (_hWnd, &pt);
|
||||||
SetCursorPos(pt.x, pt.y);
|
SetCursorPos(pt.x, pt.y);
|
||||||
}
|
}
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
XWindowAttributes xwa;
|
XWindowAttributes xwa;
|
||||||
XGetWindowAttributes (dpy, win, &xwa);
|
XGetWindowAttributes (dpy, win, &xwa);
|
||||||
|
@ -2458,6 +2543,13 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
|
||||||
height = (uint32)(_WindowHeight);
|
height = (uint32)(_WindowHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Temporary Mac Implementation"
|
||||||
|
// nlwarning("OpenGL Driver: Temporary Mac Implementation");
|
||||||
|
|
||||||
|
width = 1024;
|
||||||
|
height = 768;
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
XWindowAttributes xwa;
|
XWindowAttributes xwa;
|
||||||
XGetWindowAttributes (dpy, win, &xwa);
|
XGetWindowAttributes (dpy, win, &xwa);
|
||||||
|
@ -2486,6 +2578,10 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y)
|
||||||
y = (uint32)(_WindowY);
|
y = (uint32)(_WindowY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
@ -2500,9 +2596,14 @@ bool CDriverGL::isActive()
|
||||||
H_AUTO_OGL(CDriverGL_isActive)
|
H_AUTO_OGL(CDriverGL_isActive)
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return (IsWindow(_hWnd) != 0);
|
return (IsWindow(_hWnd) != 0);
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
// nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
return true;
|
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 CDriverGL::getBitPerPixel ()
|
uint8 CDriverGL::getBitPerPixel ()
|
||||||
|
@ -2562,8 +2663,16 @@ void CDriverGL::setCapture (bool b)
|
||||||
ReleaseCapture ();
|
ReleaseCapture ();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO x11 funtion: setCapture
|
||||||
|
*/
|
||||||
|
|
||||||
if(b) // capture the cursor.
|
if(b) // capture the cursor.
|
||||||
{
|
{
|
||||||
XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
|
XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
|
||||||
|
@ -3008,9 +3117,14 @@ NLMISC::IMouseDevice *CDriverGL::enableLowLevelMouse(bool enable, bool exclusive
|
||||||
diee->releaseMouse();
|
diee->releaseMouse();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
return NULL;
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -3037,9 +3151,14 @@ NLMISC::IKeyboardDevice *CDriverGL::enableLowLevelKeyboard(bool enable)
|
||||||
diee->releaseKeyboard();
|
diee->releaseKeyboard();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
return NULL;
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -3050,9 +3169,14 @@ NLMISC::IInputDeviceManager *CDriverGL::getLowLevelInputDeviceManager()
|
||||||
if (_EventEmitter.getNumEmitters() < 2) return NULL;
|
if (_EventEmitter.getNumEmitters() < 2) return NULL;
|
||||||
NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1));
|
NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1));
|
||||||
return diee;
|
return diee;
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
return NULL;
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -3083,7 +3207,11 @@ uint CDriverGL::getDoubleClickDelay(bool hardwareMouse)
|
||||||
}
|
}
|
||||||
// try to read the good value from windows
|
// try to read the good value from windows
|
||||||
return ::GetDoubleClickTime();
|
return ::GetDoubleClickTime();
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
// TODO for Linux FIXME: FAKE FIX
|
// TODO for Linux FIXME: FAKE FIX
|
||||||
return 250;
|
return 250;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3190,7 +3318,11 @@ bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &prop
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
// TODO for Linux: implement CDriverGL::setMonitorColorProperties
|
// TODO for Linux: implement CDriverGL::setMonitorColorProperties
|
||||||
nlwarning ("CDriverGL::setMonitorColorProperties not implemented");
|
nlwarning ("CDriverGL::setMonitorColorProperties not implemented");
|
||||||
|
@ -3956,9 +4088,13 @@ void CDriverGL::retrieveATIDriverVersion()
|
||||||
}
|
}
|
||||||
RegCloseKey(parentKey);
|
RegCloseKey(parentKey);
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
// TODO for Linux: implement retrieveATIDriverVersion... assuming versions under linux are probably different
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
#endif
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
|
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
// TODO for Linux: implement retrieveATIDriverVersion... assuming versions under linux are probably different
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#ifndef NL_DRIVER_OPENGL_H
|
#ifndef NL_DRIVER_OPENGL_H
|
||||||
#define NL_DRIVER_OPENGL_H
|
#define NL_DRIVER_OPENGL_H
|
||||||
|
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
|
|
||||||
//#define NL_PROFILE_DRIVER_OGL
|
//#define NL_PROFILE_DRIVER_OGL
|
||||||
|
@ -31,16 +30,19 @@
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# define NOMINMAX
|
# define NOMINMAX
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#else // NL_OS_UNIX
|
# include <GL/gl.h>
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# define GL_GLEXT_LEGACY
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
# define GLX_GLXEXT_PROTOTYPES
|
# define GLX_GLXEXT_PROTOTYPES
|
||||||
|
# include <GL/gl.h>
|
||||||
# include <GL/glx.h>
|
# include <GL/glx.h>
|
||||||
# ifdef XF86VIDMODE
|
# ifdef XF86VIDMODE
|
||||||
# include <X11/extensions/xf86vmode.h>
|
# include <X11/extensions/xf86vmode.h>
|
||||||
# endif //XF86VIDMODE
|
# endif //XF86VIDMODE
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include "driver_opengl_extension.h"
|
#include "driver_opengl_extension.h"
|
||||||
|
|
||||||
#include "nel/3d/driver.h"
|
#include "nel/3d/driver.h"
|
||||||
|
@ -68,6 +70,8 @@
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
#include "nel/misc/win_event_emitter.h"
|
#include "nel/misc/win_event_emitter.h"
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
#include "mac/cocoa_event_emitter.h"
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
#include "unix_event_emitter.h"
|
#include "unix_event_emitter.h"
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
@ -303,7 +307,9 @@ public:
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return _hWnd;
|
return _hWnd;
|
||||||
#else // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
return NULL;
|
||||||
|
#elif defined(NL_OS_UNIX)
|
||||||
return win;
|
return win;
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
@ -673,6 +679,9 @@ private:
|
||||||
// Off-screen rendering in Dib section
|
// Off-screen rendering in Dib section
|
||||||
HPBUFFERARB _PBuffer;
|
HPBUFFERARB _PBuffer;
|
||||||
|
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
NLMISC::CCocoaEventEmitter _EventEmitter;
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void *nglGetProcAddress(const char *name)
|
||||||
free (symbolName);
|
free (symbolName);
|
||||||
return symbol ? NSAddressOfSymbol (symbol) : NULL;
|
return symbol ? NSAddressOfSymbol (symbol) : NULL;
|
||||||
}
|
}
|
||||||
#else // NL_OS_WINDOWS
|
#elif defined (NL_OS_UNIX)
|
||||||
void (*nglGetProcAddress(const char *procName))()
|
void (*nglGetProcAddress(const char *procName))()
|
||||||
{
|
{
|
||||||
return glXGetProcAddressARB((const GLubyte *)procName);
|
return glXGetProcAddressARB((const GLubyte *)procName);
|
||||||
|
|
|
@ -24,13 +24,18 @@
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# define NOMINMAX
|
# define NOMINMAX
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#else // NL_OS_UNIX
|
# include <GL/gl.h>
|
||||||
|
# include <GL/glext.h> // Please download it from http://www.opengl.org/registry/
|
||||||
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
|
# define GL_GLEXT_LEGACY
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# include "mac/glext.h"
|
||||||
|
#elif defined (NL_OS_UNIX)
|
||||||
|
# include <GL/gl.h>
|
||||||
|
# include <GL/glext.h> // Please download it from http://www.opengl.org/registry/
|
||||||
# include <GL/glx.h>
|
# include <GL/glx.h>
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glext.h> // Please download it from http://www.opengl.org/registry/
|
|
||||||
|
|
||||||
#ifndef GL_GLEXT_VERSION
|
#ifndef GL_GLEXT_VERSION
|
||||||
# error "I need a newer <GL/glext.h>. Please download it from http://www.opengl.org/registry/"
|
# error "I need a newer <GL/glext.h>. Please download it from http://www.opengl.org/registry/"
|
||||||
#endif // GL_nGLEXT_VERSION
|
#endif // GL_nGLEXT_VERSION
|
||||||
|
|
|
@ -20,8 +20,14 @@
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#ifdef NL_MAC_NATIVE
|
||||||
#include <GL/glext.h> // Please download it from http://www.opengl.org/registry/
|
# define GL_GLEXT_LEGACY
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# include "mac/glext.h"
|
||||||
|
#else
|
||||||
|
# include <GL/gl.h>
|
||||||
|
# include <GL/glext.h> // Please download it from http://www.opengl.org/registry/
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -19,7 +19,13 @@
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/3d/vertex_buffer.h"
|
#include "nel/3d/vertex_buffer.h"
|
||||||
#include <GL/gl.h>
|
|
||||||
|
#ifdef NL_MAC_NATIVE
|
||||||
|
# define GL_GLEXT_LEGACY
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
#else
|
||||||
|
# include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace NL3D
|
namespace NL3D
|
||||||
|
|
|
@ -1966,14 +1966,18 @@ bool CDriverGL::getRenderTargetSize (uint32 &width, uint32 &height)
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
width = _WindowWidth;
|
width = _WindowWidth;
|
||||||
height = _WindowHeight;
|
height = _WindowHeight;
|
||||||
#else // NL_OS_WINDOWS
|
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
|
||||||
XWindowAttributes win_attributes;
|
# warning "OpenGL Driver: Missing Mac Implementation"
|
||||||
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
nlwarning("OpenGL Driver: Missing Mac Implementation");
|
||||||
throw EBadDisplay("Can't get window attributes.");
|
|
||||||
|
|
||||||
// Setup gl viewport
|
#elif defined (NL_OS_UNIX)
|
||||||
width = win_attributes.width;
|
XWindowAttributes win_attributes;
|
||||||
height = win_attributes.height;
|
if (!XGetWindowAttributes(dpy, win, &win_attributes))
|
||||||
|
throw EBadDisplay("Can't get window attributes.");
|
||||||
|
|
||||||
|
// Setup gl viewport
|
||||||
|
width = win_attributes.width;
|
||||||
|
height = win_attributes.height;
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
62
code/nel/src/3d/driver/opengl/mac/cocoa_adapter.h
Normal file
62
code/nel/src/3d/driver/opengl/mac/cocoa_adapter.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NL_DRIVER_OPENGL_MAC_COCOA_ADAPTER_H
|
||||||
|
#define NL_DRIVER_OPENGL_MAC_COCOA_ADAPTER_H
|
||||||
|
|
||||||
|
#include "nel/misc/types_nl.h"
|
||||||
|
#include "nel/misc/event_server.h"
|
||||||
|
#include "nel/3d/driver.h"
|
||||||
|
|
||||||
|
#include "cocoa_event_emitter.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this cocoa adapter is a helper to call functions executing obj-c code
|
||||||
|
* from driver_opengl.cpp
|
||||||
|
*
|
||||||
|
* please see this as a temporary solution... there is some stuff concerning
|
||||||
|
* driver refactoring going on anyway as far as i know
|
||||||
|
*
|
||||||
|
* this can as well be seen as a preparation to pull platform specific code
|
||||||
|
* out of driver_opengl.cpp ;)
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace NL3D { namespace MAC {
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CDriverGL::CDriverGL()
|
||||||
|
void ctor();
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CDriverGL::~CDriverGL()
|
||||||
|
void dtor();
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CDriverGL::init()
|
||||||
|
bool init(uint windowIcon = 0, emptyProc exitFunc = 0);
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CDriverGL::setDisplay()
|
||||||
|
bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable);
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CDriverGL::swapBuffers()
|
||||||
|
void swapBuffers();
|
||||||
|
|
||||||
|
/// mac specific stuff todo while calling CCocoaEventEmitter::submitEvents()
|
||||||
|
void submitEvents(NLMISC::CEventServer& server,
|
||||||
|
bool allWindows, NLMISC::CCocoaEventEmitter* eventEmitter);
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif
|
388
code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm
Normal file
388
code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm
Normal file
|
@ -0,0 +1,388 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cocoa_adapter.h"
|
||||||
|
|
||||||
|
#include "nel/misc/events.h"
|
||||||
|
#include "nel/3d/driver.h"
|
||||||
|
|
||||||
|
#include "cocoa_event_emitter.h"
|
||||||
|
#include "cocoa_opengl_view.h"
|
||||||
|
#include "cocoa_window.h"
|
||||||
|
|
||||||
|
// virtual key codes are only defined here. we still do not need to link carbon
|
||||||
|
// see: http://lists.apple.com/archives/Cocoa-dev/2009/May/msg01180.html
|
||||||
|
#include <Carbon/Carbon.h>
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
namespace NL3D { namespace MAC {
|
||||||
|
|
||||||
|
static NSApplication* g_app = 0;
|
||||||
|
static NSAutoreleasePool* g_pool = 0;
|
||||||
|
static CocoaWindow* g_window = 0;
|
||||||
|
static CocoaOpenGLView* g_glview = 0;
|
||||||
|
static NSOpenGLContext* g_glctx = 0;
|
||||||
|
|
||||||
|
void ctor()
|
||||||
|
{
|
||||||
|
nldebug("mac cpp bridge called");
|
||||||
|
|
||||||
|
// create a pool, cocoa code would leak memory otherwise
|
||||||
|
g_pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
// init the application object
|
||||||
|
g_app = [NSApplication sharedApplication];
|
||||||
|
}
|
||||||
|
|
||||||
|
void dtor()
|
||||||
|
{
|
||||||
|
nldebug("mac cpp bridge called");
|
||||||
|
|
||||||
|
// release the pool
|
||||||
|
[g_pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool init(uint windowIcon, emptyProc exitFunc)
|
||||||
|
{
|
||||||
|
nldebug("mac cpp bridge called with %u %u", windowIcon, exitFunc);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable)
|
||||||
|
{
|
||||||
|
nldebug("mac cpp bridge called with %u %u %u %u", wnd, &mode, show, resizeable);
|
||||||
|
|
||||||
|
// create a window
|
||||||
|
g_window = [[CocoaWindow alloc] initWithContentRect:NSMakeRect(10, 10, 1024, 768)
|
||||||
|
styleMask:NSTitledWindowMask | NSResizableWindowMask |
|
||||||
|
NSClosableWindowMask | NSMiniaturizableWindowMask
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:NO];
|
||||||
|
|
||||||
|
// setup opengl settings
|
||||||
|
NSOpenGLPixelFormatAttribute att[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAColorSize, 24,
|
||||||
|
NSOpenGLPFAAlphaSize, 8,
|
||||||
|
NSOpenGLPFADepthSize, 24,
|
||||||
|
NSOpenGLPFANoRecovery,
|
||||||
|
NSOpenGLPFAAccelerated,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
// put the settings into a format object
|
||||||
|
NSOpenGLPixelFormat* format =
|
||||||
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:att];
|
||||||
|
|
||||||
|
// create a opengl view with the created format
|
||||||
|
g_glview = [[CocoaOpenGLView alloc]
|
||||||
|
initWithFrame:NSMakeRect(0, 0, 1024, 768) pixelFormat: format];
|
||||||
|
|
||||||
|
// create a opengl context for the view
|
||||||
|
g_glctx = [g_glview openGLContext];
|
||||||
|
|
||||||
|
// setup some stuff in the window
|
||||||
|
[g_window setTitle:@"NeL Cocoa Test"];
|
||||||
|
[g_window setContentView:g_glview];
|
||||||
|
[g_window makeKeyAndOrderFront:nil];
|
||||||
|
[g_window setAcceptsMouseMovedEvents:YES];
|
||||||
|
|
||||||
|
// make the views opengl context the currrent one
|
||||||
|
[g_glctx makeCurrentContext];
|
||||||
|
|
||||||
|
// tell the application that we are running now
|
||||||
|
[g_app finishLaunching];
|
||||||
|
|
||||||
|
// free the pixel format object
|
||||||
|
[format release];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swapBuffers()
|
||||||
|
{
|
||||||
|
[g_glctx flushBuffer];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: this function has to be moved to a more central place to handle key
|
||||||
|
mapping on mac x11 as well
|
||||||
|
*/
|
||||||
|
NLMISC::TKey virtualKeycodeToNelKey(unsigned short keycode)
|
||||||
|
{
|
||||||
|
switch(keycode)
|
||||||
|
{
|
||||||
|
case kVK_ANSI_0: return NLMISC::Key0;
|
||||||
|
case kVK_ANSI_1: return NLMISC::Key1;
|
||||||
|
case kVK_ANSI_2: return NLMISC::Key2;
|
||||||
|
case kVK_ANSI_3: return NLMISC::Key3;
|
||||||
|
case kVK_ANSI_4: return NLMISC::Key4;
|
||||||
|
case kVK_ANSI_5: return NLMISC::Key6;
|
||||||
|
case kVK_ANSI_6: return NLMISC::Key5;
|
||||||
|
case kVK_ANSI_7: return NLMISC::Key7;
|
||||||
|
case kVK_ANSI_8: return NLMISC::Key8;
|
||||||
|
case kVK_ANSI_9: return NLMISC::Key9;
|
||||||
|
case kVK_ANSI_A: return NLMISC::KeyA;
|
||||||
|
case kVK_ANSI_B: return NLMISC::KeyB;
|
||||||
|
case kVK_ANSI_C: return NLMISC::KeyC;
|
||||||
|
case kVK_ANSI_D: return NLMISC::KeyD;
|
||||||
|
case kVK_ANSI_E: return NLMISC::KeyE;
|
||||||
|
case kVK_ANSI_F: return NLMISC::KeyF;
|
||||||
|
case kVK_ANSI_G: return NLMISC::KeyG;
|
||||||
|
case kVK_ANSI_H: return NLMISC::KeyH;
|
||||||
|
case kVK_ANSI_I: return NLMISC::KeyI;
|
||||||
|
case kVK_ANSI_J: return NLMISC::KeyJ;
|
||||||
|
case kVK_ANSI_K: return NLMISC::KeyK;
|
||||||
|
case kVK_ANSI_L: return NLMISC::KeyL;
|
||||||
|
case kVK_ANSI_M: return NLMISC::KeyM;
|
||||||
|
case kVK_ANSI_N: return NLMISC::KeyN;
|
||||||
|
case kVK_ANSI_O: return NLMISC::KeyO;
|
||||||
|
case kVK_ANSI_P: return NLMISC::KeyP;
|
||||||
|
case kVK_ANSI_Q: return NLMISC::KeyQ;
|
||||||
|
case kVK_ANSI_R: return NLMISC::KeyR;
|
||||||
|
case kVK_ANSI_S: return NLMISC::KeyS;
|
||||||
|
case kVK_ANSI_T: return NLMISC::KeyT;
|
||||||
|
case kVK_ANSI_U: return NLMISC::KeyU;
|
||||||
|
case kVK_ANSI_V: return NLMISC::KeyV;
|
||||||
|
case kVK_ANSI_W: return NLMISC::KeyW;
|
||||||
|
case kVK_ANSI_X: return NLMISC::KeyX;
|
||||||
|
case kVK_ANSI_Y: return NLMISC::KeyY;
|
||||||
|
case kVK_ANSI_Z: return NLMISC::KeyZ;
|
||||||
|
case kVK_ANSI_Equal: return NLMISC::KeyEQUALS;
|
||||||
|
case kVK_ANSI_Minus: return NLMISC::KeySUBTRACT;
|
||||||
|
case kVK_ANSI_RightBracket: return NLMISC::KeyRBRACKET;
|
||||||
|
case kVK_ANSI_LeftBracket: return NLMISC::KeyLBRACKET;
|
||||||
|
case kVK_ANSI_Quote:break;
|
||||||
|
case kVK_ANSI_Grave:break;
|
||||||
|
case kVK_ANSI_Slash: return NLMISC::KeySLASH;
|
||||||
|
case kVK_ANSI_Backslash: return NLMISC::KeyBACKSLASH;
|
||||||
|
case kVK_ANSI_Comma: return NLMISC::KeyCOMMA;
|
||||||
|
case kVK_ANSI_Period: return NLMISC::KeyPERIOD;
|
||||||
|
case kVK_ANSI_Semicolon: return NLMISC::KeySEMICOLON;
|
||||||
|
case kVK_ANSI_KeypadDecimal: return NLMISC::KeyDECIMAL;
|
||||||
|
case kVK_ANSI_KeypadMultiply: return NLMISC::KeyMULTIPLY;
|
||||||
|
case kVK_ANSI_KeypadPlus: return NLMISC::KeyADD;
|
||||||
|
case kVK_ANSI_KeypadClear: return NLMISC::KeyDELETE;
|
||||||
|
case kVK_ANSI_KeypadDivide: return NLMISC::KeyDIVIDE;
|
||||||
|
case kVK_ANSI_KeypadEnter: return NLMISC::KeyRETURN;
|
||||||
|
case kVK_ANSI_KeypadMinus: return NLMISC::KeySUBTRACT;
|
||||||
|
case kVK_ANSI_KeypadEquals: return NLMISC::KeySEPARATOR;
|
||||||
|
case kVK_ANSI_Keypad0: return NLMISC::KeyNUMPAD0;
|
||||||
|
case kVK_ANSI_Keypad1: return NLMISC::KeyNUMPAD1;
|
||||||
|
case kVK_ANSI_Keypad2: return NLMISC::KeyNUMPAD2;
|
||||||
|
case kVK_ANSI_Keypad3: return NLMISC::KeyNUMPAD3;
|
||||||
|
case kVK_ANSI_Keypad4: return NLMISC::KeyNUMPAD4;
|
||||||
|
case kVK_ANSI_Keypad5: return NLMISC::KeyNUMPAD5;
|
||||||
|
case kVK_ANSI_Keypad6: return NLMISC::KeyNUMPAD6;
|
||||||
|
case kVK_ANSI_Keypad7: return NLMISC::KeyNUMPAD7;
|
||||||
|
case kVK_ANSI_Keypad8: return NLMISC::KeyNUMPAD8;
|
||||||
|
case kVK_ANSI_Keypad9: return NLMISC::KeyNUMPAD9;
|
||||||
|
case kVK_Return: return NLMISC::KeyRETURN;
|
||||||
|
case kVK_Tab: return NLMISC::KeyTAB;
|
||||||
|
case kVK_Space: return NLMISC::KeySPACE;
|
||||||
|
case kVK_Delete: return NLMISC::KeyDELETE;
|
||||||
|
case kVK_ForwardDelete:break;
|
||||||
|
case kVK_Escape: return NLMISC::KeyESCAPE;
|
||||||
|
case kVK_Command:break;
|
||||||
|
case kVK_Shift: return NLMISC::KeySHIFT;
|
||||||
|
case kVK_RightShift: return NLMISC::KeyRSHIFT;
|
||||||
|
case kVK_CapsLock: return NLMISC::KeyCAPITAL;
|
||||||
|
case kVK_Option:break;
|
||||||
|
case kVK_RightOption:break;
|
||||||
|
case kVK_Control: return NLMISC::KeyCONTROL;
|
||||||
|
case kVK_RightControl: return NLMISC::KeyRCONTROL;
|
||||||
|
case kVK_F1: return NLMISC::KeyF1;
|
||||||
|
case kVK_F2: return NLMISC::KeyF2;
|
||||||
|
case kVK_F3: return NLMISC::KeyF3;
|
||||||
|
case kVK_F4: return NLMISC::KeyF4;
|
||||||
|
case kVK_F5: return NLMISC::KeyF5;
|
||||||
|
case kVK_F6: return NLMISC::KeyF6;
|
||||||
|
case kVK_F7: return NLMISC::KeyF7;
|
||||||
|
case kVK_F8: return NLMISC::KeyF8;
|
||||||
|
case kVK_F9: return NLMISC::KeyF9;
|
||||||
|
case kVK_F11: return NLMISC::KeyF11;
|
||||||
|
case kVK_F13: return NLMISC::KeyF13;
|
||||||
|
case kVK_F16: return NLMISC::KeyF16;
|
||||||
|
case kVK_F14: return NLMISC::KeyF14;
|
||||||
|
case kVK_F10: return NLMISC::KeyF10;
|
||||||
|
case kVK_F12: return NLMISC::KeyF12;
|
||||||
|
case kVK_F15: return NLMISC::KeyF15;
|
||||||
|
case kVK_F17: return NLMISC::KeyF17;
|
||||||
|
case kVK_F18: return NLMISC::KeyF18;
|
||||||
|
case kVK_F19: return NLMISC::KeyF19;
|
||||||
|
case kVK_F20: return NLMISC::KeyF20;
|
||||||
|
case kVK_Home: return NLMISC::KeyHOME;
|
||||||
|
case kVK_End: return NLMISC::KeyEND;
|
||||||
|
case kVK_PageUp:break;
|
||||||
|
case kVK_PageDown:break;
|
||||||
|
case kVK_LeftArrow: return NLMISC::KeyLEFT;
|
||||||
|
case kVK_RightArrow: return NLMISC::KeyRIGHT;
|
||||||
|
case kVK_DownArrow: return NLMISC::KeyDOWN;
|
||||||
|
case kVK_UpArrow: return NLMISC::KeyUP;
|
||||||
|
case kVK_Function:break;
|
||||||
|
case kVK_VolumeUp:break;
|
||||||
|
case kVK_VolumeDown:break;
|
||||||
|
case kVK_Mute:break;
|
||||||
|
case kVK_Help:break;
|
||||||
|
case kVK_ISO_Section:break;
|
||||||
|
case kVK_JIS_Yen:break;
|
||||||
|
case kVK_JIS_Underscore:break;
|
||||||
|
case kVK_JIS_KeypadComma:break;
|
||||||
|
case kVK_JIS_Eisu:break;
|
||||||
|
case kVK_JIS_Kana:break;
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
return NLMISC::KeyNOKEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: this function has to be moved to a more central place to handle key
|
||||||
|
mapping on mac x11 as well
|
||||||
|
*/
|
||||||
|
NLMISC::TKeyButton modifierFlagsToNelKeyButton(unsigned int modifierFlags)
|
||||||
|
{
|
||||||
|
unsigned int buttons = 0;
|
||||||
|
if (modifierFlags & NSControlKeyMask) buttons |= NLMISC::ctrlKeyButton;
|
||||||
|
if (modifierFlags & NSShiftKeyMask) buttons |= NLMISC::shiftKeyButton;
|
||||||
|
if (modifierFlags & NSAlternateKeyMask) buttons |= NLMISC::altKeyButton;
|
||||||
|
return (NLMISC::TKeyButton)buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
void submitEvents(NLMISC::CEventServer& server,
|
||||||
|
bool allWindows, NLMISC::CCocoaEventEmitter* eventEmitter)
|
||||||
|
{
|
||||||
|
// cocoa style memory cleanup
|
||||||
|
[g_pool release];
|
||||||
|
g_pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
// we break if there was no event to handle
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
// get the next event to handle
|
||||||
|
NSEvent* event = [g_app nextEventMatchingMask:NSAnyEventMask
|
||||||
|
untilDate:nil /*[NSDate distantFuture]*/
|
||||||
|
inMode:NSDefaultRunLoopMode dequeue:YES];
|
||||||
|
|
||||||
|
// stop, if there was no event
|
||||||
|
if(!event)
|
||||||
|
break;
|
||||||
|
|
||||||
|
NSLog(@"%@", event);
|
||||||
|
|
||||||
|
// get the mouse position in nel style (relative)
|
||||||
|
float mouseX = event.locationInWindow.x / 1024.0;
|
||||||
|
float mouseY = event.locationInWindow.y / 768.0;
|
||||||
|
|
||||||
|
// string to store symbols in case of key press
|
||||||
|
ucstring ucstr;
|
||||||
|
|
||||||
|
switch(event.type)
|
||||||
|
{
|
||||||
|
case NSLeftMouseDown:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseDown(
|
||||||
|
mouseX, mouseY, NLMISC::leftButton /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSLeftMouseUp:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseUp(
|
||||||
|
mouseX, mouseY, NLMISC::leftButton /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSRightMouseDown:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseDown(
|
||||||
|
mouseX, mouseY, NLMISC::rightButton /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSRightMouseUp:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseUp(
|
||||||
|
mouseX, mouseY, NLMISC::rightButton /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSMouseMoved:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseMove(
|
||||||
|
mouseX, mouseY, (NLMISC::TMouseButton)0 /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSLeftMouseDragged:
|
||||||
|
server.postEvent(new NLMISC::CEventMouseMove(
|
||||||
|
mouseX, mouseY, NLMISC::leftButton /* modifiers */, eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSRightMouseDragged:break;
|
||||||
|
server.postEvent(new NLMISC::CEventMouseMove(
|
||||||
|
mouseX, mouseY, NLMISC::rightButton /* modifiers */, eventEmitter));
|
||||||
|
case NSMouseEntered:break;
|
||||||
|
case NSMouseExited:break;
|
||||||
|
case NSKeyDown:
|
||||||
|
/*
|
||||||
|
TODO dead keys
|
||||||
|
http://developer.apple.com/mac/library/documentation/Carbon/Reference/
|
||||||
|
Unicode_Utilities_Ref/Reference/reference.html#//apple_ref/c/func/
|
||||||
|
UCKeyTranslate
|
||||||
|
*/
|
||||||
|
|
||||||
|
// push the key press event to the new event server
|
||||||
|
server.postEvent(new NLMISC::CEventKeyDown(
|
||||||
|
virtualKeycodeToNelKey([event keyCode]),
|
||||||
|
modifierFlagsToNelKeyButton([event modifierFlags]),
|
||||||
|
[event isARepeat] == NO,
|
||||||
|
eventEmitter));
|
||||||
|
|
||||||
|
// get the string associated with the key press event
|
||||||
|
ucstr.fromUtf8([[event characters] UTF8String]);
|
||||||
|
|
||||||
|
// if any, push it to the event server as well
|
||||||
|
if([[event characters] length] > 0)
|
||||||
|
server.postEvent(new NLMISC::CEventChar(
|
||||||
|
ucstr[0],
|
||||||
|
NLMISC::noKeyButton,
|
||||||
|
eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSKeyUp:
|
||||||
|
server.postEvent(new NLMISC::CEventKeyUp(
|
||||||
|
virtualKeycodeToNelKey([event keyCode]),
|
||||||
|
modifierFlagsToNelKeyButton([event modifierFlags]),
|
||||||
|
eventEmitter));
|
||||||
|
break;
|
||||||
|
case NSFlagsChanged:break;
|
||||||
|
case NSAppKitDefined:break;
|
||||||
|
case NSSystemDefined:break;
|
||||||
|
case NSApplicationDefined:break;
|
||||||
|
case NSPeriodic:break;
|
||||||
|
case NSCursorUpdate:break;
|
||||||
|
case NSScrollWheel:break;
|
||||||
|
case NSTabletPoint:break;
|
||||||
|
case NSTabletProximity:break;
|
||||||
|
case NSOtherMouseDown:break;
|
||||||
|
case NSOtherMouseUp:break;
|
||||||
|
case NSOtherMouseDragged:break;
|
||||||
|
case NSEventTypeGesture:break;
|
||||||
|
case NSEventTypeMagnify:break;
|
||||||
|
case NSEventTypeSwipe:break;
|
||||||
|
case NSEventTypeRotate:break;
|
||||||
|
case NSEventTypeBeginGesture:break;
|
||||||
|
case NSEventTypeEndGesture:break;
|
||||||
|
default:
|
||||||
|
nlwarning("Unknown event type. dropping.");
|
||||||
|
// NSLog(@"%@", event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
[g_app sendEvent:event];
|
||||||
|
[g_app updateWindows];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
30
code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp
Normal file
30
code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "cocoa_event_emitter.h"
|
||||||
|
|
||||||
|
#include "cocoa_adapter.h"
|
||||||
|
|
||||||
|
namespace NLMISC
|
||||||
|
{
|
||||||
|
|
||||||
|
void CCocoaEventEmitter::submitEvents(CEventServer & server, bool allWindows)
|
||||||
|
{
|
||||||
|
// just forwarding to out cocoa adapter
|
||||||
|
NL3D::MAC::submitEvents(server, allWindows, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h
Normal file
33
code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef NL_COCOA_EVENT_EMITTER_H
|
||||||
|
#define NL_COCOA_EVENT_EMITTER_H
|
||||||
|
|
||||||
|
#include <nel/misc/event_emitter.h>
|
||||||
|
|
||||||
|
namespace NLMISC
|
||||||
|
{
|
||||||
|
|
||||||
|
class CCocoaEventEmitter : public IEventEmitter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void submitEvents(CEventServer & server, bool allWindows);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
31
code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h
Normal file
31
code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* derived to configure the NSOpenGLView
|
||||||
|
*/
|
||||||
|
@interface CocoaOpenGLView : NSOpenGLView
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)acceptsFirstResponder;
|
||||||
|
-(BOOL)needsPanelToBecomeKey;
|
||||||
|
|
||||||
|
@end
|
33
code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m
Normal file
33
code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "cocoa_opengl_view.h"
|
||||||
|
|
||||||
|
@implementation CocoaOpenGLView
|
||||||
|
|
||||||
|
-(BOOL)acceptsFirstResponder
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)needsPanelToBecomeKey
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
31
code/nel/src/3d/driver/opengl/mac/cocoa_window.h
Normal file
31
code/nel/src/3d/driver/opengl/mac/cocoa_window.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* derived to configure the NSWindow
|
||||||
|
*/
|
||||||
|
@interface CocoaWindow : NSWindow
|
||||||
|
{
|
||||||
|
}
|
||||||
|
-(BOOL)canBecomeKeyWindow;
|
||||||
|
-(BOOL)canBecomeMainWindow;
|
||||||
|
-(BOOL)needsPanelToBecomeKey;
|
||||||
|
-(BOOL)acceptsFirstResponder;
|
||||||
|
@end
|
43
code/nel/src/3d/driver/opengl/mac/cocoa_window.m
Normal file
43
code/nel/src/3d/driver/opengl/mac/cocoa_window.m
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "cocoa_window.h"
|
||||||
|
|
||||||
|
@implementation CocoaWindow
|
||||||
|
|
||||||
|
-(BOOL)canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)canBecomeMainWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)needsPanelToBecomeKey
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)acceptsFirstResponder
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
10279
code/nel/src/3d/driver/opengl/mac/glext.h
Normal file
10279
code/nel/src/3d/driver/opengl/mac/glext.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#ifdef NL_OS_UNIX
|
#ifdef NL_OS_UNIX
|
||||||
|
|
||||||
|
#ifndef NL_MAC_NATIVE
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
@ -479,4 +481,6 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
||||||
|
|
||||||
} // NLMISC
|
} // NLMISC
|
||||||
|
|
||||||
|
#endif // NL_MAC_NATIVE
|
||||||
|
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#ifndef NL_UNIX_EVENT_EMITTER_H
|
#ifndef NL_UNIX_EVENT_EMITTER_H
|
||||||
#define NL_UNIX_EVENT_EMITTER_H
|
#define NL_UNIX_EVENT_EMITTER_H
|
||||||
|
|
||||||
|
#ifndef NL_MAC_NATIVE
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/misc/event_emitter.h"
|
#include "nel/misc/event_emitter.h"
|
||||||
#include "nel/misc/events.h"
|
#include "nel/misc/events.h"
|
||||||
|
@ -70,6 +72,8 @@ private:
|
||||||
|
|
||||||
#endif // NL_OS_UNIX
|
#endif // NL_OS_UNIX
|
||||||
|
|
||||||
|
#endif // NL_MAC_NATIVE
|
||||||
|
|
||||||
#endif // NL_UNIX_EVENT_EMITTER_H
|
#endif // NL_UNIX_EVENT_EMITTER_H
|
||||||
|
|
||||||
/* End of unix_event_emitter.h */
|
/* End of unix_event_emitter.h */
|
||||||
|
|
|
@ -86,7 +86,9 @@ FIND_PACKAGE(CURL REQUIRED)
|
||||||
FIND_PACKAGE(Libwww)
|
FIND_PACKAGE(Libwww)
|
||||||
FIND_PACKAGE(ZLIB)
|
FIND_PACKAGE(ZLIB)
|
||||||
IF(NOT WIN32)
|
IF(NOT WIN32)
|
||||||
FIND_PACKAGE(X11)
|
IF(NOT WITH_COCOA)
|
||||||
|
FIND_PACKAGE(X11)
|
||||||
|
ENDIF(NOT WITH_COCOA)
|
||||||
ENDIF(NOT WIN32)
|
ENDIF(NOT WIN32)
|
||||||
|
|
||||||
NL_SETUP_BUILD()
|
NL_SETUP_BUILD()
|
||||||
|
|
|
@ -33,9 +33,37 @@ IF(UNIX)
|
||||||
INCLUDE(${CMAKE_BINARY_DIR})
|
INCLUDE(${CMAKE_BINARY_DIR})
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
ADD_EXECUTABLE(client ${SRC})
|
# on Mac, create a .App Bundle
|
||||||
|
if(APPLE)
|
||||||
|
SET(MACOSX_BUNDLE_INFO_STRING "Ryzom Core Client")
|
||||||
|
SET(MACOSX_BUNDLE_ICON_FILE "")
|
||||||
|
SET(MACOSX_BUNDLE_GUI_IDENTIFIER "")
|
||||||
|
SET(MACOSX_BUNDLE_LONG_VERSION_STRING "0.8.0")
|
||||||
|
SET(MACOSX_BUNDLE_BUNDLE_NAME "Ryzom Core Client")
|
||||||
|
SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "0.8")
|
||||||
|
SET(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
|
||||||
|
SET(MACOSX_BUNDLE_COPYRIGHT "Winchgate and The Ryzom Core Community")
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES( ${LIBXML2_INCLUDE_DIR}
|
ADD_EXECUTABLE(client MACOSX_BUNDLE ${SRC})
|
||||||
|
|
||||||
|
# TODO: in release mode, cmake could copy all the dylibs into the .app
|
||||||
|
# bundle for redistribution... should some part of cpack handle that?
|
||||||
|
# ADD_CUSTOM_COMMAND(TARGET client POST_BUILD
|
||||||
|
# # make frameworks directory in app bundle
|
||||||
|
# COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR}/client.app/Contents/Frameworks
|
||||||
|
# # copy framework into app bundle
|
||||||
|
# COMMAND ${CMAKE_COMMAND} -E copy ${SOME_LIBRARY}
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR}/client.app/Contents/Frameworks
|
||||||
|
# # ...
|
||||||
|
# # install_name_tool the lib pathes
|
||||||
|
|
||||||
|
ELSE(APPLE)
|
||||||
|
ADD_EXECUTABLE(client ${SRC})
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${NEL_INCLUDE_DIR}
|
${NEL_INCLUDE_DIR}
|
||||||
${LUA_INCLUDE_DIR}
|
${LUA_INCLUDE_DIR}
|
||||||
${LIBWWW_INCLUDE_DIR}
|
${LIBWWW_INCLUDE_DIR}
|
||||||
|
@ -58,9 +86,13 @@ TARGET_LINK_LIBRARIES(client ${PLATFORM_LINKFLAGS}
|
||||||
${NELPACS_LIBRARY}
|
${NELPACS_LIBRARY}
|
||||||
${LIBWWW_LIBRARY}
|
${LIBWWW_LIBRARY}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${X11_LIBRARIES}
|
|
||||||
seven_zip
|
seven_zip
|
||||||
luabind)
|
luabind)
|
||||||
|
|
||||||
|
IF(NOT WITH_COCOA)
|
||||||
|
TARGET_LINK_LIBRARIES(client ${X11_LIBRARIES})
|
||||||
|
ENDIF(NOT WITH_COCOA)
|
||||||
|
|
||||||
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
|
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
|
||||||
|
|
||||||
INSTALL(TARGETS client RUNTIME DESTINATION bin COMPONENT client)
|
INSTALL(TARGETS client RUNTIME DESTINATION bin COMPONENT client BUNDLE DESTINATION /Applications)
|
||||||
|
|
|
@ -452,20 +452,25 @@ void CUserControls::getMouseAngleMove(float &dx, float &dy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// On X11, do the thing without IMouseDevice implementation
|
// On X11 and Mac, do the thing without IMouseDevice implementation
|
||||||
if( EventsListener.getMousePosX() != _LastFrameMousePosX ||
|
if( EventsListener.getMousePosX() != _LastFrameMousePosX ||
|
||||||
EventsListener.getMousePosY() != _LastFrameMousePosY )
|
EventsListener.getMousePosY() != _LastFrameMousePosY )
|
||||||
{
|
{
|
||||||
float dmpx, dmpy;
|
float dmpx, dmpy;
|
||||||
|
|
||||||
|
#ifndef NL_MAC_NATIVE
|
||||||
// On X11 in free look mode, the mouse is pulled back to (0.5, 0.5)
|
// On X11 in free look mode, the mouse is pulled back to (0.5, 0.5)
|
||||||
// every update to prevent reaching a border and get stuck.
|
// every update to prevent reaching a border and get stuck.
|
||||||
if(IsMouseFreeLook())
|
if(IsMouseFreeLook())
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
TODO use setCapture to not fake it
|
||||||
|
*/
|
||||||
dmpx = EventsListener.getMousePosX() - 0.5;
|
dmpx = EventsListener.getMousePosX() - 0.5;
|
||||||
dmpy = EventsListener.getMousePosY() - 0.5;
|
dmpy = EventsListener.getMousePosY() - 0.5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
dmpx = EventsListener.getMousePosX() - _LastFrameMousePosX;
|
dmpx = EventsListener.getMousePosX() - _LastFrameMousePosX;
|
||||||
dmpy = EventsListener.getMousePosY() - _LastFrameMousePosY;
|
dmpy = EventsListener.getMousePosY() - _LastFrameMousePosY;
|
||||||
|
|
Loading…
Reference in a new issue