SDL_gfx broken?

Does anyone know what’s going on with the drawing primitives in the
SDL_gfx library? It appears to be completely broken. The *RGBA
functions fail to draw either the red or alpha channel, depending on my
surface’s format, and the *Color functions do absolutely nothing.

Thanks.

Mike Benfield

What version are you using? What platform are you under? SDL_gfx works great
for me so I suspect it’s some sort of build issue.On August 31, 2005 04:37 am, Michael Benfield wrote:

Does anyone know what’s going on with the drawing primitives in the
SDL_gfx library? It appears to be completely broken. The *RGBA
functions fail to draw either the red or alpha channel, depending on my
surface’s format, and the *Color functions do absolutely nothing.

Does anyone know what’s going on with the drawing primitives in the
SDL_gfx library? It appears to be completely broken. The *RGBA
functions fail to draw either the red or alpha channel, depending on
my
surface’s format, and the *Color functions do absolutely nothing.
What version are you using? What platform are you under? SDL_gfx
works great
for me so I suspect it’s some sort of build issue.

I’m using version 2.0.13. I tried on both Mac OS X and x86 Linux.

Mike BenfieldOn Aug 31, 2005, at 10:41 AM, Tyler Montbriand wrote:

On August 31, 2005 04:37 am, Michael Benfield wrote:

Can you post a minimal example showing the problem?On August 31, 2005 09:50 am, Michael Benfield wrote:

On Aug 31, 2005, at 10:41 AM, Tyler Montbriand wrote:

What version are you using? What platform are you under? SDL_gfx
works great
for me so I suspect it’s some sort of build issue.

I’m using version 2.0.13. I tried on both Mac OS X and x86 Linux.

Mike Benfield

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.

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.

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(;:wink: {
SDL_PollEvent(&e);
if(e.type == SDL_QUIT)
break;
}
}
}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.

– JoshOn 8/31/05, Michael Benfield wrote:

On Aug 31, 2005, at 12:17 PM, Tyler Montbriand wrote:

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(;:wink: {
SDL_PollEvent(&e);
if(e.type == SDL_QUIT)
break;
}
}
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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.

No. I know this. As you can see in the example I attached to the other
email, that’s how I did it (and the *RGBA varieties give me the same
problems, anyway). (although in that example I did forget to take into
account endianness; this is only correct on a big endian computer…
but it doesn’t really matter. Either way it’s still not doing the right
thing.)

Mike BenfieldOn Aug 31, 2005, at 6:13 PM, Joshua Oreman wrote:

Could somebody please just run this code and tell me what shows up?

This code makes a white background, and then tries to blit a red square
in the upper left corner, upper right corner, and lower left corner.
However, the one in the upper left corner turns up black, and the one
in the lower left corner doesn’t show up at all. Experiments with other
bit depths are even more screwed up.

#include<SDL.h>
#include<SDL_gfxPrimitives.h>

int main(int argc, char** argv)
{
SDL_Rect r;
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(400, 400, 32, 0);
boxRGBA(SDL_GetVideoSurface(), 0, 0, 399, 399, 255, 255, 255, 255);

Uint32 mask1 = 0xff000000; Uint32 mask2 = 0x00ff0000;
Uint32 mask3 = 0x0000ff00; Uint32 mask4 = 0x000000ff;

SDL_Surface* s1 =
SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
boxRGBA(s1, 0, 0, 199, 199, 255, 0, 0, 254);
r.x = 0; r.y = 0;
SDL_BlitSurface(s1, 0, SDL_GetVideoSurface(), &r);

SDL_Surface* s2 =
SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
boxRGBA(s2, 0, 0, 199, 199, 255, 0, 0, 254);
r.x = 0; r.y = 200;
SDL_BlitSurface(s2, 0, SDL_GetVideoSurface(), &r);

SDL_Surface* s3 =
SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
boxRGBA(s3, 0, 0, 199, 199, 255, 0, 0, 255);
r.x = 200; r.y = 0;
SDL_BlitSurface(s3, 0, SDL_GetVideoSurface(), &r);

SDL_Flip(SDL_GetVideoSurface());

SDL_Event e;
for(;:wink: {
SDL_PollEvent(&e);
if(e.type == SDL_QUIT)
break;
}

}