[SDL] Faster way to do an SDL_BlitSurface

Brian brian.ripoff at gmail.com
Fri May 4 01:19:39 PDT 2007


Where did you hear memcpy would be faster?

SDL_BlitSurface is already highly optimised, taking advantage of
various special instructions available on different CPUs. If the SDL
developers found that memcpy could blit faster on a particular
platform, then that's what they would use.

As for why you are getting a corrupted display, are both surfaces
software surfaces? If not you'll need to lock hardware ones. Do they
both share the same BitsPerPixel and colour formats? You may find that
converting all surfaces to software can improve performance anyway,
depending on the types of surfaces (alpha blending in particular, and
any pixel manipulation are horribly slow on hardware surfaces).
Another potential time saver would be do blit the large image (which
Im assuming is a background) once, and only re-blit small portions of
it when a sprite moves across the screen. For a static background this
will really help.

Finally however, I will point you to Bob Pendleton's excellent articles on SDL:
http://www.oreillynet.com/articles/author/1205

There's some very good information about SDL and blitting in these,
they are well worth the read.

Cheers,
      Brian.

On 5/4/07, Manuel García Cabrera <manugarciac5 at yahoo.com.ar> wrote:
> I heard that with memcpy it should be faster, and it seems to be, but
> the result is not good.


More information about the SDL mailing list