Multithreaded opengl rendering in SDL 1.3

I was going through the current source for SDL 1.3 and I noticed that
the gl context is now exposed. This means an API could be built to allow
gl commands in a different thread without using SDL_sysWMinfo and
platform specific code.

Currently the API has

int SDL_GL_MakeCurrent(SDL_GLcontext context,
SDL_GLwindow window );

To complete the api, there needs to be a release function.

int SDL_GL_ReleaseContext();

So code for rendering in a different thread would look like this :

SDL_mutex* renderMutex;
SDL_GLcontext glContext;
SDL_window window;

–main thread

//assuming the context is now current


//shutdown code
SDL_GL_MakeCurrent(glContext, window);

SDL_GL_MakeCurrent(glContext, window);



If the API was really nice, the lock/unlock would be internal to
SDL_GL_MakeCurrent and SDL_GL_ReleaseContext. Then application would not
have to worry about maintaining a mutex.

I know this how you use opengl in a thread under X11 and Windows, but I
don’t know if this is applicable to all platforms that supports threads
and opengl. So another function

SDL_bool DL_GL_RenderMultithreadRenderAllowed()

could be created if for some reasons that was really impossible to
implement on some platform. This would tell application to fall back to
a single threaded path.

Any thoughts or comments?