Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 5, 2006, 5:27:38 PM (18 years ago)
Author:
ponder
Message:

The md2Model loader now works as expected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/osx/src/lib/graphics/importer/texture.cc

    r8122 r8162  
    2222#include <math.h>
    2323
    24 // INCLUDING SDL_Image
    25 #ifdef HAVE_SDL_IMAGE_H
     24#ifdef HAVE_SDL_SDL_H
     25#include <SDL/SDL_image.h>
     26#include <SDL/SDL_endian.h>
     27#include <SDL/SDL_byteorder.h>
     28#else
     29#include <SDL_endian.h>
    2630#include <SDL_image.h>
     31#include <SDL_byteorder.h>
     32#endif
     33#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     34/*
     35 * On the BIG_ENDIAN architecture, the 24 and 32bit bitmaps have
     36 * different masks. If you don't do this distinction properly,
     37 * you will get weird-looking textures.
     38 */
     39Uint32 alphaMask[] = {
     40        0xFF000000,
     41        0x00FF0000,
     42        0x0000FF00,
     43        0x000000FF,
     44};
     45
     46Uint32 opaqueMask[] = {
     47        0x00FF0000,
     48        0x0000FF00,
     49        0x000000FF,
     50        0xFF000000
     51};
    2752#else
    28 #include <SDL/SDL_image.h>
     53/*
     54 * On the LIL_ENDIAN architecture everything is fine and easy. The 24
     55 * and 32bit bitmaps have the same masks.
     56 */
     57Uint32 alphaMask[] = {
     58        0x000000FF,
     59        0x0000FF00,
     60        0x00FF0000,
     61        0xFF000000,
     62};
     63
     64Uint32 opaqueMask[] = alphaMask
     65
    2966#endif
    30 
    3167/**
    3268 * @brief Constructor for a Texture
     
    190226  Uint32 saved_flags;
    191227  Uint8  saved_alpha;
    192 
    193228  hasAlpha = false;
    194229  int pixelDepth = 24;
    195230
     231        Uint32* mask = opaqueMask;
     232       
    196233  /* Save the alpha blending attributes */
    197234  saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK);
    198235  saved_alpha = surface->format->alpha;
    199   if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
     236  if ( saved_flags & SDL_SRCALPHA )
    200237  {
    201238    SDL_SetAlpha(surface, 0, 0);
    202239    hasAlpha = true;
    203240    pixelDepth = 32;
    204   }
    205 
     241                mask = alphaMask;
     242  }
     243               
    206244  retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE,
    207245                                    surface->w, surface->h,
    208246                                    pixelDepth,
    209 //#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    210                                     0x000000FF,
    211                                     0x0000FF00,
    212                                     0x00FF0000,
    213                                     0xFF000000
    214 /*#else*/
    215                                     /*0xFF000000,
    216                                     0x00FF0000,
    217                                     0x0000FF00,
    218                                     0x000000FF*/
    219 /*#endif*/
    220                                    );
     247                                                                                                                                                mask[0], mask[1], mask[2], mask[3] );
    221248  if ( retSurface == NULL )
    222249    return NULL;
Note: See TracChangeset for help on using the changeset viewer.