[SDL] How to dynamically check for SDL_GL_SWAP_INTERVAL support
sa666666 at gmail.com
Mon Dec 4 11:09:13 PST 2006
On Monday 04 December 2006 15:08, Peter Mulholland wrote:
> Hello Stephen,
> Monday, December 4, 2006, 5:47:00 PM, you wrote:
> > Hi, I'm wondering how to check (at runtime) if I can use the GL
> > command:
> > SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
> > This only works on SDL > 1.2.10, I think. The problem is, how do I
> > check this at runtime, since the SDL lib will be dynamically
> > linked? And just because it's available at compile-time doesn't
> > mean it will be at run-time (and vice-versa).
> The "enum" is just a value that gets compiled into your program.
> Older versions of SDL which don't recognise it should just do nothing
> (they might generate an error through SDL_GetError()).
On another guys advice, I actually did a little experimentation, and
looked at the source code for SDL in this area. I tried passing in a
nonsensical enum value, and it still worked fine (it just ignored the
> If this is a Linux program, the best thing to do is a) explicitly say
> you need 1.2.10 or greater, b) if it's a closed source binary app,
> distribute your own libSDL.so with your executable.
OSX and Win32 get distributed with their own SDL lib, so it's not a
problem there. My only concern was what happens when the lib doesn't
support the functionality, and that #define'ing the enum values seemed
a bit hacky. But it *does* work, so hacky it is :)
More information about the SDL