Timer Confusion

I attempted to make a timer (code attached), but it doesn’t seem to do
much. You press t to turn the timer on, but I don’t see any difference
on my computer. So …

Can someone explain to my the basics of making a timer w/ SDL_GetTicks
such that the framerate is constant on every computer and my program
won’t take much massive amounts of CPU from blitting as fast as
possible? Can somebody help me here?

Thanks!–

saved=SDL_GetTicks();

bar.x=10;
bar.y=screen->h-40;

//put in the image size:
bar.w=image->w;
bar.h=image->h;

SDL_BlitSurface(image, NULL, screen, &bar); //to position on screen

SDL_UpdateRects(screen,1,&bar); //only this one is updated

// check for events
handleEvents();

ok=0;

while (!ok)
{

int wanted= (int)(1000 / frameRate);

if (SDL_GetTicks() - saved > wanted) //
{
ok=1;

}
}

“Christopher Thielen” a ?crit dans le message news:
mailman.1015111142.24265.sdl at libsdl.org…> I attempted to make a timer (code attached), but it doesn’t seem to do

much. You press t to turn the timer on, but I don’t see any difference
on my computer. So …

Can someone explain to my the basics of making a timer w/ SDL_GetTicks
such that the framerate is constant on every computer and my program
won’t take much massive amounts of CPU from blitting as fast as
possible? Can somebody help me here?

Thanks!