# HG changeset patch # User Sam Lantinga # Date 1238779145 0 # Node ID cdeee9f9b14ba43c8ad83dd5bbd17d72d947dd01 # Parent 86ea6c073d87d9928f95bdc08a87d0f1c51df6b5 Fixed bug #721 From michalziulek@gmail.com 2009-03-28 07:43:34 (-) [reply] There is a bug in OpenGL 3.x context creation code. Function glXGetProcAddress is used directly where it should be: _this->gl_data->glXGetProcAddress. I have attached patch which fixes this on x11 and win32. Thanks. diff -r 86ea6c073d87 -r cdeee9f9b14b src/video/win32/SDL_win32opengl.c --- a/src/video/win32/SDL_win32opengl.c Fri Apr 03 13:35:05 2009 +0000 +++ b/src/video/win32/SDL_win32opengl.c Fri Apr 03 17:19:05 2009 +0000 @@ -512,7 +512,7 @@ return NULL; } - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB"); + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB"); if (!wglCreateContextAttribsARB) { SDL_SetError("GL 3.x is not supported"); context = temp_context; @@ -525,7 +525,7 @@ /* Create the GL 3.x context */ context = wglCreateContextAttribsARB(hdc, 0, attribs); /* Delete the GL 2.x context */ - wglDeleteContext(temp_context); + _this->gl_data->wglDeleteContext(temp_context); } } diff -r 86ea6c073d87 -r cdeee9f9b14b src/video/x11/SDL_x11opengl.c --- a/src/video/x11/SDL_x11opengl.c Fri Apr 03 13:35:05 2009 +0000 +++ b/src/video/x11/SDL_x11opengl.c Fri Apr 03 17:19:05 2009 +0000 @@ -413,21 +413,24 @@ }; /* Get a pointer to the context creation function for GL 3.0 */ - PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((GLubyte*)"glXCreateContextAttribsARB"); + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)_this->gl_data->glXGetProcAddress((GLubyte*)"glXCreateContextAttribsARB"); if (!glXCreateContextAttribs) { SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { - /* Create a GL 3.0 context */ + /* Create a GL 3.x context */ GLXFBConfig *framebuffer_config = NULL; int fbcount = 0; - framebuffer_config = glXChooseFBConfig(display, DefaultScreen(display), NULL, &fbcount); - if (!framebuffer_config) { - SDL_SetError("No good framebuffers found. GL 3.0 disabled"); + GLXFBConfig* (*glXChooseFBConfig)(Display* disp, int screen, const int* attrib_list, int* nelements); + + glXChooseFBConfig = (GLXFBConfig* (*)(Display*, int, const int*, int*))_this->gl_data->glXGetProcAddress((GLubyte*)"glXChooseFBConfig"); + + if (!glXChooseFBConfig || !(framebuffer_config = glXChooseFBConfig(display, DefaultScreen(display), NULL, &fbcount))) { + SDL_SetError("No good framebuffers found. GL 3.x disabled"); context = temp_context; } else { context = glXCreateContextAttribs(display, framebuffer_config[0], NULL, True, attribs); - glXDestroyContext(display, temp_context); + _this->gl_data->glXDestroyContext(display, temp_context); } } }