Gunnar G wrote:
Tim Oertel wrote:
Odds are good you are doing alpha blending, which you probably
don’t want at this point.
Check the color/function you are using
to draw the shapes. You probably want the alpha to be 0 (or is
it 255, I forget…), if it is something like 0x80, it’ll give
the results you are seeing.
If I just want to use RGB colours, i.e. three unsigned 8-bit values, what
should I do?
In the SDL_gfxprimitives.h it says: Uint32 as the datatype for the
colour.
Yes, for the *Color() primitives, it is a 32 bit value. It is RRGGBBAA, so for
red, you’d use 0xFF0000FF, or black you’d use 0x000000FF. For a somewhat
transparent blue, you could use 0x0000FF7F.
If you aren’t familiar with alpha blending, draw a few overlapping boxes,
with a given alpha value, a little playing should give you a decent feel
for it.
For instance:
boxColor(surf, 0, 0, 200, 200, 0xFF000020);
boxColor(surf, 20, 20, 220, 220, 0xFF000020);
boxColor(surf, 40, 40, 240, 240, 0xFF000020);
boxColor(surf, 0, 300, 200, 500, 0x00FF0080);
boxColor(surf, 20, 320, 220, 520, 0x00FF0080);
boxColor(surf, 40, 340, 240, 540, 0x00FF0080);
I guess I should instead ask the question: what is the absolutly best thing
to read to learn about SDL? One feel a little resistant to order a book
that is 2-3 years old. Things are developing so fast…
SDL is pretty nice in that the API is pretty straight forward, and there
is a goodly amount of documentation out there. I used the API reference,
and that took me most of the way. There is also a LARGE amount of source
code that uses SDL, including quite a few example programs. That’s what
I’d recommend.