diff -Naur Irrlicht.old/include/SColor.h Irrlicht/include/SColor.h --- Irrlicht.old/include/SColor.h 2005-03-01 14:43:46.684337313 +0100 +++ Irrlicht/include/SColor.h 2005-03-11 10:41:15.000000000 +0100 @@ -14,16 +14,13 @@ //! Creates a 16 bit A1R5G5B5 color inline s16 RGB16(s32 r, s32 g, s32 b) { - return (((r>>3) & 0x1F)<<10) | (((g>>3) & 0x1F)<<5) | ((b>>3) & 0x1F); + return ((r & 0xF8)<<7) | ((g & 0xF8)<<2) | ((b & 0xF8)>>3); } //! Creates a 16 bit A1R5G5B5 color inline s16 RGBA16(s32 r, s32 g, s32 b, s32 a) { - return (((a>>7) & 0x1)<<15) | - (((r>>3) & 0x1F)<<10) | - (((g>>3) & 0x1F)<<5) | - ((b>>3) & 0x1F); + return (((a & (0x1<<7))<<8) | RGB16(r,g,b)); } //! Converts a 32 bit (X8R8G8B8) color to a 16 A1R5G5B5 color @@ -68,18 +65,24 @@ } + //! Returns R5G6B5 Color from A1R5G5B5 color + inline s32 A1R5G5B5toR5G6B5(s16 color) + { + return ((color &0x1F) | ((color << 1)&0xFFC0)); + } + //! Returns A8R8G8B8 Color from A1R5G5B5 color inline s32 A1R5G5B5toA8R8G8B8(s16 color) { - return (((color >> 15)&0x1)<<31) | (((color >> 10)&0x1F)<<19) | - (((color >> 5)&0x1F)<<11) | (color&0x1F)<<3; + return (((color &(0x1<<15))<<16) | ((color &(0x1F<<10))<<9) | + ((color &(0x1F<<5))<<6) | (color&0x1F)<<3); } //! Returns A8R8G8B8 Color from R5G6B5 color inline s32 R5G6B5toA8R8G8B8(s16 color) { - return 0xFF000000 & ((((color >> 11)&0x1F)<<19) | - (((color >> 5)&0x3F)<<11) | (color&0x1F)<<3); + return 0xFF000000 & (((color &(0x1F<<11))<<8) | + ((color &(0x3F<<5))<<6) | (color&0x1F)<<3); } @@ -127,26 +130,26 @@ //! 0 means dark, 255 means full blue. inline s32 getBlue() const { return color & 0xff; } - //! Sets the alpha comonent of the Color. The alpha component + //! Sets the alpha component of the Color. The alpha component //! defines how transparent a color should be. //! \param a: Has to be a value between 0 and 255. //! 0 means not transparent, 255 means fully transparent. - inline void setAlpha(s32 a) { color = ((a & 0xff)<<24) | (((color>>16)& 0xff)<<16) | ((color>>8 & 0xff)<<8) | (color & 0xff); } + inline void setAlpha(s32 a) { color = ((a & 0xff)<<24) | (color& (0xff<<16)) | (color & (0xff<<8)) | (color & 0xff); } - //! Sets the red comonent of the Color. + //! Sets the red component of the Color. //! \param r: Has to be a value between 0 and 255. //! 0 means dark red (=black), 255 means full red. - inline void setRed(s32 r) { color = (((color>>24) & 0xff)<<24) | ((r & 0xff)<<16) | ((color>>8 & 0xff)<<8) | (color & 0xff); } + inline void setRed(s32 r) { color = ((color & (0xff<<24)) | ((r & 0xff)<<16) | (color & (0xff<<8)) | (color & 0xff)); } - //! Sets the green comonent of the Color. + //! Sets the green component of the Color. //! \param g: Has to be a value between 0 and 255. //! 0 means dark green (=black), 255 means full green. - inline void setGreen(s32 g) { color = (((color>>24) & 0xff)<<24) | (((color>>16)& 0xff)<<16) | ((g & 0xff)<<8) | (color & 0xff); } + inline void setGreen(s32 g) { color = ((color & (0xff<<24)) | (color & (0xff<<16)) | ((g & 0xff)<<8) | (color & 0xff)); } - //! Sets the blue comonent of the Color. + //! Sets the blue component of the Color. //! \param b: Has to be a value between 0 and 255. //! 0 means dark blue (=black), 255 means full blue. - inline void setBlue(s32 b) { color = (((color>>24) & 0xff)<<24) | (((color>>16)& 0xff)<<16) | ((color>>8 & 0xff)<<8) | (b & 0xff); } + inline void setBlue(s32 b) { color = ((color & (0xff<<24)) | (color & (0xff<<16)) | (color & (0xff<<8)) | (b & 0xff)); } //! Calculates a 16 bit A1R5G5B5 value of this color. //! \return Returns the 16 bit A1R5G5B5 value of this color. @@ -156,10 +159,10 @@ //! \return Returns the 32 bit openGL color value. inline s32 toOpenGLColor() const { - return (((color>>24) & 0xff)<<24) | - (((color)& 0xff)<<16) | - ((color>>8 & 0xff)<<8) | - ((color>>16) & 0xff); + return ((color & 0xff000000) | + ((color& 0xff)<<16) | + (color & 0x0000ff00) | + ((color>>16) & 0xff)); }; //! Sets all four components of the color at once.