[SDL] SDL_gfx broken ?
Joshua Oreman
oremanj at gmail.com
Wed Aug 31 15:13:23 PDT 2005
On 8/31/05, Michael Benfield <leftfist at mac.com> wrote:
>
> On Aug 31, 2005, at 12:17 PM, Tyler Montbriand wrote:
> > Can you post a minimal example showing the problem?
> >
>
> Indeed. This example should spray an orange box on the screen but the
> box comes out green because the red channel left at 0. If I make it
> opaque (by making pcolor[3] = 255), the box is orange as it should be.
> If I comment out the masks and uncomment the other set of masks, no box
> is visible, because it's the alpha channel that is left at 0. (This is
> on a big endian system. I think on a little endian system the situation
> is reversed.) What I said earlier about the *Color varieties doing
> nothing doesn't seem to be the case; I'm not sure what I was doing
> wrong then.
The *Color varieties don't take a MapRGB()'ed color. They take a
32-bit value of the format 0xRRGGBBAA.
I think this might be the cause of your error.
>
> Also, while I'm on the topic.. Why does the code for these drawing
> primitives do checks for endianness? Doesn't SDL_MapRGBA make that
> unnecessary? It does in my testing.
To know whether *(Uint8 *)color is RR or AA.
-- Josh
>
> I appreciate your help.
>
> #include<stdio.h>
> #include<SDL.h>
> #include<SDL_gfxPrimitives.h>
>
> int main(int argc, char** argv)
> {
> SDL_Init(SDL_INIT_VIDEO);
> SDL_SetVideoMode(400, 400, 32, 0);
> SDL_Surface* s = SDL_CreateRGBSurface(0, 200, 200, 32,
> 0xff000000, 0x00ff0000,
> 0x0000ff00, 0x000000ff);
> //0x000000ff, 0x0000ff00,
> //0x00ff0000, 0xff000000);
> Uint32 color;
> Uint8* pcolor = (Uint8*) &color;
> pcolor[0] = 200; pcolor[1] = 100; pcolor[2] = 10; pcolor[3] = 254;
> //if(boxRGBA(s, 0, 0, 199, 199, pcolor[0], pcolor[1],
> // pcolor[2], pcolor[3])) {
> if(boxColor(s, 10, 10, 199, 199, color)) {
> printf("error\n");
> } else {
> SDL_BlitSurface(s, 0, SDL_GetVideoSurface(), 0);
> SDL_Flip(SDL_GetVideoSurface());
> SDL_Event e;
> for(;;) {
> SDL_PollEvent(&e);
> if(e.type == SDL_QUIT)
> break;
> }
> }
> }
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
More information about the SDL
mailing list