I believe that if you could post your main loop's code that would allow us to help you more.while(!exitProgram) { fps.start(); if(menu->screenMode == PlayingGame) gameLoop();//this checks input and animates one frame else menuLoop();//this checks input and animates one frame if(menu->screenMode == PlayingGame) game->Draw(screen); else menu->Draw(screen); SDL_Flip(screen); diff = (1000 / updateFPS) - fps.GetTicks(); if( diff > 0 ) SDL_Delay( diff ); }
Edited: Because I pasted a load of crap by accident. fps class just records the number of ticks (GetTicks return the time passed since Start)
I don't see any problems here. Probably the frames take too long to draw. Did you check how much time does it take to draw one frame?
You may also check if you haven't got any float/int implicit conversions taking place. It's a longshot but it's easy to miss and causes strange errors.
Also, how do you store coordinates? They shouldn't be ints, the conversion to int should be just before drawing. Rounding can cause laggy movement.
Hmmm, well as I explained before all menuLoop bit does is blit a background image and display about 50 16x16 images. So it's not doing a great deal.
Thing is, I seem to recall doing a scrolling message using AMOS basic about 20 years ago and getting PERFECT scrolling, no jitter, no worries. Now, I did have a fixed delay then as my brain hadn't figured out the variable-delay-dependant-on-draw-time bit but still... Of course my Amiga would've just had the AMOS process running, so no background threads/processes to cause jitter. This, I think, is the problem I'm encountering.
Also, the co-ords as ints comment: I'm using a 1 to 1 co-ord to pixel ratio, so I don't understand. I guess I could scale the scroller position up, move a fraction then scale down to draw...but I'm scrolling it along 1 pixel at a time right now, so I dont see the benefit.
If the time needed to draw the frame is low as you say then I highly doubt that any applications running in the background could cause that (if you're not running movie encoding or something very, very resource intensive). The priority and scheduling tricks are reserved for extremely low latency applications which do something hundreds of thousands times a second or so - that's when the system scheduler can cause jitter, not in your case. I had to use this tricks when I was doing RGB LED PWM modulation by LPT port. The modulation pulses where generated by the CPU...
Just check your CPU load graph.
Running here at work (on windows Vista, ughh), it's using 3% CPU on a 3GigHz machine! It's not running too fast for the Delay but STILL it jitters. I reckon this can only mean that the SDL_GetTicks() isn't accurate enough. Is it worth trying a higher resolution timer?











