Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
authorRyan C. Gordon
Wed, 23 Nov 2005 07:23:48 +0000
changeset 1189c96b326b90ba
parent 1188 f31856cf29ae
child 1190 173c063d4f55
Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
src/video/quartz/SDL_QuartzGL.m
src/video/quartz/SDL_QuartzVideo.h
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/video/quartz/SDL_QuartzGL.m	Wed Nov 23 07:07:19 2005 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzGL.m	Wed Nov 23 07:23:48 2005 +0000
     1.3 @@ -166,63 +166,33 @@
     1.4  
     1.5  
     1.6  /* SDL OpenGL functions */
     1.7 +static const char *DEFAULT_OPENGL_LIB_NAME =
     1.8 +    "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
     1.9  
    1.10  int    QZ_GL_LoadLibrary    (_THIS, const char *location) {
    1.11 -    CFURLRef bundleURL;
    1.12 -    CFStringRef cfstr;
    1.13 -
    1.14      if ( gl_context != NULL ) {
    1.15          SDL_SetError("OpenGL context already created");
    1.16          return -1;
    1.17      }
    1.18  
    1.19 -    if (opengl_bundle != NULL)
    1.20 -        CFRelease(opengl_bundle);
    1.21 -
    1.22 -    opengl_bundle = NULL;
    1.23 -    this->gl_config.driver_loaded = 0;
    1.24 +    if (opengl_library != NULL)
    1.25 +        SDL_UnloadObject(opengl_library);
    1.26  
    1.27      if (location == NULL)
    1.28 -        location = "/System/Library/Frameworks/OpenGL.framework";
    1.29 -
    1.30 -    cfstr = CFStringCreateWithCString(kCFAllocatorDefault, location,
    1.31 -                                      kCFStringEncodingUTF8);
    1.32 -    if (cfstr == NULL) {
    1.33 -        SDL_OutOfMemory();
    1.34 -        return -1;
    1.35 -    }
    1.36 -
    1.37 -    bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
    1.38 -                        cfstr, kCFURLPOSIXPathStyle, true);
    1.39 +        location = DEFAULT_OPENGL_LIB_NAME;
    1.40  
    1.41 -    CFRelease(cfstr);
    1.42 -
    1.43 -    if (bundleURL == NULL) {
    1.44 -        SDL_OutOfMemory();
    1.45 -        return -1;
    1.46 -    }
    1.47 -
    1.48 -    opengl_bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
    1.49 -
    1.50 -    CFRelease(bundleURL);
    1.51 -
    1.52 -    if (opengl_bundle != NULL) {
    1.53 +    opengl_library = SDL_LoadObject(location);
    1.54 +    if (opengl_library != NULL) {
    1.55          this->gl_config.driver_loaded = 1;
    1.56          return 0;
    1.57      }
    1.58  
    1.59 -    /* not exactly descriptive, but okay... */
    1.60 -    SDL_SetError("Could not load OpenGL library");
    1.61 +    this->gl_config.driver_loaded = 0;
    1.62      return -1;
    1.63  }
    1.64  
    1.65  void*  QZ_GL_GetProcAddress (_THIS, const char *proc) {
    1.66 -    CFStringRef funcName = CFStringCreateWithCString
    1.67 -        (kCFAllocatorDefault, proc, kCFStringEncodingASCII);
    1.68 -
    1.69 -    void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName);
    1.70 -    CFRelease (funcName);
    1.71 -    return func;
    1.72 +    return SDL_LoadFunction(opengl_library, proc);
    1.73  }
    1.74  
    1.75  int    QZ_GL_GetAttribute   (_THIS, SDL_GLattr attrib, int* value) {
     2.1 --- a/src/video/quartz/SDL_QuartzVideo.h	Wed Nov 23 07:07:19 2005 +0000
     2.2 +++ b/src/video/quartz/SDL_QuartzVideo.h	Wed Nov 23 07:23:48 2005 +0000
     2.3 @@ -64,6 +64,7 @@
     2.4  #include "SDL_sysvideo.h"
     2.5  #include "SDL_pixels_c.h"
     2.6  #include "SDL_events_c.h"
     2.7 +#include "SDL_loadso.h"
     2.8  
     2.9  /* 
    2.10      This is a workaround to directly access NSOpenGLContext's CGL context
    2.11 @@ -117,7 +118,7 @@
    2.12      Sint16                  yuv_width, yuv_height;
    2.13      CGrafPtr                yuv_port;
    2.14  
    2.15 -    CFBundleRef opengl_bundle;    /* dynamically loaded OpenGL library. */
    2.16 +    void *opengl_library;    /* dynamically loaded OpenGL library. */
    2.17  } SDL_PrivateVideoData;
    2.18  
    2.19  #define _THIS    SDL_VideoDevice *this
    2.20 @@ -155,7 +156,7 @@
    2.21  #define current_buffer (this->hidden->current_buffer)
    2.22  #define quit_thread (this->hidden->quit_thread)
    2.23  #define system_version (this->hidden->system_version)
    2.24 -#define opengl_bundle (this->hidden->opengl_bundle)
    2.25 +#define opengl_library (this->hidden->opengl_library)
    2.26  
    2.27  /* grab states - the input is in one of these states */
    2.28  enum {
     3.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Wed Nov 23 07:07:19 2005 +0000
     3.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Wed Nov 23 07:23:48 2005 +0000
     3.3 @@ -23,7 +23,6 @@
     3.4  #include "SDL_QuartzVideo.h"
     3.5  #include "SDL_QuartzWindow.h"
     3.6  
     3.7 -
     3.8  /* 
     3.9      Add methods to get at private members of NSScreen. 
    3.10      Since there is a bug in Apple's screen switching code
    3.11 @@ -1495,9 +1494,9 @@
    3.12      QZ_UnsetVideoMode (this);
    3.13      CGPaletteRelease (palette);
    3.14  
    3.15 -    if (opengl_bundle) {
    3.16 -        CFRelease(opengl_bundle);
    3.17 -        opengl_bundle = NULL;
    3.18 +    if (opengl_library) {
    3.19 +        SDL_UnloadObject(opengl_library);
    3.20 +        opengl_library = NULL;
    3.21      }
    3.22      this->gl_config.driver_loaded = 0;
    3.23  }