rwkc / devnotes

SDL drawing speed

Time taken to draw the background:
- Without optim                : 9996346 ns (10 ms)
- With SDL_DisplayFormatAlpha(): 1259087 ns (1.3 ms)
- With SDL_DisplayFormat()     :  422413 ns (0.42 ms)

That is a 23x speed gain!


1) Profile your code even when it's fast enough on your hardware.
   10 ms to draw a simple 640*480 background on a recent PC is not normal.
   Think of all the kittens dying because of the pollution and fix the problem.

2) Always call SDL_DisplayFormat() after loading an image!

Only use SDL_DisplayFormatAlpha() for images with a true alpha channel;
SDL_DisplayFormat() works fine for images with a colorkey (transparency mask).

Consider using a colorkey instead of an alpha channel in your images (3x speed gain).