src/video/cocoa/SDL_cocoaopengl.m
changeset 9587 18979eac0a35
parent 8986 1c81316ac642
child 9619 b94b6d0bff0f
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Tue May 05 16:24:05 2015 -0300
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Tue May 05 19:01:55 2015 -0300
     1.3 @@ -150,8 +150,8 @@
     1.4  
     1.5  SDL_GLContext
     1.6  Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
     1.7 +{ @autoreleasepool
     1.8  {
     1.9 -    NSAutoreleasePool *pool;
    1.10      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.11      SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
    1.12      SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
    1.13 @@ -173,8 +173,6 @@
    1.14          return NULL;
    1.15      }
    1.16  
    1.17 -    pool = [[NSAutoreleasePool alloc] init];
    1.18 -
    1.19      /* specify a profile if we're on Lion (10.7) or later. */
    1.20      if (lion_or_later) {
    1.21          NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
    1.22 @@ -239,7 +237,6 @@
    1.23      fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    1.24      if (fmt == nil) {
    1.25          SDL_SetError("Failed creating OpenGL pixel format");
    1.26 -        [pool release];
    1.27          return NULL;
    1.28      }
    1.29  
    1.30 @@ -253,12 +250,9 @@
    1.31  
    1.32      if (context == nil) {
    1.33          SDL_SetError("Failed creating OpenGL context");
    1.34 -        [pool release];
    1.35          return NULL;
    1.36      }
    1.37  
    1.38 -    [pool release];
    1.39 -
    1.40      if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    1.41          Cocoa_GL_DeleteContext(_this, context);
    1.42          SDL_SetError("Failed making OpenGL context current");
    1.43 @@ -306,15 +300,12 @@
    1.44          /*_this->gl_config.minor_version = glversion_minor;*/
    1.45      }
    1.46      return context;
    1.47 -}
    1.48 +}}
    1.49  
    1.50  int
    1.51  Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
    1.52 +{ @autoreleasepool
    1.53  {
    1.54 -    NSAutoreleasePool *pool;
    1.55 -
    1.56 -    pool = [[NSAutoreleasePool alloc] init];
    1.57 -
    1.58      if (context) {
    1.59          SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    1.60          [nscontext setWindow:window];
    1.61 @@ -324,9 +315,8 @@
    1.62          [NSOpenGLContext clearCurrentContext];
    1.63      }
    1.64  
    1.65 -    [pool release];
    1.66      return 0;
    1.67 -}
    1.68 +}}
    1.69  
    1.70  void
    1.71  Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
    1.72 @@ -352,8 +342,8 @@
    1.73  
    1.74  int
    1.75  Cocoa_GL_SetSwapInterval(_THIS, int interval)
    1.76 +{ @autoreleasepool
    1.77  {
    1.78 -    NSAutoreleasePool *pool;
    1.79      NSOpenGLContext *nscontext;
    1.80      GLint value;
    1.81      int status;
    1.82 @@ -362,8 +352,6 @@
    1.83          return SDL_SetError("Late swap tearing currently unsupported");
    1.84      }
    1.85  
    1.86 -    pool = [[NSAutoreleasePool alloc] init];
    1.87 -
    1.88      nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
    1.89      if (nscontext != nil) {
    1.90          value = interval;
    1.91 @@ -373,57 +361,44 @@
    1.92          status = SDL_SetError("No current OpenGL context");
    1.93      }
    1.94  
    1.95 -    [pool release];
    1.96      return status;
    1.97 -}
    1.98 +}}
    1.99  
   1.100  int
   1.101  Cocoa_GL_GetSwapInterval(_THIS)
   1.102 +{ @autoreleasepool
   1.103  {
   1.104 -    NSAutoreleasePool *pool;
   1.105      NSOpenGLContext *nscontext;
   1.106      GLint value;
   1.107      int status = 0;
   1.108  
   1.109 -    pool = [[NSAutoreleasePool alloc] init];
   1.110 -
   1.111      nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
   1.112      if (nscontext != nil) {
   1.113          [nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
   1.114          status = (int)value;
   1.115      }
   1.116  
   1.117 -    [pool release];
   1.118      return status;
   1.119 -}
   1.120 +}}
   1.121  
   1.122  void
   1.123  Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
   1.124 +{ @autoreleasepool
   1.125  {
   1.126 -    NSAutoreleasePool *pool;
   1.127 -
   1.128 -    pool = [[NSAutoreleasePool alloc] init];
   1.129 -
   1.130      SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
   1.131      [nscontext flushBuffer];
   1.132      [nscontext updateIfNeeded];
   1.133 -
   1.134 -    [pool release];
   1.135 -}
   1.136 +}}
   1.137  
   1.138  void
   1.139  Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
   1.140 +{ @autoreleasepool
   1.141  {
   1.142 -    NSAutoreleasePool *pool;
   1.143      SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
   1.144  
   1.145 -    pool = [[NSAutoreleasePool alloc] init];
   1.146 -
   1.147      [nscontext setWindow:NULL];
   1.148      [nscontext release];
   1.149 -
   1.150 -    [pool release];
   1.151 -}
   1.152 +}}
   1.153  
   1.154  #endif /* SDL_VIDEO_OPENGL_CGL */
   1.155