mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
x11: Clean up sacrificial GL context code.
Check for failures, restore any previously-current context.
This commit is contained in:
parent
507659c6ac
commit
4649ac463c
@ -331,31 +331,41 @@ X11_GL_InitExtensions(_THIS)
|
|||||||
{
|
{
|
||||||
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||||
const int screen = DefaultScreen(display);
|
const int screen = DefaultScreen(display);
|
||||||
XVisualInfo *vinfo;
|
XVisualInfo *vinfo = NULL;
|
||||||
XSetWindowAttributes xattr;
|
Window w = 0;
|
||||||
Window w;
|
GLXContext current_context = 0;
|
||||||
GLXContext context;
|
GLXContext context = 0;
|
||||||
const char *(*glXQueryExtensionsStringFunc) (Display *, int);
|
const char *(*glXQueryExtensionsStringFunc) (Display *, int);
|
||||||
const char *extensions;
|
const char *extensions;
|
||||||
|
|
||||||
vinfo = X11_GL_GetVisual(_this, display, screen);
|
vinfo = X11_GL_GetVisual(_this, display, screen);
|
||||||
if (!vinfo) {
|
if (vinfo) {
|
||||||
return;
|
GLXContext (*glXGetCurrentContextFunc) (void) =
|
||||||
}
|
(GLXContext(*)(void))
|
||||||
|
X11_GL_GetProcAddress(_this, "glXGetCurrentContextFunc");
|
||||||
|
|
||||||
xattr.background_pixel = 0;
|
if (glXGetCurrentContextFunc) {
|
||||||
xattr.border_pixel = 0;
|
XSetWindowAttributes xattr;
|
||||||
xattr.colormap =
|
current_context = glXGetCurrentContextFunc();
|
||||||
X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
|
|
||||||
AllocNone);
|
xattr.background_pixel = 0;
|
||||||
w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
|
xattr.border_pixel = 0;
|
||||||
vinfo->depth, InputOutput, vinfo->visual,
|
xattr.colormap =
|
||||||
(CWBackPixel | CWBorderPixel | CWColormap), &xattr);
|
X11_XCreateColormap(display, RootWindow(display, screen),
|
||||||
context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
|
vinfo->visual, AllocNone);
|
||||||
if (context) {
|
w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0,
|
||||||
_this->gl_data->glXMakeCurrent(display, w, context);
|
32, 32, 0, vinfo->depth, InputOutput, vinfo->visual,
|
||||||
|
(CWBackPixel | CWBorderPixel | CWColormap), &xattr);
|
||||||
|
|
||||||
|
context = _this->gl_data->glXCreateContext(display, vinfo,
|
||||||
|
NULL, True);
|
||||||
|
if (context) {
|
||||||
|
_this->gl_data->glXMakeCurrent(display, w, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
X11_XFree(vinfo);
|
||||||
}
|
}
|
||||||
X11_XFree(vinfo);
|
|
||||||
|
|
||||||
glXQueryExtensionsStringFunc =
|
glXQueryExtensionsStringFunc =
|
||||||
(const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
|
(const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
|
||||||
@ -442,6 +452,7 @@ X11_GL_InitExtensions(_THIS)
|
|||||||
if (context) {
|
if (context) {
|
||||||
_this->gl_data->glXMakeCurrent(display, None, NULL);
|
_this->gl_data->glXMakeCurrent(display, None, NULL);
|
||||||
_this->gl_data->glXDestroyContext(display, context);
|
_this->gl_data->glXDestroyContext(display, context);
|
||||||
|
_this->gl_data->glXMakeCurrent(display, w, current_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
X11_XDestroyWindow(display, w);
|
X11_XDestroyWindow(display, w);
|
||||||
|
Loading…
Reference in New Issue
Block a user