# SDL\_UpdateRect(s) and animation

**URL:** <https://discourse.libsdl.org/t/sdl-updaterect-s-and-animation/13900>\
**Category:** SDL Development\
**Created:** [October 2, 2006, 3:12am UTC](https://discourse.libsdl.org/t/sdl-updaterect-s-and-animation/13900 "2006-10-02T03:12:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benang\_at\_cs.its.ac](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/a88e57/32.png) [@benang\_at\_cs.its.ac](https://discourse.libsdl.org/u/benang_at_cs.its.ac)\
**Post date:** [October 2, 2006, 3:12am UTC](https://discourse.libsdl.org/t/sdl-updaterect-s-and-animation/13900/1 "2006-10-02T03:12:34Z")

</div>

Hi again, in my current application the animation is done by calling these  
procedures:

1. Blit the whole background
2. Blit the sprites
3. Flip the surface
4. For the next frame --\> loop to no 1

Well, the application runs fast enough in my PC. But when I run it in an  
embedded platform called EPIA Mini ITX, it lags a lot. Maybe it’s because  
of my way of doing the animation, or maybe it’s because I load all the  
approx. 200 megs of bitmap surfaces in the memory. In a recent message in  
this mailing list, there’s been a discussion about doing animation with  
SDL\_UpdateRect(s). How do I do that? Is there any example for this kind of  
animation system?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Waltzer\_George](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/w/e9bcb4/32.png) [@Waltzer\_George](https://discourse.libsdl.org/u/Waltzer_George)\
**Post date:** [October 2, 2006, 6:54pm UTC](https://discourse.libsdl.org/t/sdl-updaterect-s-and-animation/13900/2 "2006-10-02T18:54:20Z")

</div>

I don’t know about your embeded sistem, but as I could understand so far:  
-If you do not use SDL\_UpdateRect or any other SDL function for doing  
blit/fill operations, you may get slow performance without any 2D  
acceleration.

For SW mode, there may be MMX, SSE accelerated subrutines for intel procs,  
but I don’t know if SDL has implemented all kind of optimizations for all  
cpu’s…

Just an example: If you use HW memory (local video memory) and try to  
blit(SDL does a rect fill if no double buffer) and don’t have some 2D acc or  
simply you do not use SDL functions for this operations… well, it moves  
like crap. On my P4 and X1600, using ddraw, tryed an alpha blit. It moves  
like grandma! Because of the ALPHA operations are not hw accelerated and the  
slow buss to video mem & it is not cached by cpu & etc…

Either you have 2D accel an your video driver (see SDL\_GetVideoInfo)and use  
SDL function for blit/fill or if you don’t, than use the system memory for  
all your drawings buffer/screens, it’s a lot faster. If you wanna be  
generic, use SDL functions for everything(avoid using HW surfaces with  
operations that are not accelerated).

As an example for your animation:  
load for example 10 frames in memory. For each screen update/flip, you do a  
SDL\_UpdateRect (or blit) each time for the consecutive frame. Well, the  
experts may help you further, as a demo I looked into the SDL\_bouncing.zip  
example. Just search for some examples, they are many.On 10/2/06, benang at cs.its.ac.id wrote:

> Hi again, in my current application the animation is done by calling these  
> procedures:
> 
> 1. Blit the whole background
> 2. Blit the sprites
> 3. Flip the surface
> 4. For the next frame → loop to no 1
> 
> Well, the application runs fast enough in my PC. But when I run it in an  
> embedded platform called EPIA Mini ITX, it lags a lot. Maybe it’s because  
> of my way of doing the animation, or maybe it’s because I load all the  
> approx. 200 megs of bitmap surfaces in the memory. In a recent message in  
> this mailing list, there’s been a discussion about doing animation with  
> SDL\_UpdateRect(s). How do I do that? Is there any example for this kind of  
> animation system?
> 
> Thanks in advance.
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

–  
george
