Fix cocoaGL window resizing.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6807 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-01-10 23:48:59 +00:00
parent 08b2e766d6
commit d7b6766fe2
12 changed files with 65 additions and 510 deletions

View File

@ -94,8 +94,8 @@ unsigned int Callback_PeekMessages()
// Show the current FPS
void UpdateFPSDisplay(const char *text)
{
char temp[512];
sprintf(temp, "SVN R%s: SW: %s", svn_rev_str, text);
char temp[100];
snprintf(temp, sizeof temp, "%s | Software | %s", svn_rev_str, text);
OpenGL_SetWindowText(temp);
}

View File

@ -19,40 +19,28 @@
#ifndef _GLINIT_H_
#define _GLINIT_H_
#include "Common.h"
#include <string>
#include "VideoConfig.h"
#include "pluginspecs_video.h"
#ifdef _WIN32
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/wglew.h>
#else
#if defined(USE_WX) && USE_WX
#include <GL/glew.h>
#include "wx/wx.h"
#include "wx/glcanvas.h"
#elif defined(HAVE_X11) && HAVE_X11
#elif defined HAVE_X11 && HAVE_X11
#include <GL/glxew.h>
#include <X11/XKBlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#else
#include <GL/glew.h>
#endif // end USE_WX
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h>
#elif defined __APPLE__
#include <GL/glew.h>
#import <AppKit/AppKit.h>
#endif
#if defined USE_WX && USE_WX
#include "wx/wx.h"
#include "wx/glcanvas.h"
#endif
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils

View File

@ -37,11 +37,9 @@ files = [
if env['HAVE_WX']:
files += [ 'VideoConfigDialog.cpp' ]
if sys.platform == 'darwin' and not env['HAVE_WX']:
files += [ 'cocoaGL.m' ]
elif sys.platform == 'win32':
if sys.platform == 'win32':
files += [ 'Win32.cpp' ]
libs = [ 'videocommon', 'GLEW', 'SOIL', 'common' ]
env.SharedLibrary(env['plugin_dir'] + name, files, LIBS = env['LIBS'] + libs)

View File

@ -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

View File

@ -1,109 +0,0 @@
#import "cocoaGL.h"
NSWindow *cocoaGLCreateWindow(int w, int h)
{
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];
return window;
}
void cocoaGLSetTitle(NSWindow *win, const char *title)
{
[win setTitle: [[[NSString alloc] initWithCString: title
encoding: NSASCIIStringEncoding] autorelease]];
}
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
{
int value = 0;
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
if (ctx) {
[ctx setView:[win contentView]];
[ctx update];
[ctx makeCurrentContext];
}
else
[NSOpenGLContext clearCurrentContext];
}
NSOpenGLContext* cocoaGLInit(int mode)
{
NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt;
NSOpenGLContext *context;
int i = 0;
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");
return NULL;
}
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
[fmt release];
if (context == nil) {
printf("failed to create context\n");
return NULL;
}
return context;
}
void cocoaGLDelete(NSOpenGLContext *ctx)
{
[ctx clearDrawable];
[ctx release];
}
void cocoaGLDeleteWindow(NSWindow *window)
{
[window close];
return;
}
void cocoaGLSwap(NSOpenGLContext *ctx, NSWindow *window)
{
[window makeKeyAndOrderFront: nil];
ctx = [NSOpenGLContext currentContext];
if (ctx != nil)
[ctx flushBuffer];
else
printf("bad cocoa gl ctx\n");
}