Using SDL_GetTicks() before SDL_Init()

Hello,

We had a problem with the Battle for Wesnoth game on OS/2 platform,
that it crashed if we had no extra SDL_Init() call.

It turned out, that the crash was in SDL_GetTicks(), and the
reason was that Wesnoth uses the SDL_GetTicks() function too early,
before calling SDL_Init(), which means that SDL_StartTicks() was not
called before.

We could create a workaround, so SDL_GetTicks() on OS/2 now detects
that SDL_StartTicks() was not called before, and calls it if it’s
needed, but I’d like to know, what is the official way of using
this function?

Is it officially needed to call SDL_Init() before using SDL_GetTicks()?

I can see that the other platforms will not crash, as they don’t use
division in there, dividing by a value initialized at SDL_StartTicks()
time, but most of them will also return “invalid” values.

Thanks in advance,
Doodle

Le Sat, 15 Dec 2007 10:04:59 +0100
Doodle a ?crit:

Is it officially needed to call SDL_Init() before using
SDL_GetTicks()?

Yep, I think it is mandatory to call SDL_Init() before any other SDL
function.–
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux

Hello !

Is it officially needed to call SDL_Init() before using SDL_GetTicks()?

I can see that the other platforms will not crash, as they don’t use
division in there, dividing by a value initialized at SDL_StartTicks()
time, but most of them will also return “invalid” values.

I don’t know if it is necessary, but the easy way
around this is to do SDL_Init (SDL_INIT_TIMER) at the start
of your prgramm and then after that use SDL_InitSubsystem (…)
to init Video, Audio and that stuff.

CU