[SDL] Graphics/Audio Driver selection at runtime

Steven Johnson SDL at sakuraindustries.com
Fri Sep 16 04:13:22 PDT 2005

Olivier Delannoy wrote:

> You can parse options before initializing SDL and fixes the 
> environment vars using SDL_putenv in your program just before calling 
> SDL_InitSubSystem. This function is available for this usage.

I appreciate I can do this, it was my first thought.  It just seems a
little bit Kludgey to me, that is all.  It also still doesnt allow my
application to probe the available drivers, so the end user knows what
the currently available selections are.  So the thought was, if i add
any routines to probe, why not add a "not so kuldgy" way of selecting
those drivers,  rather than force environment variables.

Is there any real problem with the suggestion?  I wouldnt break any API
compatibility with anything suggested.

Also, I would really need to know which version I should develop against
1.2.9 or CVS, and what is the protocol for submitting patches?


> On 9/15/05, *Steven Johnson* <SDL at sakuraindustries.com 
> <mailto:SDL at sakuraindustries.com>> wrote:
>     Hi,
>     I am starting to work with SDL.
>     I want my users to be able to select from all drivers (video and
>     audio)
>     compiled into the SDL Library, so that they can select the driver with
>     the best features/performance.
>     I know this can be done by setting the "SDL_VIDEODRIVER" and
>     "SDL_AUDIODRIVER" environment variables.
>     I would prefer my users do this by either passing options on the
>     command
>     line, or having settings in a configuration file.
>     I would like a modified SDL_InitSubSystem to allow the required
>     names of
>     the Audio and Video Driver to use  to be explicitly declared, and not
>     just auto probed.  Null, or an empty string would auto probe as it
>     does
>     now.  And this would be a copy of SDL_InitSubSystem, renamed
>     something like:
>     SDL_InitSubSystem_Drivers(flags, VideoDriver, AudioDriver);
>     then SDL_InitSubSystem would just call SDL_InitSubSystem_Drivers,
>     with
>     empty entries for VideoDriver and AudioDriver.  To maintain complete
>     compatibility with the current api.
>     To go with this, i would like to add a function to enumerate
>     drivers, so
>     its possible at run time to discover what drivers a particular
>     library
>     supports.  A Function something like:
>     SDL_EnumerateDriver(Type, Index, **Name, **Description) returns
>     True if
>     its available to be used.  False if its in the SDL Library, but not
>     available to be used.
>     Type would be "Audio" or "Video". Index, an increasing number.
>     **Name is
>     set null if at the end of the list, Description likewise.  Name and
>     Description just get set to the constants from the bootstrap table.
>     Then the program could display the available drivers, and the user
>     could
>     select the video method they wanted for best performance.
>     Or something like that.  The purpose of this post is for comments
>     before
>     I do anything.
>     Thanks for any comments or pointers.
>     Also, should i do this work against 1.2.9 or CVS version?  Whats the
>     process for patch approval?
>     Steven Johnson
>     _______________________________________________
>     SDL mailing list
>     SDL at libsdl.org <mailto:SDL at libsdl.org>
>     http://www.libsdl.org/mailman/listinfo/sdl
>SDL mailing list
>SDL at libsdl.org

More information about the SDL mailing list