Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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: https://vimeo.com/62065078

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:

SDL_Flip(screen);

main loop is:

for(;;) {
    curr_ts = stopwatch_seconds_elapsed(sw);
    d_time = curr_ts - prev_ts;
    prev_ts = curr_ts;
    cpSpaceStep(space, d_time);
    draw_scene(screen);
}
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
2  
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
show 1 more comment

1 Answer

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
add comment

Your Answer

 
discard

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.