src/video/cocoa/SDL_cocoaopengl.m
changeset 8278 e60a7bb2b80b
parent 8276 9bd65b58278e
child 8601 4c04c7785cba
equal deleted inserted replaced
8277:cd0a00060738 8278:e60a7bb2b80b
   160 
   160 
   161 SDL_GLContext
   161 SDL_GLContext
   162 Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
   162 Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
   163 {
   163 {
   164     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   164     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
       
   165     const GLubyte *(APIENTRY * glGetStringFunc)(GLenum) = NULL;
   165     NSAutoreleasePool *pool;
   166     NSAutoreleasePool *pool;
   166     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
   167     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
   167     SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
   168     SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
   168     NSOpenGLPixelFormatAttribute attr[32];
   169     NSOpenGLPixelFormatAttribute attr[32];
   169     NSOpenGLPixelFormat *fmt;
   170     NSOpenGLPixelFormat *fmt;
   273         Cocoa_GL_DeleteContext(_this, context);
   274         Cocoa_GL_DeleteContext(_this, context);
   274         SDL_SetError ("Failed making OpenGL context current");
   275         SDL_SetError ("Failed making OpenGL context current");
   275         return NULL;
   276         return NULL;
   276     }
   277     }
   277 
   278 
   278     glversion = (const char *)glGetString(GL_VERSION);
   279     glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
       
   280     if (!glGetStringFunc) {
       
   281         Cocoa_GL_DeleteContext(_this, context);
       
   282         SDL_SetError ("Failed getting OpenGL glGetString entry point");
       
   283         return NULL;
       
   284     }
       
   285 
       
   286     glversion = (const char *)glGetStringFunc(GL_VERSION);
   279     if (glversion == NULL) {
   287     if (glversion == NULL) {
   280         Cocoa_GL_DeleteContext(_this, context);
   288         Cocoa_GL_DeleteContext(_this, context);
   281         SDL_SetError ("Failed getting OpenGL context version");
   289         SDL_SetError ("Failed getting OpenGL context version");
   282         return NULL;
   290         return NULL;
   283     }
   291     }