diff -ur SDL-1.2.15/include/SDL_video.h SDL-1.2.15-idthread/include/SDL_video.h --- SDL-1.2.15/include/SDL_video.h 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/include/SDL_video.h 2014-04-16 19:52:48.010249290 +0100 @@ -862,6 +862,14 @@ */ extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); +/** + * Switch current GLX context for calling thread. + * + * Used by id Software for SMP rthread binaries of Quake 4 and ET:Quake Wars. + */ + extern DECLSPEC void SDLCALL SDL_GL_DisableContext(void); + extern DECLSPEC void SDLCALL SDL_GL_EnableContext_Thread(void); + /** @name OpenGL Internal Functions * Internal functions that should not be called unless you have read * and understood the source code for these functions. diff -ur SDL-1.2.15/src/video/SDL_sysvideo.h SDL-1.2.15-idthread/src/video/SDL_sysvideo.h --- SDL-1.2.15/src/video/SDL_sysvideo.h 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/src/video/SDL_sysvideo.h 2014-04-16 20:33:24.643100574 +0100 @@ -179,6 +179,12 @@ /* Make the context associated with this driver current */ int (*GL_MakeCurrent)(_THIS); + /* Make the current context active to the calling thread */ + int (*GL_MakeCurrent_Thread)(_THIS); + + /* Disable the current context. */ + int (*GL_DisableContext)(_THIS); + /* Swap the current buffers in double buffer mode. */ void (*GL_SwapBuffers)(_THIS); diff -ur SDL-1.2.15/src/video/SDL_video.c SDL-1.2.15-idthread/src/video/SDL_video.c --- SDL-1.2.15/src/video/SDL_video.c 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/src/video/SDL_video.c 2014-04-16 20:31:42.065238105 +0100 @@ -1540,6 +1540,17 @@ } } +/* Make the current context active to the calling thread */ +void SDL_GL_EnableContext_Thread() { + SDL_VideoDevice *this = current_video; + this->GL_MakeCurrent_Thread( this ); +} +void SDL_GL_DisableContext() +{ + SDL_VideoDevice *this = current_video; + this->GL_DisableContext( this ); +} + /* Update rects with locking */ void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects) { diff -ur SDL-1.2.15/src/video/x11/SDL_x11gl.c SDL-1.2.15-idthread/src/video/x11/SDL_x11gl.c --- SDL-1.2.15/src/video/x11/SDL_x11gl.c 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/src/video/x11/SDL_x11gl.c 2014-04-16 20:06:30.053421900 +0100 @@ -352,6 +352,33 @@ return(retval); } +/* Make the current context active to the calling thread. */ +int X11_GL_MakeCurrent_Thread(_THIS) +{ + int retval; + + retval = 0; + if ( ! this->gl_data->glXMakeCurrent(GFX_Display, + SDL_Window, glx_context) ) { + SDL_SetError("Unable to make GL context current"); + retval = -1; + } + return retval; +} + +/* Disable the context. */ +int X11_GL_DisableContext(_THIS) +{ + int retval; + + retval = 0; + if ( !this->gl_data->glXMakeCurrent( GFX_Display, None, NULL ) ) { + SDL_SetError( "Unable to disable GL context" ); + retval = -1; + } + return(retval); +} + /* Get attribute data from glX. */ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) { diff -ur SDL-1.2.15/src/video/x11/SDL_x11gl_c.h SDL-1.2.15-idthread/src/video/x11/SDL_x11gl_c.h --- SDL-1.2.15/src/video/x11/SDL_x11gl_c.h 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/src/video/x11/SDL_x11gl_c.h 2014-04-16 19:34:46.031213845 +0100 @@ -90,6 +90,8 @@ extern void X11_GL_Shutdown(_THIS); #if SDL_VIDEO_OPENGL_GLX extern int X11_GL_MakeCurrent(_THIS); +extern int X11_GL_MakeCurrent_Thread(_THIS); +extern int X11_GL_DisableContext(_THIS); extern int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); extern void X11_GL_SwapBuffers(_THIS); extern int X11_GL_LoadLibrary(_THIS, const char* path); diff -ur SDL-1.2.15/src/video/x11/SDL_x11video.c SDL-1.2.15-idthread/src/video/x11/SDL_x11video.c --- SDL-1.2.15/src/video/x11/SDL_x11video.c 2012-01-19 06:30:06.000000000 +0000 +++ SDL-1.2.15-idthread/src/video/x11/SDL_x11video.c 2014-04-16 20:05:35.864533198 +0100 @@ -158,6 +158,8 @@ device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_GetAttribute = X11_GL_GetAttribute; device->GL_MakeCurrent = X11_GL_MakeCurrent; + device->GL_MakeCurrent_Thread = X11_GL_MakeCurrent_Thread; + device->GL_DisableContext = X11_GL_DisableContext; device->GL_SwapBuffers = X11_GL_SwapBuffers; #endif device->SetCaption = X11_SetCaption;