Sync with timer

I have little problem: syncing action with timer.
My current sync looks like this:

{
t1=SDL_GetTicks();
t=t1-t0;
t0=t1;
Action(t);
}

Animation is not smooth. There are “delays” and “jumps”.
But I can change my loop to:

{
t1=SDL_GetTicks();
t=t1-t0;
t0=t1;
Action(t);
SDL_Delay(20);
}

And animation is smooth! With SDL_Delay(10) problem still exists, but it’s
better than without Delay.

I use OpenGL, and I seen that effect in my few programs, like quite complex 3D
game, and simple rotating cube demo.
I think the problem is SDL_GetTicks returns small integers, is it possible to
get floats, or just smaller units that ticks? What is correct way to sync ?–
Well it’s a cold world And I’m in the middle
Caught in the in-between I don’t belong here
So I’m writing to you It’s wrong here "Letters From Earth"
Where I’m sending you some Letters from Earth - Ronnie James Dio

SDL_GetTicks returns small integers, is it possible to get floats,
or just smaller units that ticks? What is correct way to sync ?

tick == millisecond.

You do NOT need better resolution than this, especially when adding an
SDL_Delay(20) fixes your problem.

Chances are, this is a bug in your code. Please post it, and we can see.

–ryan.

You do NOT need better resolution than this, especially when adding an
SDL_Delay(20) fixes your problem.

SDL_Delay means smaller fps

Chances are, this is a bug in your code. Please post it, and we can see.

I will send you full source in private mail, here it is sync code:

static int t0=0;
int t1,t;
t1=SDL_GetTicks();
if (t0!=0)
{
t=t1-t0;
rx+=axtt/2+sxt;
ry+=ay
tt/2+syt;
rz+=aztt/2+szt;
sx+=ax
t;
sy+=ayt;
sz+=az
t;
}
t0=t1;On Mon, Dec 03, 2001 at 12:41:34AM -0500, Ryan C. Gordon wrote:


Well it’s a cold world And I’m in the middle
Caught in the in-between I don’t belong here
So I’m writing to you It’s wrong here "Letters From Earth"
Where I’m sending you some Letters from Earth - Ronnie James Dio

Or could it be that OpenGL rendering pipeline is in different
thread to your program? Do you get similar experience with non-GL
programs?

My guess is your code is pushing GL states of past moment down the
pipe.

Regards,
.paul.On Mon, Dec 03, 2001 at 12:41:34AM -0500, Ryan C. Gordon wrote:

SDL_GetTicks returns small integers, is it possible to get floats,
or just smaller units that ticks? What is correct way to sync ?

tick == millisecond.

You do NOT need better resolution than this, especially when adding an
SDL_Delay(20) fixes your problem.

Chances are, this is a bug in your code. Please post it, and we can see.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl