Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoaopengl.m @ 2178:114a541cfae2
Creating a context makes it current, per the documentation.
Applied a variant of the multi-card OpenGL fix from SDL 1.2
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 12 Jul 2007 06:31:36 +0000 |
parents | 81255f93dfcd |
children | 56cf872c723a |
comparison
equal
deleted
inserted
replaced
2177:4f896c20caf6 | 2178:114a541cfae2 |
---|---|
148 NSAutoreleasePool *pool; | 148 NSAutoreleasePool *pool; |
149 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | 149 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
150 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; | 150 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; |
151 NSOpenGLPixelFormatAttribute attr[32]; | 151 NSOpenGLPixelFormatAttribute attr[32]; |
152 NSOpenGLPixelFormat *fmt; | 152 NSOpenGLPixelFormat *fmt; |
153 NSOpenGLContext *nscontext; | 153 NSOpenGLContext *context; |
154 int i = 0; | 154 int i = 0; |
155 | 155 |
156 pool = [[NSAutoreleasePool alloc] init]; | 156 pool = [[NSAutoreleasePool alloc] init]; |
157 | 157 |
158 if (window->flags & SDL_WINDOW_FULLSCREEN) { | 158 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
210 SDL_SetError ("Failed creating OpenGL pixel format"); | 210 SDL_SetError ("Failed creating OpenGL pixel format"); |
211 [pool release]; | 211 [pool release]; |
212 return NULL; | 212 return NULL; |
213 } | 213 } |
214 | 214 |
215 nscontext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil]; | 215 context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil]; |
216 | 216 |
217 [fmt release]; | 217 [fmt release]; |
218 | 218 |
219 if (nscontext == nil) { | 219 if (context == nil) { |
220 SDL_SetError ("Failed creating OpenGL context"); | 220 SDL_SetError ("Failed creating OpenGL context"); |
221 [pool release]; | 221 [pool release]; |
222 return NULL; | 222 return NULL; |
223 } | 223 } |
224 | 224 |
238 #define GLI_SUBMIT_FUNC_CACHE_MAX 280 | 238 #define GLI_SUBMIT_FUNC_CACHE_MAX 280 |
239 #endif | 239 #endif |
240 | 240 |
241 { | 241 { |
242 long cache_max = 64; | 242 long cache_max = 64; |
243 CGLContextObj ctx = [nscontext CGLContextObj]; | 243 CGLContextObj ctx = [context CGLContextObj]; |
244 CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max); | 244 CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max); |
245 CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max); | 245 CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max); |
246 } | 246 } |
247 | 247 |
248 /* End Wisdom from Apple Engineer section. --ryan. */ | 248 /* End Wisdom from Apple Engineer section. --ryan. */ |
249 | 249 |
250 [pool release]; | 250 [pool release]; |
251 return nscontext; | 251 |
252 if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) { | |
253 Cocoa_GL_DeleteContext(_this, context); | |
254 return NULL; | |
255 } | |
256 | |
257 return context; | |
252 } | 258 } |
253 | 259 |
254 int | 260 int |
255 Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) | 261 Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) |
256 { | 262 { |