Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

glt/color.h

Go to the documentation of this file.
00001 #ifndef GLT_COLOR_H
00002 #define GLT_COLOR_H
00003 
00004 /*
00005 
00006   GLT OpenGL C++ Toolkit      
00007   Copyright (C) 2000-2002 Nigel Stewart
00008   Email: nigels.com@gmail.com   WWW: http://www.nigels.com/glt/
00009 
00010   This library is free software; you can redistribute it and/or
00011   modify it under the terms of the GNU Lesser General Public
00012   License as published by the Free Software Foundation; either
00013   version 2.1 of the License, or (at your option) any later version.
00014 
00015   This library is distributed in the hope that it will be useful,
00016   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018   Lesser General Public License for more details.
00019 
00020   You should have received a copy of the GNU Lesser General Public
00021   License along with this library; if not, write to the Free Software
00022   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 
00024 */
00025 
00039 #include <glt/config.h>
00040 #include <glt/gl.h>
00041 
00042 #include <string>
00043 
00044 #include <math/vector3.h>
00045 
00054 class GltColor : public Vector
00055 {
00056 public:
00057     //
00058     // Constructors
00059     //
00060 
00062     GltColor();
00064     GltColor(const float  red,const float  green,const float  blue,const float  alpha = 1.0);
00066     GltColor(const double red,const double green,const double blue,const double alpha = 1.0);
00068     GltColor(const int    red,const int    green,const int    blue,const int    alpha = 1);
00070     GltColor(const GltColor &col);
00072     GltColor(const GltColor &col,const real alpha);
00074     GltColor(const Vector &col);
00076     GltColor(const std::string &name);
00077 
00079     ~GltColor();
00080 
00082     GltColor &operator=(const GltColor &);
00083 
00084     //
00085     // OpenGL convenience functions
00086     //
00087 
00089     void glColor() const;
00090 
00092     void glColor(const GLdouble alpha)  const;
00093 
00095     void glClearColor() const;
00096 
00098     void glFogColor() const;
00099 
00101     void glMaterial(const GLenum face,const GLenum field) const;
00102 
00104     void glGetMaterial(const GLenum face,const GLenum field);
00105 
00107     void glLight(const GLenum light,const GLenum field) const;
00108 
00110     void glGetLight(const GLenum light,const GLenum field);
00111 
00112     //
00113     // Access
00114     //
00115 
00117     real &red();
00119     real &green();
00121     real &blue();
00123     real &alpha();
00124 
00126     const real &red()    const;
00128     const real &green()  const;
00130     const real &blue()   const;
00132     const real &alpha()  const;
00133 
00134     //
00135     // Misc
00136     //
00137 
00139     const real brightness() const;
00140 
00142     void toHSV(real &h,real &s,real &v) const;
00143 
00145     void fromHSV(const real h,const real s,const real v);
00146 
00147 #if 0
00148 
00149     void toCIE(Vector &XYZ) const;
00150 #endif
00151 
00153     const bool isGrey() const;
00154 
00156     std::string html() const;
00157 
00159     bool operator< (const GltColor &c) const;
00161     bool operator> (const GltColor &c) const;
00163     bool operator==(const GltColor &c) const;
00164 
00165     //
00166     // Binary operators
00167     //
00168 
00169     friend GltColor operator*(const GltColor  &c, const real x);
00170     friend GltColor operator/(const GltColor  &c, const real x);
00171     friend GltColor operator*(const real       x, const GltColor &c);
00172     friend GltColor operator+(const GltColor &c1, const GltColor &c2);
00173     friend GltColor operator-(const GltColor &c1, const GltColor &c2);
00174 
00175 private:
00176     real _alpha;
00177 
00178     static const int       _rgbSize;
00179     static const char     *_rgbName [];
00180     static const GltColor *_rgbValue[];
00181 };
00182 
00184 
00190 class GltClearColor : public GltColor
00191 {
00192 public:
00193     //
00194     // Constructor/Destructor
00195     //
00196 
00198     GltClearColor(bool getIt = false);
00200     ~GltClearColor();
00201 
00202     //
00203     // Get/Set
00204     //
00205 
00207     void get();
00209     void set() const;
00211     void set(const GltColor &col);
00212 };
00213 
00214 #endif

Generated on Tue Nov 5 11:11:03 2002 for GLT by doxygen1.2.18