[SDL] Hardware surfaces Again
Brian
brian.ripoff at gmail.com
Wed Aug 8 01:52:57 PDT 2007
I think that will leak memory =). SDL_DisplayFormatAlpha copies a
surface, so this function has 2 places where a surface is copied but
the original is never freed. In addition to which you pass the
HW_SURFACE you create back to SDL_DisplayFormatAlpha again, thus you
cannot be sure its in video memory (depending on what
DisplayFormatAlpha does internally). Finally you have no guarantees
that SDL_CreateRGBSurface will return a HW_SURFACE anyway. You can
check by inspecting surface->flags.
An quick peek at surface.c in the SDL source (1.2) says that unless
the SDL_VideoInfo says that we have hardware accelerated alpha blits
(blit_hw_A) then the surface will go in system memory.
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fVideoInfo
You have been warned that SDL (1.2 again) (allegedly) does not have
support for hardware accelerated alpha blits? You could see a slow
down by having *any* of your surfaces in video memory if you are
blending with them.
Bob Pendleton's articles on SDL are must reads, in your case take a
look at the hardware surface one in particular:
http://www.oreillynet.com/articles/author/1205
Have you tested and compared performance when surfaces are in and out
of video memory, and the effect SDL_DisplayFormatAlpha has in each
case?
If your program depends heavily on fast alpha blending then you may
find that opengl would probably be more suitable.
Hope this is helpful...
On 08/08/07, Patricia Curtis <patricia.curtis at gmail.com> wrote:
> Hi Guys
> I have implemented some code to make hardware surfaces, but i am
> not sure if i have it right so could someone look at this for me, 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. 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)
More information about the SDL
mailing list