00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreStableHeaders.h" 00026 #include "OgreColourValue.h" 00027 00028 namespace Ogre { 00029 00030 ColourValue ColourValue::Black = ColourValue(0.0,0.0,0.0); 00031 ColourValue ColourValue::White = ColourValue(1.0,1.0,1.0); 00032 ColourValue ColourValue::Red = ColourValue(1.0,0.0,0.0); 00033 ColourValue ColourValue::Green = ColourValue(0.0,1.0,0.0); 00034 ColourValue ColourValue::Blue = ColourValue(0.0,0.0,1.0); 00035 00036 //--------------------------------------------------------------------- 00037 unsigned long ColourValue::getAsLongRGBA(void) const 00038 { 00039 unsigned char val8; 00040 unsigned long val32 = 0; 00041 00042 // Convert to 32bit pattern 00043 // (RGBA = 8888) 00044 00045 // Red 00046 val8 = (unsigned char)(r * 255); 00047 val32 = val8 << 24; 00048 00049 // Green 00050 val8 = (unsigned char)(g * 255); 00051 val32 += val8 << 16; 00052 00053 // Blue 00054 val8 = (unsigned char)(b * 255); 00055 val32 += val8 << 8; 00056 00057 // Alpha 00058 val8 = (unsigned char)(a * 255); 00059 val32 += val8; 00060 00061 return val32; 00062 } 00063 //--------------------------------------------------------------------- 00064 unsigned long ColourValue::getAsLongARGB(void) const 00065 { 00066 unsigned char val8; 00067 unsigned long val32 = 0; 00068 00069 // Convert to 32bit pattern 00070 // (ARGB = 8888) 00071 00072 // Alpha 00073 val8 = (unsigned char)(a * 255); 00074 val32 = val8 << 24; 00075 00076 // Red 00077 val8 = (unsigned char)(r * 255); 00078 val32 += val8 << 16; 00079 00080 // Green 00081 val8 = (unsigned char)(g * 255); 00082 val32 += val8 << 8; 00083 00084 // Blue 00085 val8 = (unsigned char)(b * 255); 00086 val32 += val8; 00087 00088 00089 return val32; 00090 } 00091 //--------------------------------------------------------------------- 00092 ABGR ColourValue::getAsLongABGR(void) const 00093 { 00094 unsigned char val8; 00095 unsigned long val32 = 0; 00096 00097 // Convert to 32bit pattern 00098 // (ABRG = 8888) 00099 00100 // Alpha 00101 val8 = (unsigned char)(a * 255); 00102 val32 = val8 << 24; 00103 00104 // Blue 00105 val8 = (unsigned char)(b * 255); 00106 val32 += val8 << 16; 00107 00108 // Green 00109 val8 = (unsigned char)(g * 255); 00110 val32 += val8 << 8; 00111 00112 // Red 00113 val8 = (unsigned char)(r * 255); 00114 val32 += val8; 00115 00116 00117 return val32; 00118 } 00119 //--------------------------------------------------------------------- 00120 bool ColourValue::operator==(const ColourValue& rhs) const 00121 { 00122 return (r == rhs.r && 00123 g == rhs.g && 00124 b == rhs.b && 00125 a == rhs.a); 00126 } 00127 //--------------------------------------------------------------------- 00128 bool ColourValue::operator!=(const ColourValue& rhs) const 00129 { 00130 return !(*this == rhs); 00131 } 00132 00133 } 00134
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:05 2004