src/video/cocoa/SDL_cocoaopengl.m
author Sam Lantinga <slouken@libsdl.org>
Mon, 10 Mar 2014 18:45:07 -0700
changeset 8601 4c04c7785cba
parent 8278 e60a7bb2b80b
child 8604 459bd7365e9d
permissions -rw-r--r--
Fixed regression causing the renderer to recreate its window since it's not getting an OpenGL 2.1 context anymore.
slouken@1936
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@1936
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1936
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1936
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1936
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@1936
    22
slouken@1936
    23
/* NSOpenGL implementation of SDL OpenGL support */
slouken@1936
    24
slouken@1952
    25
#if SDL_VIDEO_OPENGL_CGL
slouken@6044
    26
#include "SDL_cocoavideo.h"
jorgen@7594
    27
#include "SDL_cocoaopengl.h"
slouken@6044
    28
slouken@1936
    29
#include <OpenGL/CGLTypes.h>
slouken@2738
    30
#include <OpenGL/OpenGL.h>
slouken@3570
    31
#include <OpenGL/CGLRenderers.h>
slouken@1936
    32
slouken@1936
    33
#include "SDL_loadso.h"
slouken@1936
    34
#include "SDL_opengl.h"
slouken@1936
    35
icculus@6567
    36
#define DEFAULT_OPENGL  "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
slouken@1936
    37
icculus@8276
    38
#ifndef NSOpenGLPFAOpenGLProfile
icculus@8276
    39
#define NSOpenGLPFAOpenGLProfile 99
slouken@6952
    40
#endif
icculus@8276
    41
#ifndef NSOpenGLProfileVersionLegacy
icculus@8276
    42
#define NSOpenGLProfileVersionLegacy 0x1000
slouken@6952
    43
#endif
icculus@8276
    44
#ifndef NSOpenGLProfileVersion3_2Core
icculus@8276
    45
#define NSOpenGLProfileVersion3_2Core 0x3200
icculus@6567
    46
#endif
icculus@6567
    47
jorgen@7594
    48
@implementation SDLOpenGLContext : NSOpenGLContext
jorgen@7594
    49
jorgen@7594
    50
- (id)initWithFormat:(NSOpenGLPixelFormat *)format
jorgen@7594
    51
        shareContext:(NSOpenGLContext *)share
jorgen@7594
    52
{
jorgen@7595
    53
    self = [super initWithFormat:format shareContext:share];
jorgen@7595
    54
    if (self) {
jorgen@7595
    55
        SDL_AtomicSet(&self->dirty, 0);
jorgen@7595
    56
        self->window = NULL;
jorgen@7595
    57
    }
jorgen@7595
    58
    return self;
jorgen@7594
    59
}
jorgen@7594
    60
jorgen@7594
    61
- (void)scheduleUpdate
jorgen@7594
    62
{
jorgen@7594
    63
    SDL_AtomicAdd(&self->dirty, 1);
jorgen@7594
    64
}
jorgen@7594
    65
jorgen@7594
    66
/* This should only be called on the thread on which a user is using the context. */
jorgen@7594
    67
- (void)updateIfNeeded
jorgen@7594
    68
{
jorgen@7594
    69
    int value = SDL_AtomicSet(&self->dirty, 0);
jorgen@7594
    70
    if (value > 0) {
jorgen@7594
    71
        /* We call the real underlying update here, since -[SDLOpenGLContext update] just calls us. */
jorgen@7594
    72
        [super update];
jorgen@7594
    73
    }
jorgen@7594
    74
}
jorgen@7594
    75
jorgen@7594
    76
/* This should only be called on the thread on which a user is using the context. */
jorgen@7594
    77
- (void)update
jorgen@7594
    78
{
jorgen@7594
    79
    /* This ensures that regular 'update' calls clear the atomic dirty flag. */
jorgen@7594
    80
    [self scheduleUpdate];
jorgen@7594
    81
    [self updateIfNeeded];
jorgen@7594
    82
}
jorgen@7594
    83
jorgen@7595
    84
/* Updates the drawable for the contexts and manages related state. */
jorgen@7595
    85
