mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Revert parts of r5576 and r5598 for Sonicadvance1's sake.
This reenables the option for building without wx on OS X, but still leaves wxgl as the default. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5599 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -55,6 +55,8 @@ void OpenGL_SwapBuffers()
|
||||
{
|
||||
#if defined(USE_WX) && USE_WX
|
||||
GLWin.glCanvas->SwapBuffers();
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLSwap(GLWin.cocoaCtx,GLWin.cocoaWin);
|
||||
#elif defined(_WIN32)
|
||||
SwapBuffers(hDC);
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
@ -76,6 +78,8 @@ void OpenGL_SetWindowText(const char *text)
|
||||
{
|
||||
#if defined(USE_WX) && USE_WX
|
||||
// GLWin.frame->SetTitle(wxString::FromAscii(text));
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLSetTitle(GLWin.cocoaWin, text);
|
||||
#elif defined(_WIN32)
|
||||
// TODO convert text to unicode and change SetWindowTextA to SetWindowText
|
||||
SetWindowTextA(EmuWindow::GetWnd(), text);
|
||||
@ -264,6 +268,12 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||
|
||||
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
GLWin.width = s_backbuffer_width;
|
||||
GLWin.height = s_backbuffer_height;
|
||||
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
|
||||
GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
|
||||
|
||||
#elif defined(_WIN32)
|
||||
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait..."));
|
||||
if (g_VideoInitialize.pWindowHandle == NULL)
|
||||
@ -405,6 +415,8 @@ bool OpenGL_MakeCurrent()
|
||||
// connect the glx-context to the window
|
||||
#if defined(USE_WX) && USE_WX
|
||||
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin);
|
||||
#elif defined(_WIN32)
|
||||
return wglMakeCurrent(hDC,hRC);
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
@ -425,6 +437,11 @@ void OpenGL_Update()
|
||||
|
||||
// TODO fill in
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
RECT rcWindow = {0};
|
||||
rcWindow.right = GLWin.width;
|
||||
rcWindow.bottom = GLWin.height;
|
||||
|
||||
#elif defined(_WIN32)
|
||||
RECT rcWindow;
|
||||
if (!EmuWindow::GetParentWnd())
|
||||
@ -464,6 +481,10 @@ void OpenGL_Shutdown()
|
||||
{
|
||||
#if defined(USE_WX) && USE_WX
|
||||
delete GLWin.glCanvas;
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLDeleteWindow(GLWin.cocoaWin);
|
||||
cocoaGLDelete(GLWin.cocoaCtx);
|
||||
|
||||
#elif defined(_WIN32)
|
||||
if (hRC) // Do We Have A Rendering Context?
|
||||
{
|
||||
|
@ -49,8 +49,9 @@
|
||||
#include <GL/glew.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#else
|
||||
#elif defined(__APPLE__)
|
||||
#include <GL/glew.h>
|
||||
#include "cocoaGL.h"
|
||||
#endif // end USE_WX
|
||||
|
||||
#if defined(__APPLE__)
|
||||
@ -75,7 +76,10 @@
|
||||
|
||||
typedef struct {
|
||||
int screen;
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#if defined(__APPLE__)
|
||||
NSWindow *cocoaWin;
|
||||
NSOpenGLContext *cocoaCtx;
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
Window win;
|
||||
Window parent;
|
||||
Display *dpy;
|
||||
@ -83,7 +87,8 @@ typedef struct {
|
||||
GLXContext ctx;
|
||||
XSetWindowAttributes attr;
|
||||
Common::Thread *xEventThread;
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
#endif // X11
|
||||
#if defined(USE_WX) && USE_WX
|
||||
wxGLCanvas *glCanvas;
|
||||
wxPanel *panel;
|
||||
wxGLContext *glCtxt;
|
||||
|
@ -25,6 +25,8 @@ files = [
|
||||
'PostProcessing.cpp',
|
||||
'FramebufferManager.cpp',
|
||||
]
|
||||
compileFlags = [
|
||||
]
|
||||
linkFlags = [
|
||||
]
|
||||
libs = [
|
||||
@ -46,6 +48,12 @@ if gfxenv['HAVE_WX']:
|
||||
'Debugger/Debugger.cpp',
|
||||
]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
files += [ 'cocoaGL.m' ]
|
||||
compileFlags += [
|
||||
'-x',
|
||||
'objective-c++',
|
||||
]
|
||||
if sys.platform == 'win32':
|
||||
files += [ 'OS/Win32.cpp' ]
|
||||
|
||||
@ -97,6 +105,7 @@ if gfxenv['USE_WX'] and not gfxenv['HAVE_WX']:
|
||||
print "Must have wx to use wxgl"
|
||||
Return()
|
||||
gfxenv.Append(
|
||||
CXXFLAGS = compileFlags,
|
||||
LINKFLAGS = linkFlags,
|
||||
)
|
||||
|
||||
|
29
Source/Plugins/Plugin_VideoOGL/Src/cocoaApp.h
Normal file
29
Source/Plugins/Plugin_VideoOGL/Src/cocoaApp.h
Normal file
@ -0,0 +1,29 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/CGLRenderers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
void cocoaGLCreateApp();
|
||||
|
||||
NSWindow *cocoaGLCreateWindow(int w,int h);
|
||||
|
||||
void cocoaGLSetTitle(NSWindow *win, const char *title);
|
||||
|
||||
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win);
|
||||
|
||||
NSOpenGLContext* cocoaGLInit(int mode);
|
||||
|
||||
void cocoaGLDelete(NSOpenGLContext *ctx);
|
||||
|
||||
void cocoaGLDeleteWindow(NSWindow *window);
|
||||
|
||||
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
149
Source/Plugins/Plugin_VideoOGL/Src/cocoaApp.m
Executable file
149
Source/Plugins/Plugin_VideoOGL/Src/cocoaApp.m
Executable file
@ -0,0 +1,149 @@
|
||||
#import "cocoaGL.h"
|
||||
|
||||
NSWindow *cocoaGLCreateWindow(int w,int h)
|
||||
{
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *window;
|
||||
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h)
|
||||
styleMask:NSTitledWindowMask | NSResizableWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:FALSE];
|
||||
[window setReleasedWhenClosed: YES];
|
||||
|
||||
[window setTitle:@"Dolphin on OSX"];
|
||||
//[window makeKeyAndOrderFront: nil];
|
||||
|
||||
[pool release];
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
void cocoaGLSetTitle(NSWindow *win, const char *title)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
int value = 0;
|
||||
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
|
||||
if (ctx) {
|
||||
[ctx setView:[win contentView]];
|
||||
[ctx update];
|
||||
[ctx makeCurrentContext];
|
||||
}
|
||||
else
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
||||
|
||||
NSOpenGLContext* cocoaGLInit(int mode)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
NSOpenGLContext *context;
|
||||
int i = 0;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
attr[i++] = NSOpenGLPFADepthSize;
|
||||
attr[i++] = 24;
|
||||
attr[i++] = NSOpenGLPFADoubleBuffer;
|
||||
|
||||
attr[i++] = NSOpenGLPFASampleBuffers;
|
||||
attr[i++] = mode;
|
||||
attr[i++] = NSOpenGLPFASamples;
|
||||
attr[i++] = 1;
|
||||
|
||||
attr[i++] = NSOpenGLPFANoRecovery;
|
||||
#ifdef GL_VERSION_1_3
|
||||
|
||||
#else
|
||||
#ifdef GL_VERSION_1_2
|
||||
#warning "your card only supports ogl 1.2, dolphin will use software renderer"
|
||||
//if opengl < 1.3 uncomment this twoo lines to use software renderer
|
||||
attr[i++] = NSOpenGLPFARendererID;
|
||||
attr[i++] = kCGLRendererGenericFloatID;
|
||||
#endif
|
||||
#endif
|
||||
attr[i++] = NSOpenGLPFAScreenMask;
|
||||
attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID());
|
||||
|
||||
attr[i] = 0;
|
||||
|
||||
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
||||
if (fmt == nil) {
|
||||
printf("failed to create pixel format\n");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
||||
|
||||
[fmt release];
|
||||
|
||||
if (context == nil) {
|
||||
printf("failed to create context\n");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return context;
|
||||
|
||||
}
|
||||
|
||||
void cocoaGLDelete(NSOpenGLContext *ctx)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[ctx clearDrawable];
|
||||
[ctx release];
|
||||
|
||||
[pool release];
|
||||
|
||||
}
|
||||
void cocoaGLDeleteWindow(NSWindow *window)
|
||||
{
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[window close];
|
||||
[pool release];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
[window makeKeyAndOrderFront: nil];
|
||||
|
||||
ctx = [NSOpenGLContext currentContext];
|
||||
if (ctx != nil)
|
||||
[ctx flushBuffer];
|
||||
else
|
||||
printf("bad cocoa gl ctx\n");
|
||||
|
||||
[pool release];
|
||||
}
|
28
Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h
Normal file
28
Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h
Normal file
@ -0,0 +1,28 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/CGLRenderers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
void cocoaGLCreateApp();
|
||||
|
||||
NSWindow *cocoaGLCreateWindow(int w,int h);
|
||||
|
||||
void cocoaGLSetTitle(NSWindow *win, const char *title);
|
||||
|
||||
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win);
|
||||
|
||||
NSOpenGLContext* cocoaGLInit(int mode);
|
||||
|
||||
void cocoaGLDelete(NSOpenGLContext *ctx);
|
||||
|
||||
void cocoaGLDeleteWindow(NSWindow *window);
|
||||
|
||||
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
149
Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m
Executable file
149
Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m
Executable file
@ -0,0 +1,149 @@
|
||||
#import "cocoaGL.h"
|
||||
|
||||
NSWindow *cocoaGLCreateWindow(int w,int h)
|
||||
{
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *window;
|
||||
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h)
|
||||
styleMask:NSTitledWindowMask | NSResizableWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:FALSE];
|
||||
[window setReleasedWhenClosed: YES];
|
||||
|
||||
[window setTitle:@"Dolphin on OSX"];
|
||||
//[window makeKeyAndOrderFront: nil];
|
||||
|
||||
[pool release];
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
void cocoaGLSetTitle(NSWindow *win, const char *title)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
int value = 0;
|
||||
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
|
||||
if (ctx) {
|
||||
[ctx setView:[win contentView]];
|
||||
[ctx update];
|
||||
[ctx makeCurrentContext];
|
||||
}
|
||||
else
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
||||
|
||||
NSOpenGLContext* cocoaGLInit(int mode)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
NSOpenGLContext *context;
|
||||
int i = 0;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
attr[i++] = NSOpenGLPFADepthSize;
|
||||
attr[i++] = 24;
|
||||
attr[i++] = NSOpenGLPFADoubleBuffer;
|
||||
|
||||
attr[i++] = NSOpenGLPFASampleBuffers;
|
||||
attr[i++] = mode;
|
||||
attr[i++] = NSOpenGLPFASamples;
|
||||
attr[i++] = 1;
|
||||
|
||||
attr[i++] = NSOpenGLPFANoRecovery;
|
||||
#ifdef GL_VERSION_1_3
|
||||
|
||||
#else
|
||||
#ifdef GL_VERSION_1_2
|
||||
#warning "your card only supports ogl 1.2, dolphin will use software renderer"
|
||||
//if opengl < 1.3 uncomment this twoo lines to use software renderer
|
||||
attr[i++] = NSOpenGLPFARendererID;
|
||||
attr[i++] = kCGLRendererGenericFloatID;
|
||||
#endif
|
||||
#endif
|
||||
attr[i++] = NSOpenGLPFAScreenMask;
|
||||
attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID());
|
||||
|
||||
attr[i] = 0;
|
||||
|
||||
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
||||
if (fmt == nil) {
|
||||
printf("failed to create pixel format\n");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
||||
|
||||
[fmt release];
|
||||
|
||||
if (context == nil) {
|
||||
printf("failed to create context\n");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return context;
|
||||
|
||||
}
|
||||
|
||||
void cocoaGLDelete(NSOpenGLContext *ctx)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[ctx clearDrawable];
|
||||
[ctx release];
|
||||
|
||||
[pool release];
|
||||
|
||||
}
|
||||
void cocoaGLDeleteWindow(NSWindow *window)
|
||||
{
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[window close];
|
||||
[pool release];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
[window makeKeyAndOrderFront: nil];
|
||||
|
||||
ctx = [NSOpenGLContext currentContext];
|
||||
if (ctx != nil)
|
||||
[ctx flushBuffer];
|
||||
else
|
||||
printf("bad cocoa gl ctx\n");
|
||||
|
||||
[pool release];
|
||||
}
|
Reference in New Issue
Block a user