add cocoa in ogl plugin

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@976 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
tmator 2008-10-27 20:29:32 +00:00
parent 62b49ea2d6
commit a7be7689c1
5 changed files with 43 additions and 16 deletions

View File

@ -64,7 +64,7 @@ void OpenGL_SwapBuffers()
#if USE_SDL #if USE_SDL
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
#elif defined(OSX64) #elif defined(OSX64)
cocoaGLSwap(GLWin.cocoaWin,GLWin.cocoaWin);
#elif defined(_WIN32) #elif defined(_WIN32)
SwapBuffers(hDC); SwapBuffers(hDC);
#else // GLX #else // GLX
@ -77,7 +77,7 @@ void OpenGL_SetWindowText(const char *text)
#if USE_SDL #if USE_SDL
SDL_WM_SetCaption(text, NULL); SDL_WM_SetCaption(text, NULL);
#elif defined(OSX64) #elif defined(OSX64)
cocoaGLSetTitle();
#elif defined(_WIN32) #elif defined(_WIN32)
SetWindowText(EmuWindow::GetWnd(), text); SetWindowText(EmuWindow::GetWnd(), text);
#else // GLX #else // GLX
@ -101,6 +101,7 @@ BOOL Callback_PeekMessages()
// proper value to return. // proper value to return.
return FALSE; return FALSE;
#elif defined(OSX64) #elif defined(OSX64)
//TODO
return FALSE; return FALSE;
#elif defined(_WIN32) #elif defined(_WIN32)
//TODO: peekmessage //TODO: peekmessage
@ -210,7 +211,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
//setup ogl to use double buffering //setup ogl to use double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#elif defined(OSX64) #elif defined(OSX64)
cocoaGLCreateApp();
GLWin.width = nBackbufferWidth;
GLWin.height = nBackbufferHeight;
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
#elif defined(_WIN32) #elif defined(_WIN32)
// create the window // create the window
if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL) if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL)
@ -491,7 +496,7 @@ bool OpenGL_MakeCurrent()
return false; return false;
} }
#elif defined(OSX64) #elif defined(OSX64)
cocoaGLMakeCurrent(GLWin.cocoaWin,GLWin.cocoaCtx);
#elif defined(_WIN32) #elif defined(_WIN32)
if (!wglMakeCurrent(hDC,hRC)) { if (!wglMakeCurrent(hDC,hRC)) {
MessageBox(NULL,"(5) Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); MessageBox(NULL,"(5) Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
@ -530,6 +535,8 @@ void OpenGL_Update()
nBackbufferHeight = surface->h; nBackbufferHeight = surface->h;
#elif defined(OSX64) #elif defined(OSX64)
RECT rcWindow; RECT rcWindow;
rcWindow.right = GLWin.width;
rcWindow.bottom = GLWin.height;
#elif defined(_WIN32) #elif defined(_WIN32)
if (!EmuWindow::GetParentWnd()) return; if (!EmuWindow::GetParentWnd()) return;
@ -666,7 +673,7 @@ void OpenGL_Shutdown()
#if USE_SDL #if USE_SDL
SDL_Quit(); SDL_Quit();
#elif defined(OSX64) #elif defined(OSX64)
cocoaGLDelete(GLWin.cocoaCtx);
#elif defined(_WIN32) #elif defined(_WIN32)
if (hRC) // Do We Have A Rendering Context? if (hRC) // Do We Have A Rendering Context?
{ {

View File

@ -37,10 +37,12 @@
#if !defined(OSX64) #if !defined(OSX64)
#include <GL/glxew.h> #include <GL/glxew.h>
#else #else
#undef BOOL
#include <GL/glew.h> #include <GL/glew.h>
#include "cocoaGL.h"
#endif #endif
#if defined(__APPLE__)
#if defined(__APPLE__)
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#else #else
@ -88,21 +90,24 @@ inline unsigned long timeGetTime()
#undef I_NEED_OS2_H #undef I_NEED_OS2_H
#undef BOOL #undef BOOL
#if !defined(__APPLE__)
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/extensions/xf86vmode.h> #include <X11/extensions/xf86vmode.h>
//#include <gtk/gtk.h> //#include <gtk/gtk.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
typedef struct { typedef struct {
Display *dpy;
int screen; int screen;
Window win;
#if defined(OSX64) #if defined(OSX64)
NSWindow *cocoaWin;
NSOpenGLContext *cocoaCtx;
#else //linux #else //linux
Window win;
Display *dpy;
GLXContext ctx; GLXContext ctx;
XSetWindowAttributes attr; XSetWindowAttributes attr;
Bool fs; Bool fs;

View File

@ -63,7 +63,10 @@ if gfxenv['osx64']:
if sys.platform == 'darwin': if sys.platform == 'darwin':
platform = 'mac' platform = 'mac'
# SDL is currently the only way to get video on Mac OS X. # SDL is currently the only way to get video on Mac OS X.
useSDL = True if gfxenv['osx64']:
useSDL = False
else:
useSDL = True
# TODO: clean it up (use incpath and libpath) # TODO: clean it up (use incpath and libpath)
# Use libraries from MacPorts. # Use libraries from MacPorts.
compileFlags.append('-I/opt/local/include') compileFlags.append('-I/opt/local/include')

View File

@ -13,9 +13,17 @@ files = [
] ]
padenv = env.Clone() padenv = env.Clone()
padenv.Append(
CXXFLAGS = [ '-fPIC' ], if padenv['osx64']:
LIBS = [ 'common' ], padenv.Append(
) CXXFLAGS = [ '-arch', 'x86_64' ],
if not env['osx64']: LINKFLAGS = [ '-arch', 'x86_64' ],
padenv.SharedLibrary(output, files) LIBS = [ 'common' ],
)
else:
padenv.Append(
CXXFLAGS = [ '-fPIC' ],
LIBS = [ 'common' ],
)
padenv.SharedLibrary(output, files)

View File

@ -1,4 +1,6 @@
#if !defined(OSX64)
#include <wx/aboutdlg.h> #include <wx/aboutdlg.h>
#endif
#include "Common.h" #include "Common.h"
#include "StringUtil.h" #include "StringUtil.h"
@ -145,11 +147,13 @@ extern "C" void GetDllInfo (PLUGIN_INFO* _PluginInfo)
extern "C" void DllAbout(HWND _hParent) extern "C" void DllAbout(HWND _hParent)
{ {
#if !defined(OSX64)
wxAboutDialogInfo info; wxAboutDialogInfo info;
info.SetName(_T("Wiimote test plugin")); info.SetName(_T("Wiimote test plugin"));
info.AddDeveloper(_T("masken (masken3@gmail.com)")); info.AddDeveloper(_T("masken (masken3@gmail.com)"));
info.SetDescription(_T("Wiimote test plugin")); info.SetDescription(_T("Wiimote test plugin"));
wxAboutBox(info); wxAboutBox(info);
#endif
} }
extern "C" void DllConfig(HWND _hParent) extern "C" void DllConfig(HWND _hParent)