SDL_GetTicks not working after call to settimeofday()?

I have a function to set system date/time. That function uses settimeofday()
on unix and SetSystemTime() on windows. Windows version works fine, but
after I set date on unix, my SDL_GetTicks() function starts returning
grabage values. If I only change a time by minute it starts returning
unbelievably high values and becomes unusable. What cna be the cause for
this problem?_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Vladimir Prelovac a ?crit :

I have a function to set system date/time. That function uses
settimeofday() on unix and SetSystemTime() on windows. Windows version
works fine, but after I set date on unix, my SDL_GetTicks() function
starts returning grabage values. If I only change a time by minute it
starts returning unbelievably high values and becomes unusable. What
cna be the cause for this problem?

SDL uses gettimeofday on linux. So if you use settimeofday you
effectively screw up SDL’s timers.

A workaround could be to do a full SDL reinit before/after your
settimeofday call :

SDL_QuitSubSystem(…)
settimeofday(…)
SDL_Init(…)

Stephane

Thanks Stephane !

It was enough to put

SDL_InitSubSystem(SDL_INIT_TIMER);

after call to settimeofday() to settle things.

There is no need to quit timers before as all this funciton does is sets the
new start value with gettimeofday. You may have a weird frame rate skip
during these calls but that’s it.>SDL uses gettimeofday on linux. So if you use settimeofday you effectively

screw up SDL’s timers.

A workaround could be to do a full SDL reinit before/after your
settimeofday call :

SDL_QuitSubSystem(…)
settimeofday(…)
SDL_Init(…)

Stephane


Express yourself instantly with MSN Messenger! Download today it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/