wglgears: add srgb-mode to usage
[mesa-demos.git] / src / wgl / rtotex / maths / color.cpp
blobf3dca98eec6b7732b1779bb307210942a528da39
1 //////////////////////////////////////////////////////////////////////////////////////////
2 // COLOR.cpp
3 // function definitions for an RGBA color class
4 // Downloaded from: www.paulsprojects.net
5 // Created: 20th July 2002
6 // Modified: 7th November 2002 - Some speed improvements
7 // - Removed clamping after adds etc. Do it yourself!
8 // To enable use with floating point color buffers
9 // - Corrected lerp (reversed f and 1-f)
11 // Copyright (c) 2006, Paul Baker
12 // Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
13 // http://www.paulsprojects.net/NewBSDLicense.txt)
14 //////////////////////////////////////////////////////////////////////////////////////////
16 #include "maths.h"
18 void COLOR::ClampTo01()
20 if(r>1.0f)
21 r=1.0f;
22 if(r<0.0f)
23 r=0.0f;
25 if(g>1.0f)
26 g=1.0f;
27 if(g<0.0f)
28 g=0.0f;
30 if(b>1.0f)
31 b=1.0f;
32 if(b<0.0f)
33 b=0.0f;
35 if(a>1.0f)
36 a=1.0f;
37 if(a<0.0f)
38 a=0.0f;
41 COLOR operator*(float scaleFactor, const COLOR & rhs)
43 return rhs*scaleFactor;
46 bool COLOR::operator ==(const COLOR & rhs) const
48 if(r != rhs.r)
49 return false;
50 if(g != rhs.g)
51 return false;
52 if(b != rhs.b)
53 return false;
54 if(a != rhs.a)
55 return false;
57 return true;