PICCANTE  0.4
The hottest HDR imaging library!
color_conv_rgb_to_xyz.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP
19 #define PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP
20 
21 #include "../../colors/color_conv_rgb_to_xyz.hpp"
22 
23 #include "../../gl/colors/color_conv.hpp"
24 
25 namespace pic {
26 
31 {
32 public:
33 
38  {
39  }
40 
45  std::string getDirectFunction()
46  {
47  std::string fragment_source = MAKE_STRING
48  (
49  uniform sampler2D u_tex; \n
50  uniform mat3 mtx; \n
51  out vec4 f_color; \n
52  \n
53  void main(void) {
54  \n
55  ivec2 coords = ivec2(gl_FragCoord.xy); \n
56  vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \n
57  vec3 colOut = mtx * colIn;
58  f_color = vec4(colOut, 1.0); \n
59  \n
60  }
61  );
62  return fragment_source;
63  }
64 
69  std::string getInverseFunction()
70  {
71  return getDirectFunction();
72  }
73 
77  void setUniforms()
78  {
79  if(direct) {
80  techniques[0].bind();
81  techniques[0].setUniform3x3("mtx", mtxRGBtoXYZ, true);
82  techniques[0].unbind();
83  } else {
84  techniques[1].bind();
85  techniques[1].setUniform3x3("mtx", mtxXYZtoRGB, true);
86  techniques[1].unbind();
87  }
88  }
89 
90 };
91 
92 } // end namespace pic
93 
94 #endif /* PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP */
95 
std::string getDirectFunction()
getDirectFunction
Definition: color_conv_rgb_to_xyz.hpp:45
void bind()
bind
Definition: display.hpp:189
#define MAKE_STRING(input_string)
std::string getInverseFunction()
getInverseFunction
Definition: color_conv_rgb_to_xyz.hpp:69
const float mtxRGBtoXYZ[]
Definition: color_conv_rgb_to_xyz.hpp:25
ColorConvGLRGBtoXYZ(bool direct=true)
ColorConvGLRGBtoXYZ.
Definition: color_conv_rgb_to_xyz.hpp:37
TechniqueGL techniques[2]
Definition: display.hpp:34
The ColorConvGLRGBtoXYZ class.
Definition: color_conv_rgb_to_xyz.hpp:30
const float mtxXYZtoRGB[]
Definition: color_conv_rgb_to_xyz.hpp:30
The ColorConvGL class.
Definition: color_conv.hpp:30
int direct
Definition: display.hpp:33
void unbind()
unbind
Definition: display.hpp:197
Definition: bilateral_separation.hpp:25
void setUniforms()
setUniforms
Definition: color_conv_rgb_to_xyz.hpp:77
void setUniform3x3(const char *name_uniform, const float *matrix, bool bTranspose)
setUniform3x3
Definition: display.hpp:304