fixed bug where SDL_CreateMutex was being called before SDL_Init; restructured code a little
svn-id: r7510
This commit is contained in:
parent
d4841c9197
commit
fae5ab677c
4 changed files with 21 additions and 9 deletions
|
@ -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 *OSystem_SDL_Common::create(int gfx_mode, bool full_screen) {
|
||||||
OSystem_SDL_Common *syst = OSystem_SDL_Common::create();
|
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) {
|
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());
|
error("Could not initialize SDL: %s.\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_mutex = SDL_CreateMutex();
|
||||||
|
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
|
||||||
// Enable unicode support if possible
|
// 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
|
#ifndef MACOSX // Don't set icon on OS X, as we use a nicer external icon there
|
||||||
// Setup the icon
|
// Setup the icon
|
||||||
syst->setup_icon();
|
setup_icon();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MACOSX // Work around a bug in OS X
|
#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
|
// enable joystick
|
||||||
if (SDL_NumJoysticks() > 0) {
|
if (SDL_NumJoysticks() > 0) {
|
||||||
printf("Using joystick: %s\n", SDL_JoystickName(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)) {
|
void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) {
|
||||||
|
@ -105,7 +113,7 @@ OSystem_SDL_Common::OSystem_SDL_Common()
|
||||||
// reset mouse state
|
// reset mouse state
|
||||||
memset(&km, 0, sizeof(km));
|
memset(&km, 0, sizeof(km));
|
||||||
|
|
||||||
_mutex = SDL_CreateMutex();
|
_mutex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSystem_SDL_Common::~OSystem_SDL_Common() {
|
OSystem_SDL_Common::~OSystem_SDL_Common() {
|
||||||
|
|
|
@ -130,6 +130,10 @@ protected:
|
||||||
OSystem_SDL_Common();
|
OSystem_SDL_Common();
|
||||||
virtual ~OSystem_SDL_Common();
|
virtual ~OSystem_SDL_Common();
|
||||||
|
|
||||||
|
static OSystem *create_intern();
|
||||||
|
|
||||||
|
void init_intern(int gfx_mode, bool full_screen);
|
||||||
|
|
||||||
// unseen game screen
|
// unseen game screen
|
||||||
SDL_Surface *_screen;
|
SDL_Surface *_screen;
|
||||||
int _screenWidth, _screenHeight;
|
int _screenWidth, _screenHeight;
|
||||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
||||||
void hotswap_gfx_mode();
|
void hotswap_gfx_mode();
|
||||||
};
|
};
|
||||||
|
|
||||||
OSystem_SDL_Common *OSystem_SDL_Common::create() {
|
OSystem *OSystem_SDL_Common::create_intern() {
|
||||||
return new OSystem_SDL();
|
return new OSystem_SDL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ protected:
|
||||||
void hotswap_gfx_mode();
|
void hotswap_gfx_mode();
|
||||||
};
|
};
|
||||||
|
|
||||||
OSystem_SDL_Common *OSystem_SDL_Common::create() {
|
OSystem *OSystem_SDL_Common::create_intern() {
|
||||||
return new OSystem_SDL_OpenGL();
|
return new OSystem_SDL_OpenGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue