do SDL_Init in 1 step as required, no SDL parachute unless fullscreen

This commit is contained in:
Albert Cahalan 2005-01-02 21:18:57 +00:00
parent cf711e956e
commit 778f399ab5

View file

@ -6625,70 +6625,42 @@ static void setup(int argc, char * argv[])
} }
/* Init SDL Video: */ Uint32 init_flags = SDL_INIT_VIDEO|SDL_INIT_TIMER;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
fprintf(stderr,
"\nError: I could not initialize video!\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
exit(1);
}
/* Set-up Key-Repeat: */
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
SDL_DEFAULT_REPEAT_INTERVAL);
/* Init SDL Timer: */
if (SDL_Init(SDL_INIT_TIMER) < 0)
{
fprintf(stderr,
"\nError: I could not initialize timer!\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
exit(1);
}
/* Init TTF stuff: */
if (TTF_Init() < 0)
{
fprintf(stderr,
"\nError: I could not initialize the font (TTF) library!\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
SDL_Quit();
exit(1);
}
/* Init SDL Audio and set-up Mixer: */
#ifndef NOSOUND
if(use_sound) if(use_sound)
init_flags |= SDL_INIT_AUDIO;
if(!fullscreen)
init_flags |= SDL_INIT_NOPARACHUTE; // allow debugger to catch crash
/* Init SDL */
if (SDL_Init(init_flags) < 0)
{ {
if (SDL_Init(SDL_INIT_AUDIO) < 0) #ifndef NOSOUND
use_sound = 0;
init_flags &= ~SDL_INIT_AUDIO;
char *olderr = strdup(SDL_GetError());
if (SDL_Init(init_flags) >= 0)
{ {
// worked, w/o sound
fprintf(stderr, fprintf(stderr,
"\nWarning: I could not initialize audio!\n" "\nWarning: I could not initialize audio!\n"
"The Simple DirectMedia Layer error that occurred was:\n" "The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError()); "%s\n\n", SDL_GetError());
use_sound = 0; free(olderr);
} }
else else
{
#ifndef WIN32
if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) < 0)
#else
if (Mix_OpenAudio(44100, AUDIO_S16, 2, 2048) < 0)
#endif #endif
{
fprintf(stderr,
"\nError: I could not initialize video and/or the timer!\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
exit(1);
}
}
#ifndef NOSOUND
// need Mix_OpenAudio(44100, AUDIO_S16, 2, 2048) for WIN32 ?
if (use_sound && Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) < 0)
{ {
fprintf(stderr, fprintf(stderr,
"\nWarning: I could not set up audio for 44100 Hz " "\nWarning: I could not set up audio for 44100 Hz "
@ -6697,11 +6669,9 @@ static void setup(int argc, char * argv[])
"%s\n\n", SDL_GetError()); "%s\n\n", SDL_GetError());
use_sound = 0; use_sound = 0;
} }
else
{
/* Load sounds: */
for (i = 0; i < NUM_SOUNDS; i++) i = NUM_SOUNDS;
while(use_sound && i--)
{ {
sounds[i] = Mix_LoadWAV(sound_fnames[i]); sounds[i] = Mix_LoadWAV(sound_fnames[i]);
@ -6714,12 +6684,27 @@ static void setup(int argc, char * argv[])
use_sound = 0; use_sound = 0;
} }
} }
}
}
}
#endif #endif
/* Set-up Key-Repeat: */
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
SDL_DEFAULT_REPEAT_INTERVAL);
/* Init TTF stuff: */
if (TTF_Init() < 0)
{
fprintf(stderr,
"\nError: I could not initialize the font (TTF) library!\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
SDL_Quit();
exit(1);
}
setup_screen_layout(); setup_screen_layout();
/* Set window icon and caption: */ /* Set window icon and caption: */