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
This commit is contained in:
parent
374ad1d764
commit
4893ceacfc
3 changed files with 58 additions and 21 deletions
|
@ -168,32 +168,61 @@ void QZ_TearDownOpenGL (_THIS) {
|
||||||
/* SDL OpenGL functions */
|
/* SDL OpenGL functions */
|
||||||
|
|
||||||
int QZ_GL_LoadLibrary (_THIS, const char *location) {
|
int QZ_GL_LoadLibrary (_THIS, const char *location) {
|
||||||
this->gl_config.driver_loaded = 1;
|
CFURLRef bundleURL;
|
||||||
return 0;
|
CFStringRef cfstr;
|
||||||
|
|
||||||
|
if ( gl_context != NULL ) {
|
||||||
|
SDL_SetError("OpenGL context already created");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opengl_bundle != NULL)
|
||||||
|
CFRelease(opengl_bundle);
|
||||||
|
|
||||||
|
opengl_bundle = NULL;
|
||||||
|
this->gl_config.driver_loaded = 0;
|
||||||
|
|
||||||
|
if (location == NULL)
|
||||||
|
location = "/System/Library/Frameworks/OpenGL.framework";
|
||||||
|
|
||||||
|
cfstr = CFStringCreateWithCString(kCFAllocatorDefault, location,
|
||||||
|
kCFStringEncodingUTF8);
|
||||||
|
if (cfstr == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
|
||||||
|
cfstr, kCFURLPOSIXPathStyle, true);
|
||||||
|
|
||||||
|
CFRelease(cfstr);
|
||||||
|
|
||||||
|
if (bundleURL == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
|
||||||
|
CFStringRef funcName = CFStringCreateWithCString
|
||||||
/* We may want to cache the bundleRef at some point */
|
|
||||||
CFBundleRef bundle;
|
|
||||||
CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
|
|
||||||
CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true);
|
|
||||||
|
|
||||||
CFStringRef functionName = CFStringCreateWithCString
|
|
||||||
(kCFAllocatorDefault, proc, kCFStringEncodingASCII);
|
(kCFAllocatorDefault, proc, kCFStringEncodingASCII);
|
||||||
|
|
||||||
void *function;
|
void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName);
|
||||||
|
CFRelease (funcName);
|
||||||
bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
|
return func;
|
||||||
assert (bundle != NULL);
|
|
||||||
|
|
||||||
function = CFBundleGetFunctionPointerForName (bundle, functionName);
|
|
||||||
|
|
||||||
CFRelease ( bundleURL );
|
|
||||||
CFRelease ( functionName );
|
|
||||||
CFRelease ( bundle );
|
|
||||||
|
|
||||||
return function;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {
|
int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {
|
||||||
|
|
|
@ -117,6 +117,7 @@ typedef struct SDL_PrivateVideoData {
|
||||||
Sint16 yuv_width, yuv_height;
|
Sint16 yuv_width, yuv_height;
|
||||||
CGrafPtr yuv_port;
|
CGrafPtr yuv_port;
|
||||||
|
|
||||||
|
CFBundleRef opengl_bundle; /* dynamically loaded OpenGL library. */
|
||||||
} SDL_PrivateVideoData;
|
} SDL_PrivateVideoData;
|
||||||
|
|
||||||
#define _THIS SDL_VideoDevice *this
|
#define _THIS SDL_VideoDevice *this
|
||||||
|
@ -154,6 +155,7 @@ typedef struct SDL_PrivateVideoData {
|
||||||
#define current_buffer (this->hidden->current_buffer)
|
#define current_buffer (this->hidden->current_buffer)
|
||||||
#define quit_thread (this->hidden->quit_thread)
|
#define quit_thread (this->hidden->quit_thread)
|
||||||
#define system_version (this->hidden->system_version)
|
#define system_version (this->hidden->system_version)
|
||||||
|
#define opengl_bundle (this->hidden->opengl_bundle)
|
||||||
|
|
||||||
/* grab states - the input is in one of these states */
|
/* grab states - the input is in one of these states */
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -1489,6 +1489,12 @@ static void QZ_VideoQuit (_THIS) {
|
||||||
|
|
||||||
QZ_UnsetVideoMode (this);
|
QZ_UnsetVideoMode (this);
|
||||||
CGPaletteRelease (palette);
|
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) */
|
#if 0 /* Not used (apparently, it's really slow) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue