comparison src/video/quartz/SDL_QuartzGL.m @ 1189:c96b326b90ba

Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 23 Nov 2005 07:23:48 +0000
parents 49d3efec6651
children bb6791b0a268
comparison
equal deleted inserted replaced
1188:f31856cf29ae 1189:c96b326b90ba
164 [ gl_context release ]; 164 [ gl_context release ];
165 } 165 }
166 166
167 167
168 /* SDL OpenGL functions */ 168 /* SDL OpenGL functions */
169 static const char *DEFAULT_OPENGL_LIB_NAME =
170 "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
169 171
170 int QZ_GL_LoadLibrary (_THIS, const char *location) { 172 int QZ_GL_LoadLibrary (_THIS, const char *location) {
171 CFURLRef bundleURL;
172 CFStringRef cfstr;
173
174 if ( gl_context != NULL ) { 173 if ( gl_context != NULL ) {
175 SDL_SetError("OpenGL context already created"); 174 SDL_SetError("OpenGL context already created");
176 return -1; 175 return -1;
177 } 176 }
178 177
179 if (opengl_bundle != NULL) 178 if (opengl_library != NULL)
180 CFRelease(opengl_bundle); 179 SDL_UnloadObject(opengl_library);
181 180
182 opengl_bundle = NULL; 181 if (location == NULL)
182 location = DEFAULT_OPENGL_LIB_NAME;
183
184 opengl_library = SDL_LoadObject(location);
185 if (opengl_library != NULL) {
186 this->gl_config.driver_loaded = 1;
187 return 0;
188 }
189
183 this->gl_config.driver_loaded = 0; 190 this->gl_config.driver_loaded = 0;
184
185 if (location == NULL)
186 location = "/System/Library/Frameworks/OpenGL.framework";
187
188 cfstr = CFStringCreateWithCString(kCFAllocatorDefault, location,
189 kCFStringEncodingUTF8);
190 if (cfstr == NULL) {
191 SDL_OutOfMemory();
192 return -1;
193 }
194
195 bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
196 cfstr, kCFURLPOSIXPathStyle, true);
197
198 CFRelease(cfstr);
199
200 if (bundleURL == NULL) {
201 SDL_OutOfMemory();
202 return -1;
203 }
204
205 opengl_bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
206
207 CFRelease(bundleURL);
208
209 if (opengl_bundle != NULL) {
210 this->gl_config.driver_loaded = 1;
211 return 0;
212 }
213
214 /* not exactly descriptive, but okay... */
215 SDL_SetError("Could not load OpenGL library");
216 return -1; 191 return -1;
217 } 192 }
218 193
219 void* QZ_GL_GetProcAddress (_THIS, const char *proc) { 194 void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
220 CFStringRef funcName = CFStringCreateWithCString 195 return SDL_LoadFunction(opengl_library, proc);
221 (kCFAllocatorDefault, proc, kCFStringEncodingASCII);
222
223 void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName);
224 CFRelease (funcName);
225 return func;
226 } 196 }
227 197
228 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) { 198 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {
229 199
230 GLenum attr = 0; 200 GLenum attr = 0;