Commit 4893ceac authored by Ryan C. Gordon's avatar Ryan C. Gordon

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().

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401184
parent 374ad1d7
......@@ -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) {
......
......@@ -117,6 +117,7 @@ typedef struct SDL_PrivateVideoData {
Sint16 yuv_width, yuv_height;
CGrafPtr yuv_port;
CFBundleRef opengl_bundle; /* dynamically loaded OpenGL library. */
} SDL_PrivateVideoData;
#define _THIS SDL_VideoDevice *this
......@@ -154,6 +155,7 @@ typedef struct SDL_PrivateVideoData {
#define current_buffer (this->hidden->current_buffer)
#define quit_thread (this->hidden->quit_thread)
#define system_version (this->hidden->system_version)
#define opengl_bundle (this->hidden->opengl_bundle)
/* grab states - the input is in one of these states */
enum {
......
......@@ -1489,6 +1489,12 @@ static void QZ_VideoQuit (_THIS) {
QZ_UnsetVideoMode (this);
CGPaletteRelease (palette);
if (opengl_bundle) {
CFRelease(opengl_bundle);
opengl_bundle = NULL;
}
this->gl_config.driver_loaded = 0;
}
#if 0 /* Not used (apparently, it's really slow) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment