[SDL] aalineRGBA problem

Tommi Kyntola tommi.kyntola at ray.fi
Wed Jun 14 01:27:40 PDT 2006


Armin Steinhoff wrote:
> "clemens kirchgatterer" <everslick at gmail.com> schrieb am 13.06.2006 13:41:16:
>>>> I suggest you skip the alpha stuff unless you need it and use
>>>> SDL_DisplayFormat to get an image suitable for blitting.
>>>> You're using ABGR, which on little endian machines happens to be what
>>>> the opengl wants (big endiand RGBA), but using that to blit
>>>> on screen in 2D is probably not what you're looking for, because I'm
>>>> betting you're display surface has something other than ABGR
>>>> (could it be ARGB?).
>>> Sorry ... I don't understand fully the concept behind these RGBA masks.
>> the RGBA mask defines where in a single pixelvalue the different color
>> channels get stored. this means, for example, if you are in a 32 bit mode,
>> one pixel is stored in a 32 bit integer and each color of RGBA use 8 bits.
>>
>> pixel = 00101001 00101111 10101011 00011100
>>
>> if the masks are set as follwing:
>>
>> amask = 0xff000000
>> rmask = 0x000000ff
>> gmask = 0x0000ff00
>> bmask = 0x00ff0000
>>
>> then the MSB holds the alpha value of the pixel and the LSB the red
>> colour channel. you get the idea?
> 
> Yes ... but does it mean I can define the pixel format in that way for my individual surfaces ?

I stand corrected, but my understanding is that yes. Those masks, and
those alone once bpp has been defined, define how SDL and others (like
SDL_gfx) use the per pixel bits when they draw onto that surface aswell
as when they blit from that surface.

For example giving correct bitmasks and 32 bpp is all that it takes
for a surface to be compatible with opengl.

(granted there are things like SRCALPHA and other flags that also have
  effect here, but basically that's how it goes)

> What happens if I use mask values different from 0xFF?

Hmmm, someone with more insight on this might shed some more
light on this, but my guess is that most sw assume that the
bits in each mask are at least consecutive. Without that
assumption it's a tad more difficult to calculate the range
of each color.

In any case, wither it's supported or not to use masks like
0x00aaaa00, 0x55550000, 0xaa0000aa, 0x00005555, or not, I'd
still call such masks "asking for it".

cheers,
Tommi Kyntola





More information about the SDL mailing list