[SDL] [SDL1.3 hg] Sharing a SDL_GLContext between two SDL_Windows

interim_descriptor interim.descriptor at gmail.com
Sat Dec 18 23:31:02 PST 2010


I'm currently sharing a single SDL_GLContext between two SDL_Windows (one on
each display, the 2nd of which has vsync enabled).

I create a 3rd invisible window, which has dimensions equal to the greater
dimensions of either window, and then call SDL_GL_CreateContext() on its

Each frame, I:

   1. Render the 1st window
   2. Call SDL_GL_SetSwapInterval(false) disabling vsync
   3. Call SDL_GL_SwapWindow()
   4. Call SDL_GL_MakeCurrent() for the 2nd window
   5. Render the 2nd window
   6. Call SDL_GL_SetSwapInterval(true), enabling
   7. Call SDL_GL_SwapWindow()

This seems to work pretty well, but I'm wondering if there's a better way to
do what I want to do, or if there are any performance implications I should
be aware of...

The reason I'm sharing a glContext is because I'm writing VJ software the
plays back multiple video simultaneously, so I'd like to only update one set
of glTextures.

Has anybody else solved this sort of problem in a way they believe to be
more efficient?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20101218/2dfa8842/attachment-0007.htm>

More information about the SDL mailing list