Picking a specific audio and video driver

I am aware of the way to pick an audio and/or a video driver using
environment variables, but is there another way of doing this so that such a
setting could be in a config file or passed as a command-line parameter?
(aside from setting/restoring the environment from within my code?)

Thanks!

[I guess it’s time I downloaded the source and found out some of these things for myself…]–

Olivier A. Dagenais - Software Architect and Developer

Actually, I notice MSDN saying the _putenv function only affects the
environment of the running process (a copy of it maintained by the runtime,
to be precise), is it the same on other platforms? If so, would this be an
acceptable solution? (not very elegant, but it seems I don’t have much
choice…)–

Olivier A. Dagenais - Software Architect and Developer

“Olivier Dagenais” <olivier.dagenais at canada.com> wrote in message
news:99494d$u4b$1 at ftp.lokigames.com

I am aware of the way to pick an audio and/or a video driver using
environment variables, but is there another way of doing this so that such
a
setting could be in a config file or passed as a command-line parameter?
(aside from setting/restoring the environment from within my code?)

Thanks!

[I guess it’s time I downloaded the source and found out some of these things for myself…]

Olivier A. Dagenais - Software Architect and Developer

Olivier Dagenais wrote:

Actually, I notice MSDN saying the _putenv function only affects the
environment of the running process (a copy of it maintained by the runtime,
to be precise), is it the same on other platforms? If so, would this be an
acceptable solution? (not very elegant, but it seems I don’t have much
choice…)

I believe so, yes. Lots of programs do this.
Agreed, it’s not very elegant, but it should work.

-John–
Underfull \account (badness 10000) has occurred while \spend is active
John R. Hall - Student, Georgia Tech - Contractor, Loki Software

Actually, I notice MSDN saying the _putenv function only affects the
environment of the running process (a copy of it maintained by the runtime,
to be precise), is it the same on other platforms?

no _putenv(), but putenv() is POSIX

I may need to do a typedef or a #ifdef if I want my program to be portable,
then? (there doesn’t seem to be a putenv(), just a _putenv())–

Olivier A. Dagenais - Software Architect and Developer

“Mattias Engdeg?rd” wrote in message

Actually, I notice MSDN saying the _putenv function only affects the
environment of the running process (a copy of it maintained by the
runtime,

to be precise), is it the same on other platforms?

no _putenv(), but putenv() is POSIX

I may need to do a typedef or a #ifdef if I want my program to be
portable,
then? (there doesn’t seem to be a putenv(), just a _putenv())

Runtime library documentation says:
“The names of Microsoft-specific functions and global variables begin with a
single underscore. These names can be overridden only locally, within the
scope of your code. For example, when you include Microsoft run-time header
files, you can still locally override the Microsoft-specific function named
_open by declaring a local variable of the same name. However, you cannot
use this name for your own global function or global variable.”

So this seems to be a “Microsoft-specific” form of the function. However,
there seem to be mappings from names without underscores to those with.

"For compatibility with Microsoft C professional development system version
6.0 and earlier Microsoft C versions, the library OLDNAMES.LIB maps old
names to new names. For instance, open maps to _open. You must explicitly
link with OLDNAMES.LIB only when you compile with the following combinations
of command-line options:

(listing command line options to suppress automatic linking of default
libs)"

putenv also compiles and links normally in VC++ 5.0. ( I didn’t try with the
/nodefaultlibs parameters)

I am aware of the way to pick an audio and/or a video driver using
environment variables, but is there another way of doing this so that such a
setting could be in a config file or passed as a command-line parameter?
(aside from setting/restoring the environment from within my code?)

/* These functions are used internally, and should not be used unless you

  • have a specific need to specify the video driver you want to use.
  • You should normally use SDL_Init() or SDL_InitSubSystem().
    */
    extern DECLSPEC int SDL_VideoInit(const char *driver_name, Uint32 flags);
    extern DECLSPEC int SDL_AudioInit(const char *driver_name);

Thanks!

No problem.

[I guess it’s time I downloaded the source and found out some of these things for myself…]

Or even browse the include files. :slight_smile:

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

/* These functions are used internally, and should not be used
unless you

  • have a specific need to specify the video driver you want to use.
  • You should normally use SDL_Init() or SDL_InitSubSystem().
    */
    extern DECLSPEC int SDL_VideoInit(const char *driver_name, Uint32
    flags);
    extern DECLSPEC int SDL_AudioInit(const char *driver_name);

Now that I have the source code, I see how you’re using these, however
I don’t understand the warning in SDL_video.h, right after the comment
you posted:

“If you use both sound and video in your application, you need to call
SDL_Init() before opening the sound device, otherwise under Win32
DirectX, you won’t be able to set the full-screen display modes.”

Seeing as how SDL_Init calls SDL_InitSubSystem (right after clearing
the error(s)), which in turn calls the appropriate inits (including
both above), the only “gotcha” that the “Win32 DirectX” situation
enforces (that I can see) is that Video is initialized before Audio.

Is that why the comment/warning was written or is the comment
inaccurate and should read “you need to call SDL_VideoInit()
before…”??

Thanks!–

Olivier A. Dagenais - Software Architect and Developer

Seeing as how SDL_Init calls SDL_InitSubSystem (right after clearing
the error(s)), which in turn calls the appropriate inits (including
both above), the only “gotcha” that the “Win32 DirectX” situation
enforces (that I can see) is that Video is initialized before Audio.

Is that why the comment/warning was written

Yep, that’s exactly right.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Seeing as how SDL_Init calls SDL_InitSubSystem (right after
clearing

the error(s)), which in turn calls the appropriate inits
(including

both above), the only “gotcha” that the “Win32 DirectX” situation
enforces (that I can see) is that Video is initialized before
Audio.

Is that why the comment/warning was written
Yep, that’s exactly right.

Might I recommend the comment specify this explicitely by saying
"SDL_InitVideo()" instead of “SDL_Init()”, probably with the
explanation why this is so. (isn’t it because DirectSound needs a
Handle to a Window?)–

Olivier A. Dagenais - Software Architect and Developer