Changeset 8162 in orxonox.OLD for branches/osx/src/lib/graphics/importer/texture.cc
- Timestamp:
- Jun 5, 2006, 5:27:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/osx/src/lib/graphics/importer/texture.cc
r8122 r8162 22 22 #include <math.h> 23 23 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> 26 30 #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 */ 39 Uint32 alphaMask[] = { 40 0xFF000000, 41 0x00FF0000, 42 0x0000FF00, 43 0x000000FF, 44 }; 45 46 Uint32 opaqueMask[] = { 47 0x00FF0000, 48 0x0000FF00, 49 0x000000FF, 50 0xFF000000 51 }; 27 52 #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 */ 57 Uint32 alphaMask[] = { 58 0x000000FF, 59 0x0000FF00, 60 0x00FF0000, 61 0xFF000000, 62 }; 63 64 Uint32 opaqueMask[] = alphaMask 65 29 66 #endif 30 31 67 /** 32 68 * @brief Constructor for a Texture … … 190 226 Uint32 saved_flags; 191 227 Uint8 saved_alpha; 192 193 228 hasAlpha = false; 194 229 int pixelDepth = 24; 195 230 231 Uint32* mask = opaqueMask; 232 196 233 /* Save the alpha blending attributes */ 197 234 saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK); 198 235 saved_alpha = surface->format->alpha; 199 if ( (saved_flags & SDL_SRCALPHA) ==SDL_SRCALPHA )236 if ( saved_flags & SDL_SRCALPHA ) 200 237 { 201 238 SDL_SetAlpha(surface, 0, 0); 202 239 hasAlpha = true; 203 240 pixelDepth = 32; 204 } 205 241 mask = alphaMask; 242 } 243 206 244 retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 207 245 surface->w, surface->h, 208 246 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] ); 221 248 if ( retSurface == NULL ) 222 249 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.