mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Make wxgl mandatory on OS X.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5576 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,148 +1,141 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// 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 General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#ifndef _GLINIT_H_
|
||||
#define _GLINIT_H_
|
||||
|
||||
#if defined GLTEST && GLTEST
|
||||
#include "nGLUtil.h"
|
||||
#else
|
||||
#include "Common.h"
|
||||
#include <string>
|
||||
#include "VideoConfig.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define GLEW_STATIC
|
||||
|
||||
#include <GLew/glew.h>
|
||||
#include <GLew/wglew.h>
|
||||
#include <GLew/gl.h>
|
||||
#include <GLew/glext.h>
|
||||
|
||||
#else // linux basic definitions
|
||||
|
||||
#if defined(USE_WX) && USE_WX
|
||||
#include <GL/glew.h>
|
||||
#include "wx/wx.h"
|
||||
#include "wx/glcanvas.h"
|
||||
#undef HAVE_X11
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
#define I_NEED_OS2_H // HAXXOR
|
||||
#include <GL/glxew.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#elif defined(USE_SDL) && USE_SDL
|
||||
#include <GL/glew.h>
|
||||
#include <SDL.h>
|
||||
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
||||
#include <GL/glew.h>
|
||||
#include "cocoaGL.h"
|
||||
#endif // end USE_WX
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#endif // linux basic definitions
|
||||
|
||||
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
|
||||
#define GL_DEPTH_STENCIL_EXT 0x84F9
|
||||
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
|
||||
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
|
||||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#endif // X11
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct {
|
||||
int screen;
|
||||
#if defined(HAVE_COCOA) && HAVE_COCOA
|
||||
NSWindow *cocoaWin;
|
||||
NSOpenGLContext *cocoaCtx;
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
Window win;
|
||||
Window parent;
|
||||
Display *dpy;
|
||||
GLXContext ctx;
|
||||
XSetWindowAttributes attr;
|
||||
#endif // X11
|
||||
#if defined(USE_WX) && USE_WX
|
||||
wxGLCanvas *glCanvas;
|
||||
wxFrame *frame;
|
||||
wxGLContext *glCtxt;
|
||||
#endif
|
||||
int x, y;
|
||||
unsigned int width, height;
|
||||
unsigned int depth;
|
||||
} GLWindow;
|
||||
|
||||
extern GLWindow GLWin;
|
||||
|
||||
#endif
|
||||
|
||||
// Public OpenGL util
|
||||
|
||||
// Initialization / upkeep
|
||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
||||
void OpenGL_Shutdown();
|
||||
void OpenGL_Update();
|
||||
bool OpenGL_MakeCurrent();
|
||||
void OpenGL_SwapBuffers();
|
||||
|
||||
// Get status
|
||||
u32 OpenGL_GetBackbufferWidth();
|
||||
u32 OpenGL_GetBackbufferHeight();
|
||||
|
||||
// Set things
|
||||
void OpenGL_SetWindowText(const char *text);
|
||||
|
||||
// Error reporting - use the convenient macros.
|
||||
void OpenGL_ReportARBProgramError();
|
||||
GLuint OpenGL_ReportGLError(const char *function, const char *file, int line);
|
||||
bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
||||
|
||||
#if 1
|
||||
#define GL_REPORT_ERROR() OpenGL_ReportGLError (__FUNCTION__, __FILE__, __LINE__)
|
||||
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
||||
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError (__FUNCTION__, __FILE__, __LINE__)
|
||||
#else
|
||||
#define GL_REPORT_ERROR() GL_NO_ERROR
|
||||
#define GL_REPORT_PROGRAM_ERROR()
|
||||
#define GL_REPORT_FBO_ERROR()
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
||||
#else
|
||||
#define GL_REPORT_ERRORD()
|
||||
#endif
|
||||
|
||||
#endif // GLTEST ??
|
||||
|
||||
#endif // _GLINIT_H_
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// 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 General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#ifndef _GLINIT_H_
|
||||
#define _GLINIT_H_
|
||||
|
||||
#if defined GLTEST && GLTEST
|
||||
#include "nGLUtil.h"
|
||||
#else
|
||||
#include "Common.h"
|
||||
#include <string>
|
||||
#include "VideoConfig.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define GLEW_STATIC
|
||||
|
||||
#include <GLew/glew.h>
|
||||
#include <GLew/wglew.h>
|
||||
#include <GLew/gl.h>
|
||||
#include <GLew/glext.h>
|
||||
|
||||
#else // linux basic definitions
|
||||
|
||||
#if defined(USE_WX) && USE_WX
|
||||
#include <GL/glew.h>
|
||||
#include "wx/wx.h"
|
||||
#include "wx/glcanvas.h"
|
||||
#undef HAVE_X11
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
#define I_NEED_OS2_H // HAXXOR
|
||||
#include <GL/glxew.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#elif defined(USE_SDL) && USE_SDL
|
||||
#include <GL/glew.h>
|
||||
#include <SDL.h>
|
||||
#endif // end USE_WX
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#endif // linux basic definitions
|
||||
|
||||
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
|
||||
#define GL_DEPTH_STENCIL_EXT 0x84F9
|
||||
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
|
||||
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
|
||||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#endif // X11
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct {
|
||||
int screen;
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win;
|
||||
Window parent;
|
||||
Display *dpy;
|
||||
GLXContext ctx;
|
||||
XSetWindowAttributes attr;
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
wxGLCanvas *glCanvas;
|
||||
wxFrame *frame;
|
||||
wxGLContext *glCtxt;
|
||||
#endif
|
||||
int x, y;
|
||||
unsigned int width, height;
|
||||
unsigned int depth;
|
||||
} GLWindow;
|
||||
|
||||
extern GLWindow GLWin;
|
||||
|
||||
#endif
|
||||
|
||||
// Public OpenGL util
|
||||
|
||||
// Initialization / upkeep
|
||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
||||
void OpenGL_Shutdown();
|
||||
void OpenGL_Update();
|
||||
bool OpenGL_MakeCurrent();
|
||||
void OpenGL_SwapBuffers();
|
||||
|
||||
// Get status
|
||||
u32 OpenGL_GetBackbufferWidth();
|
||||
u32 OpenGL_GetBackbufferHeight();
|
||||
|
||||
// Set things
|
||||
void OpenGL_SetWindowText(const char *text);
|
||||
|
||||
// Error reporting - use the convenient macros.
|
||||
void OpenGL_ReportARBProgramError();
|
||||
GLuint OpenGL_ReportGLError(const char *function, const char *file, int line);
|
||||
bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
||||
|
||||
#if 1
|
||||
#define GL_REPORT_ERROR() OpenGL_ReportGLError (__FUNCTION__, __FILE__, __LINE__)
|
||||
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
||||
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError (__FUNCTION__, __FILE__, __LINE__)
|
||||
#else
|
||||
#define GL_REPORT_ERROR() GL_NO_ERROR
|
||||
#define GL_REPORT_PROGRAM_ERROR()
|
||||
#define GL_REPORT_FBO_ERROR()
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
||||
#else
|
||||
#define GL_REPORT_ERRORD()
|
||||
#endif
|
||||
|
||||
#endif // GLTEST ??
|
||||
|
||||
#endif // _GLINIT_H_
|
||||
|
@ -53,9 +53,6 @@ conf = gfxenv.Configure(custom_tests = tests,
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
gfxenv['FRAMEWORKS'] = ['CoreFoundation', 'System', 'OpenGL', 'Cocoa', 'Cg']
|
||||
compileFlags = ['-x','objective-c++',]
|
||||
files += [ 'cocoaGL.m', ]
|
||||
|
||||
conf.CheckPKG('OpenGL')
|
||||
if gfxenv['HAVE_OPENCL']:
|
||||
gfxenv['FRAMEWORKS'] += ['OpenCL']
|
||||
|
@ -1,29 +0,0 @@
|
||||
#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
|
||||
|
@ -1,149 +0,0 @@
|
||||
#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