[SDL] The perfect transparent surface. ( Improved question )

Alberto Luaces aluaces at udc.es
Tue Nov 6 01:08:45 PST 2007


El Monday 05 November 2007 17:58:21 Miguel Pragier escribió:
> > What's the better way to create a 100% transparent surface?
> >  
> > If exist a kind of 'design pattern" to create transparent surfaces, can
>
> anyone point me a code sample?
>
> >  
> > And can anyone tell me any information about the color masks?
>
> What's the best SDL's way to create a 800x600 32Bpp surface 100%
> transparent?
>
> I know the SDL_CreateRGBSurface, but don't know much about the color mask.
> specially the AMask.

Every mask is the binary mask that specify where its colour component is 
stored. From the documentation example:

    SDL_Surface *surface;
    Uint32 rmask, gmask, bmask, amask;

    /* SDL interprets each pixel as a 32-bit number, so our masks must depend
       on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    rmask = 0xff000000;
    gmask = 0x00ff0000;
    bmask = 0x0000ff00;
    amask = 0x000000ff;
#else
    rmask = 0x000000ff;
    gmask = 0x0000ff00;
    bmask = 0x00ff0000;
    amask = 0xff000000;
#endif

    surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
                                   rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?


More information about the SDL mailing list