From bafa4c7ae80f269cd22477e37dc6152ca24a279b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 1 Mar 2014 21:33:48 -0500 Subject: [PATCH] Dynamically load glGetString(), to avoid direct dependency on OpenGL. --- src/video/cocoa/SDL_cocoaopengl.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 696709f11..cacb75511 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -162,6 +162,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum) = NULL; NSAutoreleasePool *pool; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; @@ -275,7 +276,14 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) return NULL; } - glversion = (const char *)glGetString(GL_VERSION); + glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + Cocoa_GL_DeleteContext(_this, context); + SDL_SetError ("Failed getting OpenGL glGetString entry point"); + return NULL; + } + + glversion = (const char *)glGetStringFunc(GL_VERSION); if (glversion == NULL) { Cocoa_GL_DeleteContext(_this, context); SDL_SetError ("Failed getting OpenGL context version");