diff options
author | Max Horn | 2003-05-14 19:44:41 +0000 |
---|---|---|
committer | Max Horn | 2003-05-14 19:44:41 +0000 |
commit | fae5ab677c1c3d3042c48f73a34f66ce3f2fdba4 (patch) | |
tree | cda7c0a6d6141ef998f2bee5fdbca5b583ef8bc9 /backends | |
parent | d4841c91972027c230b3941699a138cf427f652e (diff) | |
download | scummvm-rg350-fae5ab677c1c3d3042c48f73a34f66ce3f2fdba4.tar.gz scummvm-rg350-fae5ab677c1c3d3042c48f73a34f66ce3f2fdba4.tar.bz2 scummvm-rg350-fae5ab677c1c3d3042c48f73a34f66ce3f2fdba4.zip |
fixed bug where SDL_CreateMutex was being called before SDL_Init; restructured code a little
svn-id: r7510
Diffstat (limited to 'backends')
-rw-r--r-- | backends/sdl/sdl-common.cpp | 22 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 4 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 2 | ||||
-rw-r--r-- | backends/sdl/sdl_gl.cpp | 2 |
4 files changed, 21 insertions, 9 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index e258957cb2..34c3ee2c35 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -53,13 +53,23 @@ OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) { OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen) { OSystem_SDL_Common *syst = OSystem_SDL_Common::create(); - syst->_mode = gfx_mode; - syst->_full_screen = full_screen; + + syst->init_intern(gfx_mode, full_screen); + + return syst; +} + +void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen) { + + _mode = gfx_mode; + _full_screen = full_screen; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) { error("Could not initialize SDL: %s.\n", SDL_GetError()); } + _mutex = SDL_CreateMutex(); + SDL_ShowCursor(SDL_DISABLE); // Enable unicode support if possible @@ -67,7 +77,7 @@ OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen) { #ifndef MACOSX // Don't set icon on OS X, as we use a nicer external icon there // Setup the icon - syst->setup_icon(); + setup_icon(); #endif #ifndef MACOSX // Work around a bug in OS X @@ -79,10 +89,8 @@ OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen) { // enable joystick if (SDL_NumJoysticks() > 0) { printf("Using joystick: %s\n", SDL_JoystickName(0)); - syst->init_joystick(); + init_joystick(); } - - return syst; } void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) { @@ -105,7 +113,7 @@ OSystem_SDL_Common::OSystem_SDL_Common() // reset mouse state memset(&km, 0, sizeof(km)); - _mutex = SDL_CreateMutex(); + _mutex = 0; } OSystem_SDL_Common::~OSystem_SDL_Common() { diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index ca90335a4a..409d4183fb 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -130,6 +130,10 @@ protected: OSystem_SDL_Common(); virtual ~OSystem_SDL_Common(); + static OSystem *create_intern(); + + void init_intern(int gfx_mode, bool full_screen); + // unseen game screen SDL_Surface *_screen; int _screenWidth, _screenHeight; diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 13cf5fe087..b2134be962 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -48,7 +48,7 @@ protected: void hotswap_gfx_mode(); }; -OSystem_SDL_Common *OSystem_SDL_Common::create() { +OSystem *OSystem_SDL_Common::create_intern() { return new OSystem_SDL(); } diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 3980d28ced..35d88d2e4b 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -69,7 +69,7 @@ protected: void hotswap_gfx_mode(); }; -OSystem_SDL_Common *OSystem_SDL_Common::create() { +OSystem *OSystem_SDL_Common::create_intern() { return new OSystem_SDL_OpenGL(); } |