[SDL] SDL_image and memory

David Olofson david at olofson.net
Tue Sep 19 23:33:42 PDT 2006


On Wednesday 20 September 2006 06:15, benang at cs.its.ac.id wrote:
> Thanks for the reply. Okay what if I change my question. If I load
> the resources into RWops pointers, and convert them to SDL_Surface
> only when needed, would the cost of conversion be more efficient
> than if the SDL_Surface were all (or partially) be read from the
> swap pagefile (obviously it will happen because the total of the
> bitmap files are 6-700 megs whereas my memory is only 512 megs)?

As far as performance is concerned, that depends on the speed of the 
disk the swap is on, in relation to the speed of the CPU. Also, if 
your application already needs a lot of CPU time, adding 
decompression overhead might be worse than streaming from disk, even 
if the disk is relatively slow.

There is another problem, however: Timing. Disk access is rather 
"random" in nature; sometimes it's very quick (data already cached or 
in the read-ahead buffers), and sometimes very slow (data needs to be 
read from the physical disk before your application can continue). To 
keep the disk access from making animation unsmooth, you'd need to do 
the disk access in a background thread or similar.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'




More information about the SDL mailing list