- (void)setWindow:(SDL_Window *)newWindow
jorgen@7595
    86
{
jorgen@7595
    87
    if (self->window) {
jorgen@7595
    88
        SDL_WindowData *oldwindowdata = (SDL_WindowData *)self->window->driverdata;
jorgen@7595
    89
jorgen@7595
    90
        /* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */
jorgen@7595
    91
        NSMutableArray *contexts = oldwindowdata->nscontexts;
jorgen@7595
    92
        @synchronized (contexts) {
jorgen@7595
    93
            [contexts removeObject:self];
jorgen@7595
    94
        }
jorgen@7595
    95
    }
jorgen@7595
    96
jorgen@7595
    97
    self->window = newWindow;
jorgen@7595
    98
jorgen@7595
    99
    if (newWindow) {
jorgen@7595
   100
        SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
jorgen@7595
   101
jorgen@7595
   102
        /* Now sign up for scheduled updates for the new window. */
jorgen@7595
   103
        NSMutableArray *contexts = windowdata->nscontexts;
jorgen@7595
   104
        @synchronized (contexts) {
jorgen@7595
   105
            [contexts addObject:self];
jorgen@7595
   106
        }
jorgen@7595
   107
jorgen@7595
   108
        if ([self view] != [windowdata->nswindow contentView]) {
jorgen@7595
   109
            [self setView:[windowdata->nswindow contentView]];
jorgen@8258
   110
            if (self == [NSOpenGLContext currentContext]) {
jorgen@8258
   111
                [self update];
jorgen@8258
   112
            } else {
jorgen@8258
   113
                [self scheduleUpdate];
jorgen@8258
   114
            }
jorgen@7595
   115
        }
jorgen@7595
   116
    } else {
jorgen@7595
   117
        [self clearDrawable];
jorgen@8258
   118
        if (self == [NSOpenGLContext currentContext]) {
jorgen@8258
   119
            [self update];
jorgen@8258
   120
        } else {
jorgen@8258
   121
            [self scheduleUpdate];
jorgen@8258
   122
        }
jorgen@7595
   123
    }
jorgen@7595
   124
}
jorgen@7595
   125
jorgen@7594
   126
@end
jorgen@7594
   127
slouken@1936
   128
slouken@1936
   129
int
slouken@1936
   130
Cocoa_GL_LoadLibrary(_THIS, const char *path)
slouken@1936
   131
{
slouken@3057
   132
    /* Load the OpenGL library */
slouken@1936
   133
    if (path == NULL) {
slouken@1952
   134
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
slouken@1952
   135
    }
slouken@1952
   136
    if (path == NULL) {
slouken@1952
   137
        path = DEFAULT_OPENGL;
slouken@1936
   138
    }
slouken@1936
   139
    _this->gl_config.dll_handle = SDL_LoadObject(path);
slouken@1936
   140
    if (!_this->gl_config.dll_handle) {
slouken@1936
   141
        return -1;
slouken@1936
   142
    }
slouken@1936
   143
    SDL_strlcpy(_this->gl_config.driver_path, path,
slouken@1936
   144
                SDL_arraysize(_this->gl_config.driver_path));
slouken@1936
   145
    return 0;
slouken@1936
   146
}
slouken@1936
   147
slouken@1936
   148
void *
slouken@1936
   149
Cocoa_GL_GetProcAddress(_THIS, const char *proc)
slouken@1936
   150
{
slouken@1936
   151
    return SDL_LoadFunction(_this->gl_config.dll_handle, proc);
slouken@1936
   152
}
slouken@1936
   153
slouken@3057
   154
void
slouken@1936
   155
Cocoa_GL_UnloadLibrary(_THIS)
slouken@1936
   156
{
slouken@3057
   157
    SDL_UnloadObject(_this->gl_config.dll_handle);
slouken@3057
   158
    _this->gl_config.dll_handle = NULL;
slouken@1936
   159
}
slouken@1936
   160
slouken@1936
   161
SDL_GLContext
slouken@1936
   162
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
slouken@1936
   163
{
icculus@6567
   164
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@8601
   165
/*
icculus@8278
   166
    const GLubyte *(APIENTRY * glGetStringFunc)(GLenum) = NULL;
slouken@8601
   167
*/
slouken@6848
   168
    NSAutoreleasePool *pool;
slouken@5246
   169
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
slouken@1936
   170
    SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
slouken@1936
   171
    NSOpenGLPixelFormatAttribute attr[32];
slouken@1936
   172
    NSOpenGLPixelFormat *fmt;
jorgen@7594
   173
    SDLOpenGLContext *context;
flibitijibibo@7152
   174
    NSOpenGLContext *share_context = nil;
slouken@1936
   175
    int i = 0;
icculus@8276
   176
    const char *glversion;
icculus@8276
   177
    int glversion_major;
icculus@8276
   178
    int glversion_minor;
slouken@1936
   179
icculus@6567
   180
    if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
icculus@7894
   181
        SDL_SetError ("OpenGL ES is not supported on this platform");
icculus@6567
   182
        return NULL;
icculus@6567
   183
    }
