Fix for recent GLX error bug
Lee Salzman I messed up in the patch I sent you regarding gobbling up the GLX error codes signaled when trying to create a context. After reading the spec I realized those error codes are relative to a base error that needs to be queried when setting up the GLX extension... So I have made a patch that fixes it for a user I had who was still getting the bug with my old patch. Without this patch my previous one won't work, so it is recommended to merge this...
This commit is contained in:
parent
ccb139c73a
commit
9583071066
2 changed files with 22 additions and 4 deletions
|
@ -133,6 +133,7 @@ static void X11_GL_InitExtensions(_THIS);
|
||||||
int
|
int
|
||||||
X11_GL_LoadLibrary(_THIS, const char *path)
|
X11_GL_LoadLibrary(_THIS, const char *path)
|
||||||
{
|
{
|
||||||
|
Display *display;
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
if (_this->gl_data) {
|
if (_this->gl_data) {
|
||||||
|
@ -186,6 +187,9 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||||
|
|
||||||
/* Load function pointers */
|
/* Load function pointers */
|
||||||
handle = _this->gl_config.dll_handle;
|
handle = _this->gl_config.dll_handle;
|
||||||
|
_this->gl_data->glXQueryExtension =
|
||||||
|
(Bool (*)(Display *, int *, int *))
|
||||||
|
GL_LoadFunction(handle, "glXQueryExtension");
|
||||||
_this->gl_data->glXGetProcAddress =
|
_this->gl_data->glXGetProcAddress =
|
||||||
(void *(*)(const GLubyte *))
|
(void *(*)(const GLubyte *))
|
||||||
GL_LoadFunction(handle, "glXGetProcAddressARB");
|
GL_LoadFunction(handle, "glXGetProcAddressARB");
|
||||||
|
@ -208,7 +212,8 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||||
(void (*)(Display*,GLXDrawable,int,unsigned int*))
|
(void (*)(Display*,GLXDrawable,int,unsigned int*))
|
||||||
X11_GL_GetProcAddress(_this, "glXQueryDrawable");
|
X11_GL_GetProcAddress(_this, "glXQueryDrawable");
|
||||||
|
|
||||||
if (!_this->gl_data->glXChooseVisual ||
|
if (!_this->gl_data->glXQueryExtension ||
|
||||||
|
!_this->gl_data->glXChooseVisual ||
|
||||||
!_this->gl_data->glXCreateContext ||
|
!_this->gl_data->glXCreateContext ||
|
||||||
!_this->gl_data->glXDestroyContext ||
|
!_this->gl_data->glXDestroyContext ||
|
||||||
!_this->gl_data->glXMakeCurrent ||
|
!_this->gl_data->glXMakeCurrent ||
|
||||||
|
@ -216,6 +221,11 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||||
return SDL_SetError("Could not retrieve OpenGL functions");
|
return SDL_SetError("Could not retrieve OpenGL functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||||
|
if (!_this->gl_data->glXQueryExtension(display, &_this->gl_data->errorBase, &_this->gl_data->eventBase)) {
|
||||||
|
return SDL_SetError("GLX is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize extensions */
|
/* Initialize extensions */
|
||||||
X11_GL_InitExtensions(_this);
|
X11_GL_InitExtensions(_this);
|
||||||
|
|
||||||
|
@ -504,19 +514,23 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
|
||||||
#define GLXBadProfileARB 13
|
#define GLXBadProfileARB 13
|
||||||
#endif
|
#endif
|
||||||
static int (*handler) (Display *, XErrorEvent *) = NULL;
|
static int (*handler) (Display *, XErrorEvent *) = NULL;
|
||||||
|
static int errorBase = 0;
|
||||||
static int
|
static int
|
||||||
X11_GL_CreateContextErrorHandler(Display * d, XErrorEvent * e)
|
X11_GL_CreateContextErrorHandler(Display * d, XErrorEvent * e)
|
||||||
{
|
{
|
||||||
switch (e->error_code) {
|
switch (e->error_code) {
|
||||||
case GLXBadContext:
|
|
||||||
case GLXBadFBConfig:
|
|
||||||
case GLXBadProfileARB:
|
|
||||||
case BadRequest:
|
case BadRequest:
|
||||||
case BadMatch:
|
case BadMatch:
|
||||||
case BadValue:
|
case BadValue:
|
||||||
case BadAlloc:
|
case BadAlloc:
|
||||||
return (0);
|
return (0);
|
||||||
default:
|
default:
|
||||||
|
if (errorBase &&
|
||||||
|
(e->error_code == errorBase + GLXBadContext ||
|
||||||
|
e->error_code == errorBase + GLXBadFBConfig ||
|
||||||
|
e->error_code == errorBase + GLXBadProfileARB)) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
return (handler(d, e));
|
return (handler(d, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,6 +555,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
|
|
||||||
/* We do this to create a clean separation between X and GLX errors. */
|
/* We do this to create a clean separation between X and GLX errors. */
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
|
errorBase = _this->gl_data->errorBase;
|
||||||
handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler);
|
handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler);
|
||||||
XGetWindowAttributes(display, data->xwindow, &xattr);
|
XGetWindowAttributes(display, data->xwindow, &xattr);
|
||||||
v.screen = screen;
|
v.screen = screen;
|
||||||
|
|
|
@ -29,10 +29,13 @@
|
||||||
|
|
||||||
struct SDL_GLDriverData
|
struct SDL_GLDriverData
|
||||||
{
|
{
|
||||||
|
int errorBase, eventBase;
|
||||||
|
|
||||||
SDL_bool HAS_GLX_EXT_visual_rating;
|
SDL_bool HAS_GLX_EXT_visual_rating;
|
||||||
SDL_bool HAS_GLX_EXT_visual_info;
|
SDL_bool HAS_GLX_EXT_visual_info;
|
||||||
SDL_bool HAS_GLX_EXT_swap_control_tear;
|
SDL_bool HAS_GLX_EXT_swap_control_tear;
|
||||||
|
|
||||||
|
Bool (*glXQueryExtension) (Display*,int*,int*);
|
||||||
void *(*glXGetProcAddress) (const GLubyte*);
|
void *(*glXGetProcAddress) (const GLubyte*);
|
||||||
XVisualInfo *(*glXChooseVisual) (Display*,int,int*);
|
XVisualInfo *(*glXChooseVisual) (Display*,int,int*);
|
||||||
GLXContext (*glXCreateContext) (Display*,XVisualInfo*,GLXContext,Bool);
|
GLXContext (*glXCreateContext) (Display*,XVisualInfo*,GLXContext,Bool);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue