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:
parent
08b2e766d6
commit
d7b6766fe2
|
@ -769,10 +769,6 @@
|
|||
RelativePath=".\Src\GLUtil.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\GLWindow.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConverter.cpp"
|
||||
>
|
||||
|
|
|
@ -45,7 +45,7 @@ void OpenGL_SwapBuffers()
|
|||
#if defined(USE_WX) && USE_WX
|
||||
GLWin.glCanvas->SwapBuffers();
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLSwap(GLWin.cocoaCtx,GLWin.cocoaWin);
|
||||
[GLWin.cocoaCtx flushBuffer];
|
||||
#elif defined(_WIN32)
|
||||
SwapBuffers(hDC);
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
|
@ -68,7 +68,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);
|
||||
[GLWin.cocoaWin setTitle: [[[NSString alloc]
|
||||
initWithCString: text] autorelease]];
|
||||
#elif defined(_WIN32)
|
||||
// TODO convert text to unicode and change SetWindowTextA to SetWindowText
|
||||
SetWindowTextA(EmuWindow::GetWnd(), text);
|
||||
|
@ -101,8 +102,8 @@ unsigned int Callback_PeekMessages()
|
|||
// Show the current FPS
|
||||
void UpdateFPSDisplay(const char *text)
|
||||
{
|
||||
char temp[512];
|
||||
sprintf(temp, "SVN R%s: GL: %s", svn_rev_str, text);
|
||||
char temp[100];
|
||||
snprintf(temp, sizeof temp, "%s | OpenGL | %s", svn_rev_str, text);
|
||||
OpenGL_SetWindowText(temp);
|
||||
}
|
||||
|
||||
|
@ -330,8 +331,29 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||
GLWin.glCanvas->Show(true);
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
|
||||
GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
|
||||
NSOpenGLPixelFormatAttribute attr[2] = { NSOpenGLPFADoubleBuffer, 0 };
|
||||
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
|
||||
initWithAttributes: attr];
|
||||
if (fmt == nil) {
|
||||
printf("failed to create pixel format\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
GLWin.cocoaCtx = [[NSOpenGLContext alloc]
|
||||
initWithFormat: fmt shareContext: nil];
|
||||
[fmt release];
|
||||
if (GLWin.cocoaCtx == nil) {
|
||||
printf("failed to create context\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
GLWin.cocoaWin = [[NSWindow alloc]
|
||||
initWithContentRect: NSMakeRect(50, 50, _twidth, _theight)
|
||||
styleMask: NSTitledWindowMask | NSResizableWindowMask
|
||||
backing: NSBackingStoreBuffered defer: FALSE];
|
||||
[GLWin.cocoaWin setReleasedWhenClosed: YES];
|
||||
[GLWin.cocoaWin makeKeyAndOrderFront: nil];
|
||||
[GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]];
|
||||
|
||||
#elif defined(_WIN32)
|
||||
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait..."));
|
||||
|
@ -474,7 +496,7 @@ bool OpenGL_MakeCurrent()
|
|||
#if defined(USE_WX) && USE_WX
|
||||
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin);
|
||||
[GLWin.cocoaCtx makeCurrentContext];
|
||||
#elif defined(_WIN32)
|
||||
return wglMakeCurrent(hDC,hRC) ? true : false;
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
|
@ -503,8 +525,18 @@ void OpenGL_Update()
|
|||
s_backbuffer_height = height;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
int width, height;
|
||||
|
||||
// Is anything needed here?
|
||||
width = [[GLWin.cocoaWin contentView] frame].size.width;
|
||||
height = [[GLWin.cocoaWin contentView] frame].size.height;
|
||||
if (width == s_backbuffer_width && height == s_backbuffer_height)
|
||||
return;
|
||||
|
||||
[GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]];
|
||||
[GLWin.cocoaCtx update];
|
||||
[GLWin.cocoaCtx makeCurrentContext];
|
||||
s_backbuffer_width = width;
|
||||
s_backbuffer_height = height;
|
||||
|
||||
#elif defined(_WIN32)
|
||||
RECT rcWindow;
|
||||
|
@ -541,9 +573,9 @@ void OpenGL_Shutdown()
|
|||
#if defined(USE_WX) && USE_WX
|
||||
delete GLWin.glCanvas;
|
||||
#elif defined(__APPLE__)
|
||||
cocoaGLDeleteWindow(GLWin.cocoaWin);
|
||||
cocoaGLDelete(GLWin.cocoaCtx);
|
||||
|
||||
[GLWin.cocoaWin close];
|
||||
[GLWin.cocoaCtx clearDrawable];
|
||||
[GLWin.cocoaCtx release];
|
||||
#elif defined(_WIN32)
|
||||
if (hRC) // Do We Have A Rendering Context?
|
||||
{
|
||||
|
|
|
@ -20,39 +20,26 @@
|
|||
|
||||
#include "VideoConfig.h"
|
||||
#include "MathUtil.h"
|
||||
#include "Thread.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 <GL/gl.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include "Thread.h"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined __APPLE__
|
||||
#include <GL/glew.h>
|
||||
#include "cocoaGL.h"
|
||||
#endif // end USE_WX
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.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
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
// Copyright (C) 2003 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 _GLWINDOW_H_
|
||||
#define _GLWINDOW_H_
|
||||
|
||||
#include <vector>
|
||||
#include "Common.h"
|
||||
#include "Globals.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
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
enum OGL_Props
|
||||
{
|
||||
OGL_FULLSCREEN,
|
||||
OGL_KEEPRATIO,
|
||||
OGL_HIDECURSOR,
|
||||
OGL_PROP_COUNT
|
||||
};
|
||||
|
||||
struct res
|
||||
{
|
||||
u32 x;
|
||||
u32 y;
|
||||
};
|
||||
|
||||
class GLWindow {
|
||||
private:
|
||||
|
||||
// TODO: what is xmax and ymax? do we need [xy]render?
|
||||
u32 xWin, yWin; // Windows' size
|
||||
int xOffset, yOffset; // Offset in window
|
||||
float xMax, yMax; // ???
|
||||
u32 xRender, yRender; // Render area
|
||||
|
||||
bool properties[OGL_PROP_COUNT];
|
||||
|
||||
protected:
|
||||
|
||||
EventHandler* eventHandler;
|
||||
res origRes, currFullRes, currWinRes;
|
||||
static std::vector<res> fullResolutions;
|
||||
virtual void SetRender(u32 x, u32 y)
|
||||
{
|
||||
xRender = x;
|
||||
yRender = y;
|
||||
}
|
||||
|
||||
static const std::vector<res>& getFsResolutions()
|
||||
{
|
||||
return fullResolutions;
|
||||
}
|
||||
|
||||
static void addFSResolution(res fsr)
|
||||
{
|
||||
fullResolutions.push_back(fsr);
|
||||
}
|
||||
public:
|
||||
|
||||
virtual void SwapBuffers() {};
|
||||
virtual void SetWindowText(const char *text) {};
|
||||
virtual bool PeekMessages() {return false;};
|
||||
virtual void Update() {};
|
||||
virtual bool MakeCurrent() {return false;};
|
||||
|
||||
virtual void updateDim()
|
||||
{
|
||||
if (GetProperty(OGL_FULLSCREEN))
|
||||
SetWinSize(currFullRes.x, currFullRes.y);
|
||||
else
|
||||
// Set the windowed resolution
|
||||
SetWinSize(currWinRes.x, currWinRes.y);
|
||||
|
||||
float FactorX = 640.0f / (float)GetXwin();
|
||||
float FactorY = 480.0f / (float)GetYwin();
|
||||
//float Max = (FactorX < FactorY) ? FactorX : FactorY;
|
||||
|
||||
SetMax(1.0f / FactorX, 1.0f / FactorY);
|
||||
SetOffset(0,0);
|
||||
}
|
||||
|
||||
void SetEventHandler(EventHandler *eh) { eventHandler = eh;}
|
||||
bool GetProperty(OGL_Props prop) {return properties[prop];}
|
||||
virtual bool SetProperty(OGL_Props prop, bool value)
|
||||
{return properties[prop] = value;}
|
||||
|
||||
u32 GetXrender() {return xRender;}
|
||||
u32 GetYrender() {return yRender;}
|
||||
|
||||
u32 GetXwin() {return xWin;}
|
||||
u32 GetYwin() {return yWin;}
|
||||
void SetWinSize(u32 x, u32 y)
|
||||
{
|
||||
xWin = x;
|
||||
yWin = y;
|
||||
}
|
||||
|
||||
int GetYoff() {return yOffset;}
|
||||
int GetXoff() {return xOffset;}
|
||||
void SetOffset(int x, int y)
|
||||
{
|
||||
yOffset = y;
|
||||
xOffset = x;
|
||||
}
|
||||
|
||||
void SetMax(float x, float y)
|
||||
{
|
||||
yMax = y;
|
||||
xMax = x;
|
||||
}
|
||||
|
||||
float GetXmax() {return xMax;}
|
||||
float GetYmax() {return yMax;}
|
||||
|
||||
static bool valid() { return false;}
|
||||
|
||||
GLWindow()
|
||||
{
|
||||
// Load defaults
|
||||
sscanf(g_Config.iFSResolution, "%dx%d",
|
||||
&currFullRes.x, &currFullRes.y);
|
||||
|
||||
sscanf(g_Config.iInternalRes, "%dx%d",
|
||||
&currWinRes.x, &currWinRes.y);
|
||||
|
||||
SetProperty(OGL_FULLSCREEN, g_Config.bFullscreen);
|
||||
// What does this do?
|
||||
SetProperty(OGL_KEEPRATIO, g_Config.bKeepAR43);
|
||||
SetProperty(OGL_HIDECURSOR, g_Config.bHideCursor);
|
||||
|
||||
updateDim();
|
||||
}
|
||||
|
||||
|
||||
// setResolution
|
||||
// resolution iter
|
||||
};
|
||||
|
||||
#endif // _GLWINDOW_H_
|
|
@ -23,7 +23,4 @@ files = [
|
|||
|
||||
libs = [ 'videocommon', 'videouicommon', 'GLEW', 'SOIL', 'common' ]
|
||||
|
||||
if sys.platform == 'darwin' and not env['HAVE_WX']:
|
||||
files += [ 'cocoaGL.m' ]
|
||||
|
||||
env.SharedLibrary(env['plugin_dir'] + name, files, LIBS = env['LIBS'] + libs)
|
||||
|
|
|
@ -1,28 +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,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");
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -37,9 +37,7 @@ 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' ]
|
||||
|
|
|
@ -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,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");
|
||||
}
|
Loading…
Reference in New Issue