SDL_DisplayFormatAlpha() in fullscreen on Win32

Hi,

I am writing a demo but I have a problem in fullscreen on Win32. The
code is this:

dst = SDL_DisplayFormatAlpha(src);
printf("%08x R\n", dst->format->Rmask);
printf("%08x G\n", dst->format->Gmask);
printf("%08x B\n", dst->format->Bmask);
printf("%08x A\n", dst->format->Amask);

on gnu/Linux (PPC) it prints

00ff0000 R
0000ff00 G
000000ff B
ff000000 A

and on Win32 in a window

00ff0000 R
0000ff00 G
000000ff B
ff000000 A

but when I run it in fullscreen (on windows) it prints

00ff0000 R
0000ff00 G
000000ff B
00000000 A

There is no alpha channel? man SDL_DisplayFormatAlpha says “This
function takes a surface and copies it to a new surface of the pixel
format and colors of the video frame buffer plus an alpha channel”.

I have tested it with the same results on Windows 98, 2000 and XP.

Is this a known problem (I searched the archives and google, but didn’t
find anything)?

thanks,
Morten–
Morten Poulsen <@Morten_Poulsen>
http://www.afdelingp.dk/

Thus spake the master programmer: “Let the programmers be many and the
managers few – then all will be productive.”

Morten Poulsen wrote:

but when I run it in fullscreen (on windows) it prints

00ff0000 R
0000ff00 G
000000ff B
00000000 A

can you write a complete minimal testcase?

[CC:ed to sdl-list and Sam]

Morten Poulsen wrote:

can you write a complete minimal testcase?

Yes, sorry… I’ve written one now: http://www.afdelingp.dk/files/sdl/

Thanks. Apparently there’s a bug when converting a surface with alpha channel
to a hardware surface (the alpha just gets stripped). This patch should
help. Sam, please apply.

Index: SDL_surface.c===================================================================
RCS file: /home/slouken/libsdl.org/cvs/SDL12/src/video/SDL_surface.c,v
retrieving revision 1.3
diff -u -r1.3 SDL_surface.c
— SDL_surface.c 2001/07/31 05:36:10 1.3
+++ SDL_surface.c 2002/01/14 13:40:44
@@ -711,6 +711,14 @@
}
}

  • /* Only create hw surfaces with alpha channel if hw alpha blits
  •  are supported */
    
  • if(format->Amask != 0 && (flags & SDL_HWSURFACE)) {
  •   const SDL_VideoInfo *vi = SDL_GetVideoInfo();
    
  •   if(!vi || !vi->blit_hw_A)
    
  •   	flags &= ~SDL_HWSURFACE;
    
  • }
  • /* Create a new surface with the desired format */
    convert = SDL_CreateRGBSurface(flags,
    surface->w, surface->h, format->BitsPerPixel,

Yes, it fixed it. Thanks. :-)On Mon, 2002-01-14 at 14:53, Mattias Engdegard wrote:

Thanks. Apparently there’s a bug when converting a surface with alpha channel
to a hardware surface (the alpha just gets stripped). This patch should
help.


Morten Poulsen <@Morten_Poulsen>
http://www.afdelingp.dk/

Thus spake the master programmer: “Let the programmers be many and the
managers few – then all will be productive.”