Skip to content
Permalink
Browse files
Quartz driver OpenGL updates:
Driver can now open whatever library is specified in SDL_GL_LoadLibrary()
 call (previously, it ignored this parameter), and uses the default system
 library when NULL is specified.

Also, library is loaded once in SDL_GL_LoadLibrary() and not every call to
 SDL_GL_GetProcAddress().
  • Loading branch information
icculus committed Nov 22, 2005
1 parent 7f5b03c commit 5e504d52b49b7397e8eba98e10eefd24ad2da081

File 1 of 3 in 5e504d5

@@ -168,32 +168,61 @@ void QZ_TearDownOpenGL (_THIS) {
/* SDL OpenGL functions */

int QZ_GL_LoadLibrary (_THIS, const char *location) {
this->gl_config.driver_loaded = 1;
return 0;
}
CFURLRef bundleURL;
CFStringRef cfstr;

void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
if ( gl_context != NULL ) {
SDL_SetError("OpenGL context already created");
return -1;
}

/* We may want to cache the bundleRef at some point */
CFBundleRef bundle;
CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true);
if (opengl_bundle != NULL)
CFRelease(opengl_bundle);

CFStringRef functionName = CFStringCreateWithCString
(kCFAllocatorDefault, proc, kCFStringEncodingASCII);
opengl_bundle = NULL;
this->gl_config.driver_loaded = 0;

if (location == NULL)
location = "/System/Library/Frameworks/OpenGL.framework";

void *function;
cfstr = CFStringCreateWithCString(kCFAllocatorDefault, location,
kCFStringEncodingUTF8);
if (cfstr == NULL) {
SDL_OutOfMemory();
return -1;
}

bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
assert (bundle != NULL);
bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
cfstr, kCFURLPOSIXPathStyle, true);

function = CFBundleGetFunctionPointerForName (bundle, functionName);
CFRelease(cfstr);

if (bundleURL == NULL) {
SDL_OutOfMemory();
return -1;
}

CFRelease ( bundleURL );
CFRelease ( functionName );
CFRelease ( bundle );
opengl_bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);

CFRelease(bundleURL);

if (opengl_bundle != NULL) {
this->gl_config.driver_loaded = 1;
return 0;
}

/* not exactly descriptive, but okay... */
SDL_SetError("Could not load OpenGL library");
return -1;
}

void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
CFStringRef funcName = CFStringCreateWithCString
(kCFAllocatorDefault, proc, kCFStringEncodingASCII);

return function;
void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName);
CFRelease (funcName);
return func;
}

int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {

0 comments on commit 5e504d5

Please sign in to comment.