icculus@8276
   184
    if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && (data->osversion < 0x1070)) {
icculus@8276
   185
        SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
icculus@6567
   186
        return NULL;
icculus@6567
   187
    }
icculus@6567
   188
slouken@6848
   189
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   190
slouken@6848
   191
    /* specify a profile if we're on Lion (10.7) or later. */
slouken@6848
   192
    if (data->osversion >= 0x1070) {
icculus@8276
   193
        NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
slouken@6848
   194
        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
icculus@8276
   195
            profile = NSOpenGLProfileVersion3_2Core;
alexey@6832
   196
        }
icculus@8276
   197
        attr[i++] = NSOpenGLPFAOpenGLProfile;
slouken@6848
   198
        attr[i++] = profile;
slouken@6848
   199
    }
slouken@1936
   200
slouken@6848
   201
    attr[i++] = NSOpenGLPFAColorSize;
slouken@6848
   202
    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
slouken@6848
   203
slouken@6848
   204
    attr[i++] = NSOpenGLPFADepthSize;
slouken@6848
   205
    attr[i++] = _this->gl_config.depth_size;
slouken@6848
   206
slouken@6848
   207
    if (_this->gl_config.double_buffer) {
slouken@6848
   208
        attr[i++] = NSOpenGLPFADoubleBuffer;
slouken@6848
   209
    }
slouken@6848
   210
slouken@6848
   211
    if (_this->gl_config.stereo) {
slouken@6848
   212
        attr[i++] = NSOpenGLPFAStereo;
slouken@6848
   213
    }
slouken@6848
   214
slouken@6848
   215
    if (_this->gl_config.stencil_size) {
slouken@6848
   216
        attr[i++] = NSOpenGLPFAStencilSize;
slouken@6848
   217
        attr[i++] = _this->gl_config.stencil_size;
slouken@6848
   218
    }
slouken@6848
   219
slouken@6848
   220
    if ((_this->gl_config.accum_red_size +
slouken@6848
   221
         _this->gl_config.accum_green_size +
slouken@6848
   222
         _this->gl_config.accum_blue_size +
slouken@6848
   223
         _this->gl_config.accum_alpha_size) > 0) {
slouken@6848
   224
        attr[i++] = NSOpenGLPFAAccumSize;
slouken@6848
   225
        attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
slouken@6848
   226
    }
slouken@6848
   227
slouken@6848
   228
    if (_this->gl_config.multisamplebuffers) {
slouken@6848
   229
        attr[i++] = NSOpenGLPFASampleBuffers;
slouken@6848
   230
        attr[i++] = _this->gl_config.multisamplebuffers;
slouken@6848
   231
    }
slouken@6848
   232
slouken@6848
   233
    if (_this->gl_config.multisamplesamples) {
slouken@6848
   234
        attr[i++] = NSOpenGLPFASamples;
slouken@6848
   235
        attr[i++] = _this->gl_config.multisamplesamples;
slouken@6848
   236
        attr[i++] = NSOpenGLPFANoRecovery;
slouken@6848
   237
    }
slouken@6848
   238
slouken@6848
   239
    if (_this->gl_config.accelerated >= 0) {
slouken@6848
   240
        if (_this->gl_config.accelerated) {
slouken@6848
   241
            attr[i++] = NSOpenGLPFAAccelerated;
slouken@6848
   242
        } else {
slouken@6848
   243
            attr[i++] = NSOpenGLPFARendererID;
slouken@6848
   244
            attr[i++] = kCGLRendererGenericFloatID;
alexey@6832
   245
        }
slouken@6848
   246
    }
slouken@6848
   247
slouken@6848
   248
    attr[i++] = NSOpenGLPFAScreenMask;
slouken@6848
   249
    attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
slouken@6848
   250
    attr[i] = 0;
slouken@6848
   251
slouken@6848
   252
    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
slouken@6848
   253
    if (fmt == nil) {
slouken@8601
   254
        SDL_SetError("Failed creating OpenGL pixel format");
slouken@6848
   255
        [pool release];
slouken@6848
   256
        return NULL;
slouken@6848
   257
    }
