OGLplus (0.52.0) a C++ wrapper for OpenGL

texture_swizzle.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_TEXTURE_SWIZZLE_1107121519_HPP
14 #define OGLPLUS_TEXTURE_SWIZZLE_1107121519_HPP
15 
16 #include <oglplus/fwd.hpp>
17 #include <oglplus/enumerations.hpp>
18 
19 namespace oglplus {
20 
22 
29 OGLPLUS_ENUM_CLASS_BEGIN(TextureSwizzleCoord, GLenum)
30 #include <oglplus/enums/texture_swizzle_coord.ipp>
31 OGLPLUS_ENUM_CLASS_END(TextureSwizzleCoord)
32 
33 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
34 #include <oglplus/enums/texture_swizzle_coord_names.ipp>
35 #endif
36 
37 #if !OGLPLUS_ENUM_VALUE_RANGES
38 #include <oglplus/enums/texture_swizzle_coord_range.ipp>
39 #endif
40 
42 
53 OGLPLUS_ENUM_CLASS_BEGIN(TextureSwizzle, GLenum)
54 #include <oglplus/enums/texture_swizzle.ipp>
55 OGLPLUS_ENUM_CLASS_END(TextureSwizzle)
56 
57 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
58 #include <oglplus/enums/texture_swizzle_names.ipp>
59 #endif
60 
61 #if !OGLPLUS_ENUM_VALUE_RANGES
62 #include <oglplus/enums/texture_swizzle_range.ipp>
63 #endif
64 
65 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_3 || GL_ARB_texture_swizzle
68 {
69 private:
70  GLint _values[4];
71 public:
72  const GLint* Values(void) const
73  {
74  return _values;
75  }
76 
77  GLint* Values(void)
78  {
79  return _values;
80  }
81 
84  {
85  _values[0] = GL_RED;
86  _values[1] = GL_GREEN;
87  _values[2] = GL_BLUE;
88  _values[3] = GL_ALPHA;
89  }
90 
93  TextureSwizzle mode_r,
94  TextureSwizzle mode_g,
95  TextureSwizzle mode_b,
96  TextureSwizzle mode_a
97  )
98  {
99  _values[0] = GLint(GLenum(mode_r));
100  _values[1] = GLint(GLenum(mode_g));
101  _values[2] = GLint(GLenum(mode_b));
102  _values[3] = GLint(GLenum(mode_a));
103  }
104 
107  {
108  _values[0] = GLint(GLenum(mode));
109  return *this;
110  }
111 
114  {
115  return TextureSwizzle(_values[0]);
116  }
117 
120  {
121  return SwizzleR(mode);
122  }
123 
125  TextureSwizzle Red(void) const
126  {
127  return SwizzleR();
128  }
129 
132  {
133  _values[1] = GLint(GLenum(mode));
134  return *this;
135  }
136 
139  {
140  return TextureSwizzle(_values[1]);
141  }
142 
145  {
146  return SwizzleG(mode);
147  }
148 
150  TextureSwizzle Green(void) const
151  {
152  return SwizzleG();
153  }
154 
157  {
158  _values[2] = GLint(GLenum(mode));
159  return *this;
160  }
161 
164  {
165  return TextureSwizzle(_values[2]);
166  }
167 
170  {
171  return SwizzleB(mode);
172  }
173 
175  TextureSwizzle Blue(void) const
176  {
177  return SwizzleB();
178  }
179 
182  {
183  _values[3] = GLint(GLenum(mode));
184  return *this;
185  }
186 
189  {
190  return TextureSwizzle(_values[3]);
191  }
192 
195  {
196  return SwizzleA(mode);
197  }
198 
200  TextureSwizzle Alpha(void) const
201  {
202  return SwizzleA();
203  }
204 
207  TextureSwizzleCoord coord,
208  TextureSwizzle mode
209  )
210  {
211  switch(GLenum(coord))
212  {
213  case GL_TEXTURE_SWIZZLE_R:
214  SwizzleR(mode);
215  break;
216  case GL_TEXTURE_SWIZZLE_G:
217  SwizzleG(mode);
218  break;
219  case GL_TEXTURE_SWIZZLE_B:
220  SwizzleB(mode);
221  break;
222  case GL_TEXTURE_SWIZZLE_A:
223  SwizzleA(mode);
224  break;
225  }
226  return *this;
227  }
228 
231  {
232  switch(GLenum(coord))
233  {
234  case GL_TEXTURE_SWIZZLE_R:
235  return SwizzleR();
236  case GL_TEXTURE_SWIZZLE_G:
237  return SwizzleG();
238  case GL_TEXTURE_SWIZZLE_B:
239  return SwizzleB();
240  case GL_TEXTURE_SWIZZLE_A:
241  return SwizzleA();
242  }
243  return TextureSwizzle();
244  }
245 };
246 #endif
247 
248 } // namespace oglplus
249 
250 #endif // include guard
TextureSwizzleTuple & Green(TextureSwizzle mode)
Synonym for SwizzleG.
Definition: texture_swizzle.hpp:144
TextureSwizzleTuple & SwizzleR(TextureSwizzle mode)
Sets the swizzle value for red component.
Definition: texture_swizzle.hpp:106
TextureSwizzle
Texture swizzle enumeration.
Definition: texture_swizzle.hpp:53
TextureSwizzleTuple & SwizzleG(TextureSwizzle mode)
Sets the swizzle value for green component.
Definition: texture_swizzle.hpp:131
TextureSwizzle Alpha(void) const
Synonym for SwizzleA.
Definition: texture_swizzle.hpp:200
TextureSwizzleTuple & Alpha(TextureSwizzle mode)
Synonym for SwizzleA.
Definition: texture_swizzle.hpp:194
TextureSwizzle Red(void) const
Synonym for SwizzleR.
Definition: texture_swizzle.hpp:125
TextureSwizzle SwizzleR(void) const
Returns the swizzle value for red component.
Definition: texture_swizzle.hpp:113
Forward declarations.
Enumeration-related declarations.
TextureSwizzle SwizzleB(void) const
Returns the swizzle value for blue component.
Definition: texture_swizzle.hpp:163
A tuple of swizzle values for all texture components.
Definition: texture_swizzle.hpp:67
TextureSwizzleTuple & Swizzle(TextureSwizzleCoord coord, TextureSwizzle mode)
Sets the swizzle value for the specified component/coord.
Definition: texture_swizzle.hpp:206
TextureSwizzleTuple & Blue(TextureSwizzle mode)
Synonym for SwizzleB.
Definition: texture_swizzle.hpp:169
TextureSwizzleTuple & SwizzleB(TextureSwizzle mode)
Sets the swizzle value for blue component.
Definition: texture_swizzle.hpp:156
TextureSwizzleTuple(TextureSwizzle mode_r, TextureSwizzle mode_g, TextureSwizzle mode_b, TextureSwizzle mode_a)
Specifies modes for all components/coords.
Definition: texture_swizzle.hpp:92
TextureSwizzleTuple(void)
Default construction.
Definition: texture_swizzle.hpp:83
TextureSwizzle Green(void) const
Synonym for SwizzleG.
Definition: texture_swizzle.hpp:150
TextureSwizzleTuple & Red(TextureSwizzle mode)
Synonym for SwizzleR.
Definition: texture_swizzle.hpp:119
TextureSwizzle Blue(void) const
Synonym for SwizzleB.
Definition: texture_swizzle.hpp:175
TextureSwizzleCoord
Texture swizzle parameter coordinate enumeration.
Definition: texture_swizzle.hpp:29
TextureSwizzle SwizzleA(void) const
Returns the swizzle value for alpha component.
Definition: texture_swizzle.hpp:188
TextureSwizzleTuple & SwizzleA(TextureSwizzle mode)
Sets the swizzle value for alpha component.
Definition: texture_swizzle.hpp:181
TextureSwizzle SwizzleG(void) const
Returns the swizzle value for green component.
Definition: texture_swizzle.hpp:138
TextureSwizzle Swizzle(TextureSwizzleCoord coord) const
Returns the swizzle value for the specified component/coord.
Definition: texture_swizzle.hpp:230

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).