SDL_BYTEORDER and amask

In Tux Paint, I have the following piece of code:

/* Create a surface to render into: */

if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
amask = 0x000000FF;
else
amask = 0xFF000000;

img_cur_brush =
SDL_CreateRGBSurface(SDL_SWSURFACE,
img_brushes[cur_brush]->w,
img_brushes[cur_brush]->h,
img_brushes[cur_brush]->format->BitsPerPixel,
img_brushes[cur_brush]->format->Rmask,
img_brushes[cur_brush]->format->Gmask,
img_brushes[cur_brush]->format->Bmask,
amask);

Works great! Except on Sparcs (both Solaris and Linux).

When I tried reversing the ‘amask’ decision
( e.g., making it: “if (SDL_BYTEORDER != SDL_BIG_ENDIAN)” )
and then run it again on my Linux/Intel box here, I get
similar (incorrect) results as the Sparc users are when the test is as shown
above.

Is that test correct or appropriate? I assume the “SDL_BYTEORDER” is
set correctly for Sparc users, and that either I don’t understand
(or was misinformed) as to what to do about deciding what ‘amask’ should be.

Any ideas? I’m going to have one of the Sparc users try reversing the
’if’ on their system, and see if things work right for them.

If that works, should I assume that ‘amask’ is the same across all
architectures? Or…?

Thanks!

-bill!

Hmm… If you already have the r, g & b masks,
wouldn’t it be easiest to do:

amask = ~(img_brushes[cur_brush]->format->Rmask |
img_brushes[cur_brush]->format->Gmask |
img_brushes[cur_brush]->format->Bmask);

That’s assuming a 32 bit surface, but I’m sure you
could taylor it to other situations… no?

Best Wishes,

-Loren

— nbs wrote:>

In Tux Paint, I have the following piece of code:

/* Create a surface to render into: */

if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
amask = 0x000000FF;
else
amask = 0xFF000000;

img_cur_brush =
SDL_CreateRGBSurface(SDL_SWSURFACE,
img_brushes[cur_brush]->w,
img_brushes[cur_brush]->h,

img_brushes[cur_brush]->format->BitsPerPixel,

img_brushes[cur_brush]->format->Rmask,

img_brushes[cur_brush]->format->Gmask,

img_brushes[cur_brush]->format->Bmask,
amask);

Works great! Except on Sparcs (both Solaris and
Linux).

When I tried reversing the ‘amask’ decision
( e.g., making it: “if (SDL_BYTEORDER !=
SDL_BIG_ENDIAN)” )
and then run it again on my Linux/Intel box here, I
get
similar (incorrect) results as the Sparc users are
when the test is as shown
above.

Is that test correct or appropriate? I assume the
"SDL_BYTEORDER" is
set correctly for Sparc users, and that either I
don’t understand
(or was misinformed) as to what to do about deciding
what ‘amask’ should be.

Any ideas? I’m going to have one of the Sparc users
try reversing the
’if’ on their system, and see if things work right
for them.

If that works, should I assume that ‘amask’ is the
same across all
architectures? Or…?

Thanks!

-bill!


Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

Thanks! :slight_smile: Duh, why didn’t I think of that!

I’ve confirmed that everything still works right on my x86 Linux box.
I’ll have the Sparc users try this and see if it helps them.

If not, then I’ve got a real head scratcher [*].

-bill!

[*] Which, knowing me, is some tiny stupid bug staring me straight in the face
;)On Sun, Aug 11, 2002 at 10:50:40AM -0700, Loren Osborn wrote:

Hmm… If you already have the r, g & b masks,
wouldn’t it be easiest to do:

amask = ~(img_brushes[cur_brush]->format->Rmask |
img_brushes[cur_brush]->format->Gmask |
img_brushes[cur_brush]->format->Bmask);