[SDL] Hardware surfaces Again

Clemens Kirchgatterer clemens at 1541.org
Wed Aug 8 01:10:55 PDT 2007


"Patricia Curtis" <patricia.curtis at gmail.com> wrote:

> also I have had to use SDL_DisplayFormatAlpha or everything that
> moved on the screen left trails which all though they looked good,
> they were obviously not right.

this is most likely due to a very common error not to
delete/refresh/whatever the background and has nothing to do with
alphablending in the first place. unless i misundersand things here.

> I also remember i think it was Torsten
> saying don't use SDL_DisplayFormatAlpha so whats right whats wrong
> and what can i do to make use of the hardware for blitting with and
> without alpha channels)

the real question is if SDL_DisplayFormatAlpha() will always return an
SWSURFACE even you feed it a SDL_HWSURFACE. the procedure torsten
suggested was create an RGBA hardware surface with

SDL_CreateRGBASurface(SDL_HWSURFACE, w, h, 0, 0, 0, 0);
(let SDL figure the last four parameters)

and blit the surface returned form LoadImage onto your newly created
one, but switch off per pixel alpha blending first, otherwise the blit
will deploy the alpha instead of copying it. IIRC this is documented
rather well in the SDL online docu.

hope this helps ...
clemens


More information about the SDL mailing list