slouken@6848
   258
flibitijibibo@7152
   259
    if (_this->gl_config.share_with_current_context) {
slouken@7412
   260
        share_context = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
flibitijibibo@7152
   261
    }
flibitijibibo@7152
   262
jorgen@7594
   263
    context = [[SDLOpenGLContext alloc] initWithFormat:fmt shareContext:share_context];
slouken@6848
   264
slouken@6848
   265
    [fmt release];
slouken@6848
   266
slouken@6848
   267
    if (context == nil) {
slouken@8601
   268
        SDL_SetError("Failed creating OpenGL context");
slouken@6848
   269
        [pool release];
slouken@6848
   270
        return NULL;
slouken@6848
   271
    }
slouken@6848
   272
slouken@6848
   273
    [pool release];
slouken@1936
   274
slouken@2178
   275
    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
slouken@2178
   276
        Cocoa_GL_DeleteContext(_this, context);
slouken@8601
   277
        SDL_SetError("Failed making OpenGL context current");
slouken@2178
   278
        return NULL;
slouken@2178
   279
    }
slouken@2178
   280
slouken@8601
   281
/* No other backend does this version checking.
slouken@8601
   282
   If we enable it, we should consider whether it should be done at a 
slouken@8601
   283
   higher level for all platforms. We'll have to think through the implications
slouken@8601
   284
   of this.
slouken@8601
   285
slouken@8601
   286
   For example, Mac OS X 10.6 will only report OpenGL 2.0, but we ask for 2.1
slouken@8601
   287
   by default. If we don't get 2.1, then the renderer will set the requested
slouken@8601
   288
   version and try to recreate the window, which causes all kinds of problems.
slouken@8601
   289
slouken@8601
   290
   For now, we'll just disable this code until we can think about it more.
slouken@8601
   291
*/
slouken@8601
   292
#if 0
icculus@8278
   293
    glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
icculus@8278
   294
    if (!glGetStringFunc) {
icculus@8278
   295
        Cocoa_GL_DeleteContext(_this, context);
icculus@8278
   296
        SDL_SetError ("Failed getting OpenGL glGetString entry point");
icculus@8278
   297
        return NULL;
icculus@8278
   298
    }
icculus@8278
   299
icculus@8278
   300
    glversion = (const char *)glGetStringFunc(GL_VERSION);
icculus@8276
   301
    if (glversion == NULL) {
icculus@8276
   302
        Cocoa_GL_DeleteContext(_this, context);
icculus@8276
   303
        SDL_SetError ("Failed getting OpenGL context version");
icculus@8276
   304
        return NULL;
icculus@8276
   305
    }
icculus@8276
   306
icculus@8276
   307
    if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
icculus@8276
   308
        Cocoa_GL_DeleteContext(_this, context);
icculus@8276
   309
        SDL_SetError ("Failed parsing OpenGL context version");
icculus@8276
   310
        return NULL;
icculus@8276
   311
    }
icculus@8276
   312
icculus@8276
   313
    if ((glversion_major <  _this->gl_config.major_version) ||
icculus@8276
   314
       ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
icculus@8276
   315
        Cocoa_GL_DeleteContext(_this, context);
icculus@8276
   316
        SDL_SetError ("Failed creating OpenGL context at version requested");
icculus@8276
   317
        return NULL;
icculus@8276
   318
    }
icculus@8276
   319
icculus@8276
   320
    _this->gl_config.major_version = glversion_major;
icculus@8276
   321
    _this->gl_config.minor_version = glversion_minor;
slouken@8601
   322
#endif
icculus@8276
   323
slouken@2178
   324
    return context;
slouken@1936
   325
}
slouken@1936
   326
slouken@1936
   327
int
slouken@1936
   328
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
slouken@1936
   329
{
slouken@6848
   330
    NSAutoreleasePool *pool;
slouken@1936
   331
slouken@6848
   332
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   333
slouken@6848
   334
    if (context) {
jorgen@7594
   335
        SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
jorgen@7595
   336
        [nscontext setWindow:window];
jorgen@7594
   337
        [nscontext updateIfNeeded];
slouken@6848
   338
        [nscontext makeCurrentContext];
slouken@6848
   339
    } else {
slouken@6848
   340
        [NSOpenGLContext clearCurrentContext];
slouken@1936
   341
    }
slouken@1936
   342
slouken@6848
   343
    [pool release];
slouken@1936
   344
    return 0;
slouken@1936
   345
}
slouken@1936
   346
