Forcing Aloss of main SDL surface to 0

Hi all,

I have a question related to alpha blending on custom hardware.

First, some background. I have a custom graphics card that uses
32 bpp (RGBA). It’s a video overlay card, so the graphics appear
superimposed on NTSC/PAL video. If alpha is 255, the graphics
obscure the video; if alpha is 0, the graphics are completely
transparent and the video shows through. The application for
the card is animated sprites moving over a transparent background;
the effect then is watching video that has small moving graphics
overlayed on it.

I have modified SDL, adding hooks to my linux driver for the card.
This is working well, and most of the demos run now, including MPEG
playback (video and audio) using smpeg.

The problem is that I’m having trouble figuring out what needs to
be done to specify that my video surface should use alpha. Even
when I call SDL_SetVideoMode(…, 32, …), Aloss is always set to
8, so there is no alpha channel available for use with the primary
SDL screen surface. This does make sense, since in
normal use the background will always be fully opaque; very few
games would want to have a tranparent xterm effect, revealing the
desktop pattern through the background and blitting sprites over
the now-visible desktop.

But, this is precisely the effect I need to perform. There
won’t be any X in the final application; just the custom board running
(hopefully) SDL, overlaying animated sprites on top of a video stream.
I just want to force SDL to keep track of the full 32 bpp RGBA pixels
for every surface, including the primary display surface, so that if
a pixel in the background is semi-transparent orange, then that is
what appears on screen.

In order to force the main background to turn on alpha, I have tried
various things:

 screen = SDL_SetVideoMode(..., 32, ...);
 SDL_SetAlpha( screen, SDL_SRCALPHA, 0 );

This doesn’t seem to work. Another possible approach I found in the API
is to lock the surface, then force the various pixel format fields to
the desired values:

 screen = SDL_SetVideoMode(..., 32, ...);
 if ( SDL_LockSurface( screen ) < 0 ) {
 else {
     screen->format->Aloss = 0;

     screen->format->Rmask = 0xFF000000;
     screen->format->Gmask = 0x00FF0000;
     screen->format->Bmask = 0x0000FF00;
     screen->format->Amask = 0x000000FF;

     screen->format->Rshift = 24;
     screen->format->Gshift = 16;
     screen->format->Bshift =  8;
     screen->format->Ashift =  0;

     SDL_UnlockSurface( screen );

But, as expected, this doesn’t seem to be a very promising avenue either.

If anyone can comment on what I need to do in order to set up the background
surface to properly use alpha, overriding the default Aloss of 8, I would
very much appreciate it.

Thanks for any suggestions,

Steve Madsen
H2Eye Ltd
24-28 Hatton Wall
London EC1N 8JH
Tel:+44 (0) 207 404 9600
Fax: +44 (0) 207 404 9490
Email: @Steve_Madsen