Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzGL.m @ 1181:49d3efec6651
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().
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 22 Nov 2005 08:21:39 +0000 |
parents | e967ab22e6fd |
children | c96b326b90ba |
comparison
equal
deleted
inserted
replaced
1180:bdcb8bb4c831 | 1181:49d3efec6651 |
---|---|
166 | 166 |
167 | 167 |
168 /* SDL OpenGL functions */ | 168 /* SDL OpenGL functions */ |
169 | 169 |
170 int QZ_GL_LoadLibrary (_THIS, const char *location) { | 170 int QZ_GL_LoadLibrary (_THIS, const char *location) { |
171 this->gl_config.driver_loaded = 1; | 171 CFURLRef bundleURL; |
172 return 0; | 172 CFStringRef cfstr; |
173 | |
174 if ( gl_context != NULL ) { | |
175 SDL_SetError("OpenGL context already created"); | |
176 return -1; | |
177 } | |
178 | |
179 if (opengl_bundle != NULL) | |
180 CFRelease(opengl_bundle); | |
181 | |
182 opengl_bundle = NULL; | |
183 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; | |
173 } | 217 } |
174 | 218 |
175 void* QZ_GL_GetProcAddress (_THIS, const char *proc) { | 219 void* QZ_GL_GetProcAddress (_THIS, const char *proc) { |
176 | 220 CFStringRef funcName = CFStringCreateWithCString |
177 /* We may want to cache the bundleRef at some point */ | |
178 CFBundleRef bundle; | |
179 CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, | |
180 CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true); | |
181 | |
182 CFStringRef functionName = CFStringCreateWithCString | |
183 (kCFAllocatorDefault, proc, kCFStringEncodingASCII); | 221 (kCFAllocatorDefault, proc, kCFStringEncodingASCII); |
184 | 222 |
185 void *function; | 223 void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName); |
186 | 224 CFRelease (funcName); |
187 bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL); | 225 return func; |
188 assert (bundle != NULL); | |
189 | |
190 function = CFBundleGetFunctionPointerForName (bundle, functionName); | |
191 | |
192 CFRelease ( bundleURL ); | |
193 CFRelease ( functionName ); | |
194 CFRelease ( bundle ); | |
195 | |
196 return function; | |
197 } | 226 } |
198 | 227 |
199 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) { | 228 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) { |
200 | 229 |
201 GLenum attr = 0; | 230 GLenum attr = 0; |