Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to achieve proper animation using SDL. Used flags are SDL_HWSURFACE and SDL_DOUBLEBUF.

That what I'm getting is technically smooth (I think), but I can figure out what should I do to remove that trail? My animation is time-based (I'm calculating displacement with delta time).

Link to to video:

my (every-frame) drawing function is like:

for(int x = 0; x < screen->w; ++x)
    for(int y = 0; y < screen->h; ++y)
        draw_pixel(screen, x, y, 136, 136, 136);

and ball:

filledCircleColor(screen, ball.x, ball.y, 17, 0x000000ff);

and finally:


main loop is:

for(;;) {
    curr_ts = stopwatch_seconds_elapsed(sw);
    d_time = curr_ts - prev_ts;
    prev_ts = curr_ts;
    cpSpaceStep(space, d_time);
share|improve this question
You may need a higher speed display matrix :p (or more durable eyes) – user1306322 Mar 18 '13 at 12:03
I think I understand what you are getting at but if you could be clearer with what problem you are trying to solve, specifically what you don't like about the animation that would help. You'll want to update the title and the body of the question accordingly. – SpartanDonut Mar 18 '13 at 12:09
how are you clearing? – tm1rbrt Mar 18 '13 at 13:16
Try stepping through the render loop one frame at a time to verify you are actually getting the trails, and it isn't simply an anomaly associated with human eyeballs. If you are still getting the trails, then it is likely because the buffer isn't being properly cleared after each frame. – Evan Mar 18 '13 at 13:49
Evan: Animation snapshot doesn't contain trail. – jacekmigacz Mar 18 '13 at 14:22
up vote 2 down vote accepted

It looks like what you're seeing is a persistence of vision effect. Your circle isn't really leaving a trail, but it looks like it is because it has a very hard edge. If you use a less contrasting image, or just squint, you will probably see that your image doesn't have the trail.

If you want to fix the app so it doesn't look like it has a trail, your best bet is to ensure you are getting a high framerate, or add a bit of fake motion blur so it counters the jagging effect created by your eyes trying to track the object.

share|improve this answer
If you want to be able to tell for sure if it's the program or your eyes, take a screenshot or pause the program when the trail is visible. If it was visible with your eyes but not on the image on screen then it's persistence of vision. – Lunin Mar 18 '13 at 17:48
Also, rendering an anti-aliased version should remove the "hard edge" aspects of the rendering. – Mokosha Mar 18 '13 at 17:59
anti-aliasing won't decrease the high frequency enough to fix this effect unfortunately, otherwise I wouldn't have seen this effect on my moving text. My experience is, if you're moving something around fast enough in 2D, there's not much you can do other than a bit of motion blur to offset eye tracking issues. – Richard Fabian Apr 3 '13 at 16:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.