[SDL] SDL_BYTEORDER and amask

nbs nbs at sonic.net
Sun Aug 11 01:26:01 PDT 2002


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!





More information about the SDL mailing list