NGL  6.5
The NCCA Graphics Library
Colour.h
Go to the documentation of this file.
1 
17 #ifndef COLOUR_H_
18 #define COLOUR_H_
19 
22 // must include types.h first for Real and GLEW if required
23 #include "Types.h"
24 
25 //----------------------------------------------------------------------------------------------------------------------
26 namespace ngl
27 {
28 //----------------------------------------------------------------------------------------------------------------------
37 //----------------------------------------------------------------------------------------------------------------------
38 
39 
41 {
42 public :
43  //----------------------------------------------------------------------------------------------------------------------
49  //----------------------------------------------------------------------------------------------------------------------
50  Colour(Real _r=0.0, Real _g=0.0, Real _b=0.0, Real _a=1.0) noexcept:
51  m_r(_r), m_g(_g), m_b(_b), m_a(_a){;}
52 
53  //----------------------------------------------------------------------------------------------------------------------
56  //----------------------------------------------------------------------------------------------------------------------
57  Colour(const Colour &_c) noexcept:
58  m_r(_c.m_r),m_g(_c.m_g), m_b(_c.m_b),m_a(_c.m_a){;}
59 
60  //----------------------------------------------------------------------------------------------------------------------
67  //----------------------------------------------------------------------------------------------------------------------
68  void set( Real _r,Real _g, Real _b, Real _a=1.0f) noexcept
69  {
70  m_r=_r; m_g=_g; m_b=_b; m_a=_a;
71  }
72  //----------------------------------------------------------------------------------------------------------------------
75  //----------------------------------------------------------------------------------------------------------------------
76  void set(const Colour& _c) noexcept
77  {
78  m_r = _c.m_r; m_g = _c.m_g; m_b= _c.m_b; m_a=_c.m_a;
79  }
80 
81  //----------------------------------------------------------------------------------------------------------------------
85  //----------------------------------------------------------------------------------------------------------------------
86  Colour operator +(const Colour &_c) const noexcept;
87  //----------------------------------------------------------------------------------------------------------------------
91  //----------------------------------------------------------------------------------------------------------------------
92  Colour operator -(const Colour &_c) const noexcept;
93  //----------------------------------------------------------------------------------------------------------------------
97  //----------------------------------------------------------------------------------------------------------------------
98  const Colour& operator +=(const Colour &_c) noexcept;
99  //----------------------------------------------------------------------------------------------------------------------
103  //----------------------------------------------------------------------------------------------------------------------
104  Colour operator *(const Colour &_c) const noexcept;
105  //----------------------------------------------------------------------------------------------------------------------
109  //----------------------------------------------------------------------------------------------------------------------
110  Colour operator *(const Real _c) const noexcept;
111  //----------------------------------------------------------------------------------------------------------------------
115  //----------------------------------------------------------------------------------------------------------------------
116  const Colour& operator *=(const Colour &_c) noexcept;
117  //----------------------------------------------------------------------------------------------------------------------
121  //----------------------------------------------------------------------------------------------------------------------
122  const Colour& operator *=(Real _c) noexcept;
123  //----------------------------------------------------------------------------------------------------------------------
127  //----------------------------------------------------------------------------------------------------------------------
128  void add(const Colour& _src, const Colour& _refl) noexcept;
129  //----------------------------------------------------------------------------------------------------------------------
132  //----------------------------------------------------------------------------------------------------------------------
133  Real * openGL() noexcept{return &m_openGL[0];}
134  //----------------------------------------------------------------------------------------------------------------------
139  //----------------------------------------------------------------------------------------------------------------------
140  void clamp( Real _min, Real _max) noexcept;
141 
145 public :
146  friend class Material;
147  //----------------------------------------------------------------------------------------------------------------------
148  // note the BUILDING_DOCS define is set in the doxygen Doxyfile so that we get
149  // nice documents for these member attributes is must not be set in C++ build
150  //----------------------------------------------------------------------------------------------------------------------
151  #ifndef BUILDING_DOCS
152  union
153  {
154  struct
155  {
156  #endif
157  //----------------------------------------------------------------------------------------------------------------------
159  //----------------------------------------------------------------------------------------------------------------------
161  //----------------------------------------------------------------------------------------------------------------------
163  //----------------------------------------------------------------------------------------------------------------------
165  //----------------------------------------------------------------------------------------------------------------------
167  //----------------------------------------------------------------------------------------------------------------------
169  //----------------------------------------------------------------------------------------------------------------------
171  //----------------------------------------------------------------------------------------------------------------------
173  #ifndef BUILDING_DOCS
174  };
175  #endif
176  //----------------------------------------------------------------------------------------------------------------------
183  //----------------------------------------------------------------------------------------------------------------------
184  Real m_openGL[4];
185  #ifndef BUILDING_DOCS
186  };
187  #endif
188 
189 };
190 
191 }
192 #endif // colour
193 //----------------------------------------------------------------------------------------------------------------------
194 
simple class to hold colour information and set the basic opengl colour state. also has overloaded me...
Definition: Colour.h:40
Real m_r
red component of the colour tuple
Definition: Colour.h:160
main definition of types and namespace
Real m_b
blue component of the colour tuple
Definition: Colour.h:168
#define NGL_DLLEXPORT
Definition: Types.h:65
Colour(const Colour &_c) noexcept
copy constructor passing in a Colour
Definition: Colour.h:57
Real * openGL() noexcept
accesor method to return a pointer to the colour array
Definition: Colour.h:133
implementation files for RibExport class
Definition: AABB.cpp:22
GLenum clamp
Definition: glew.h:2169
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
Definition: Types.h:127
Real m_g
green component of the colour tuple
Definition: Colour.h:164
Vec2 operator*(Real _k, const Vec2 &_v) noexcept
scalar * vector operator
Definition: Vec2.h:286
Real m_a
alpha the transparent element
Definition: Colour.h:172
Colour(Real _r=0.0, Real _g=0.0, Real _b=0.0, Real _a=1.0) noexcept
constructor passing in r g b components
Definition: Colour.h:50