urkle@7746
   347
void
urkle@7746
   348
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
urkle@7746
   349
{
urkle@7746
   350
    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
urkle@7746
   351
    NSView *contentView = [windata->nswindow contentView];
urkle@7746
   352
    NSRect viewport = [contentView bounds];
urkle@7746
   353
urkle@7746
   354
    /* This gives us the correct viewport for a Retina-enabled view, only
urkle@7746
   355
     * supported on 10.7+. */
urkle@7746
   356
    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
urkle@7746
   357
        viewport = [contentView convertRectToBacking:viewport];
urkle@7746
   358
    }
urkle@7746
   359
urkle@7746
   360
    if (w) {
urkle@7746
   361
        *w = viewport.size.width;
urkle@7746
   362
    }
urkle@7746
   363
urkle@7746
   364
    if (h) {
urkle@7746
   365
        *h = viewport.size.height;
urkle@7746
   366
    }
urkle@7746
   367
}
urkle@7746
   368
slouken@1936
   369
int
slouken@1936
   370
Cocoa_GL_SetSwapInterval(_THIS, int interval)
slouken@1936
   371
{
slouken@6848
   372
    NSAutoreleasePool *pool;
slouken@1936
   373
    NSOpenGLContext *nscontext;
slouken@2703
   374
    GLint value;
slouken@1936
   375
    int status;
slouken@1936
   376
icculus@7743
   377
    if (interval < 0) {  /* no extension for this on Mac OS X at the moment. */
icculus@7743
   378
        return SDL_SetError("Late swap tearing currently unsupported");
icculus@7743
   379
    }
icculus@7743
   380
slouken@6848
   381
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   382
jorgen@7594
   383
    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
slouken@6848
   384
    if (nscontext != nil) {
slouken@6848
   385
        value = interval;
slouken@6848
   386
        [nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
slouken@6848
   387
        status = 0;
slouken@6848
   388
    } else {
icculus@7037
   389
        status = SDL_SetError("No current OpenGL context");
slouken@1936
   390
    }
slouken@1936
   391
slouken@6848
   392
    [pool release];
slouken@1936
   393
    return status;
slouken@1936
   394
}
slouken@1936
   395
slouken@1936
   396
int
slouken@1936
   397
Cocoa_GL_GetSwapInterval(_THIS)
slouken@1936
   398
{
slouken@6848
   399
    NSAutoreleasePool *pool;
slouken@1936
   400
    NSOpenGLContext *nscontext;
slouken@2703
   401
    GLint value;
icculus@6382
   402
    int status = 0;
slouken@1936
   403
slouken@6848
   404
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   405
jorgen@7594
   406
    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
slouken@6848
   407
    if (nscontext != nil) {
slouken@6848
   408
        [nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
slouken@6848
   409
        status = (int)value;
slouken@1936
   410
    }
slouken@1936
   411
slouken@6848
   412
    [pool release];
slouken@1936
   413
    return status;
slouken@1936
   414
}
slouken@1936
   415
slouken@1936
   416
void
slouken@1936
   417
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
slouken@1936
   418
{
slouken@6848
   419
    NSAutoreleasePool *pool;
slouken@1936
   420
slouken@6848
   421
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   422
slouken@7738
   423
    SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
slouken@7408
   424
    [nscontext flushBuffer];
jorgen@7594
   425
    [nscontext updateIfNeeded];
slouken@6848
   426
slouken@6848
   427
    [pool release];
slouken@1936
   428
}
slouken@1936
   429
slouken@1936
   430
void
slouken@1936
   431
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
slouken@1936
   432
{
slouken@6848
   433
    NSAutoreleasePool *pool;
jorgen@7595
   434
    SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
slouken@1936
   435
slouken@6848
   436
    pool = [[NSAutoreleasePool alloc] init];
slouken@6848
   437
jorgen@7595
   438
    [nscontext setWindow:NULL];
slouken@6848
   439
    [nscontext release];
slouken@6848
   440
slouken@6848
   441
    [pool release];
slouken@1936
   442
}
slouken@1936
   443
slouken@1952
   444
#endif /* SDL_VIDEO_OPENGL_CGL */
slouken@1936
   445
slouken@1936
   446
/* vi: set ts=4 sw=4 expandtab: */