From e534493c42ffa50a95736ce2605c40a42ea64859 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 14 Jun 2004 05:18:09 +0000 Subject: [PATCH] split out SetupSDL --- stepmania/src/SDL_utils.cpp | 13 +++++++++++++ stepmania/src/SDL_utils.h | 2 ++ stepmania/src/StepMania.cpp | 11 ++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index 86e9f434f7..f89ef1957d 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -335,6 +335,19 @@ void SDL_UpdateHWnd() #endif } +void SetupSDL() +{ + static bool bDone = false; + if( bDone ) + return; + bDone = true; + + /* Start SDL (with no subsystems), to make sure we don't use SDL's error handler. */ + SDL_Init( SDL_INIT_NOPARACHUTE ); + + /* Clean up on exit. */ + atexit( SDL_Quit ); +} /* * (c) 2002-2004 Glenn Maynard diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index 70a3113e70..301170990d 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -33,6 +33,8 @@ RageSurface *RageSurfaceFromSDLSurface( SDL_Surface *surf ); void SDL_UpdateHWnd(); +void SetupSDL(); + #endif /* diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index ca4a22f2c2..1623113174 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -968,15 +968,13 @@ int main(int argc, char* argv[]) PREFSMAN->ReadGlobalPrefsFromDisk(); ApplyLogPreferences(); - atexit(SDL_Quit); /* Clean up on exit */ +#if defined(HAVE_SDL) + SetupSDL(); +#endif /* This should be done after PREFSMAN is set up, so it can use Dialog::OK(). */ Dialog::Init(); - /* Fire up the SDL, but don't actually start any subsystems. - * We use our own error handlers. */ - SDL_Init( SDL_INIT_NOPARACHUTE ); - // // Create game objects // @@ -1067,8 +1065,7 @@ int main(int argc, char* argv[]) SONGMAN->PreloadSongImages(); /* This initializes objects that change the SDL event mask, and has other - * dependencies on the SDL video subsystem, so it must be initialized after - * DISPLAY and setting the default SDL event mask. */ + * dependencies on the SDL video subsystem, so it must be initialized after DISPLAY. */ INPUTMAN = new RageInput; // These things depend on the TextureManager, so do them after!