Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Allow specifying of OpenGL 3.2 Core Profile on Mac OS X.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 11, 2012
1 parent 109a957 commit 9771299
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/video/cocoa/SDL_cocoaopengl.m
Expand Up @@ -32,9 +32,16 @@
#include "SDL_loadso.h"
#include "SDL_opengl.h"


#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"


#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
#define kCGLPFAOpenGLProfile 99
#define kCGLOGLPVersion_Legacy 0x1000
#define kCGLOGLPVersion_3_2_Core 0x3200
#endif


int
Cocoa_GL_LoadLibrary(_THIS, const char *path)
{
Expand Down Expand Up @@ -70,6 +77,9 @@
SDL_GLContext
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
{
const int wantver = (_this->gl_config.major_version << 8) |
(_this->gl_config.minor_version);
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
NSAutoreleasePool *pool;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
Expand All @@ -78,8 +88,32 @@
NSOpenGLContext *context;
int i = 0;

if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
SDL_SetError ("OpenGL ES not supported on this platform");
return NULL;
}

/* Sadly, we'll have to update this as life progresses, since we need to
set an enum for context profiles, not a context version number */
if (wantver > 0x0302) {
SDL_SetError ("OpenGL > 3.2 is not supported on this platform");
return NULL;
}

pool = [[NSAutoreleasePool alloc] init];

/* specify a profile if we're on Lion (10.7) or later. */
if (data->osversion >= 0x1070) {
NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
if (wantver == 0x0302) {
profile = kCGLOGLPVersion_3_2_Core;
}
}
attr[i++] = kCGLPFAOpenGLProfile;
attr[i++] = profile;
}

#ifndef FULLSCREEN_TOGGLEABLE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
attr[i++] = NSOpenGLPFAFullScreen;
Expand Down

0 comments on commit 9771299

Please sign in to comment.