[Patch] Add OpenGL swap control

While waiting for the new ATI drivers, I wrote the attached patch. It
adds a new OpenGL flag for SDL called SDL_GL_SWAP_CONTROL, which
enables setting vsync swap control in OpenGL from SDL. Currently
supports only GLX and AGL, but I could easily add WGL as well if there
is interest in this. However, once the new ATI driver came, it turned
out ATI do not support the swap control GLX extension (they do support
the swap control extension under WGL, however), so I could not test if
my patch actually worked.

Also, (why) isn’t SDL_GL_Get_Attribute() available on Macs?

Let me know if there is any interest in adding such support to SDL. If
so, I’ll need someone else to test this patch.

Relevant links:
http://oss.sgi.com/projects/ogl-sample/registry/SGI/swap_control.txt
http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt

Per Inge Mathisen wrote:

While waiting for the new ATI drivers, I wrote the attached patch. It
adds a new OpenGL flag for SDL called SDL_GL_SWAP_CONTROL, which
enables setting vsync swap control in OpenGL from SDL. Currently
supports only GLX and AGL, but I could easily add WGL as well if there
is interest in this. However, once the new ATI driver came, it turned
out ATI do not support the swap control GLX extension (they do support
the swap control extension under WGL, however), so I could not test if
my patch actually worked.

Also, (why) isn’t SDL_GL_Get_Attribute() available on Macs?

Are we both ok that you’re patching the mac os classic backend of SDL ?
If so, you could at least implement the most widespread attributes by
mostly cut and pasting code from SDL12/src/video/bwindow/SDL_sysvideo.c
(the function BE_GL_GetAttribute only uses standard OpenGL calls).

Let me know if there is any interest in adding such support to SDL. If
so, I’ll need someone else to test this patch.

As an SDL/OpenGL user I have heavy interest in such patches. Just like
for the accelerated visual attribute there are a number of
platform-specific OpenGL functions that are present on most platforms
under different names which are not available when using SDL (unless you
give up portability). These could be translated into some portable SDL
functions.

Stephane