comparison Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp @ 914:4d1f57773b5b

Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 19 Jul 2019 10:54:03 +0200
parents ed783cbc92d7
children 1091b2adeb5a
comparison
equal deleted inserted replaced
913:2b4b6b86520a 914:4d1f57773b5b
31 ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE 31 ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE
32 "uniform float u_offset; \n" 32 "uniform float u_offset; \n"
33 "uniform float u_slope; \n" 33 "uniform float u_slope; \n"
34 "uniform float u_windowCenter; \n" 34 "uniform float u_windowCenter; \n"
35 "uniform float u_windowWidth; \n" 35 "uniform float u_windowWidth; \n"
36 "uniform bool u_invert; \n"
36 "uniform sampler2D u_texture; \n" 37 "uniform sampler2D u_texture; \n"
37 "varying vec2 v_texcoord; \n" 38 "varying vec2 v_texcoord; \n"
38 "void main() \n" 39 "void main() \n"
39 "{ \n" 40 "{ \n"
40 " vec4 t = texture2D(u_texture, v_texcoord); \n" 41 " vec4 t = texture2D(u_texture, v_texcoord); \n"
48 " { \n" 49 " { \n"
49 " v = (v - a) * dy; \n" 50 " v = (v - a) * dy; \n"
50 " if (v >= 1.0) \n" 51 " if (v >= 1.0) \n"
51 " v = 1.0; \n" 52 " v = 1.0; \n"
52 " } \n" 53 " } \n"
54 " if (u_invert) \n"
55 " v = 1.0 - v; \n"
53 " gl_FragColor = vec4(v, v, v, 1); \n" 56 " gl_FragColor = vec4(v, v, v, 1); \n"
54 "}"; 57 "}";
55 58
56 59
57 namespace OrthancStone 60 namespace OrthancStone
131 134
132 135
133 void OpenGLFloatTextureProgram::Apply(Data& data, 136 void OpenGLFloatTextureProgram::Apply(Data& data,
134 const AffineTransform2D& transform, 137 const AffineTransform2D& transform,
135 float windowCenter, 138 float windowCenter,
136 float windowWidth) 139 float windowWidth,
140 bool invert)
137 { 141 {
138 OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform); 142 OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform);
139 143
140 glUniform1f(execution.GetUniformLocation("u_slope"), data.GetSlope()); 144 glUniform1f(execution.GetUniformLocation("u_slope"), data.GetSlope());
141 glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset()); 145 glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset());
142 glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter); 146 glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter);
143 glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth); 147 glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth);
148 glUniform1f(execution.GetUniformLocation("u_invert"), invert);
144 149
145 execution.DrawTriangles(); 150 execution.DrawTriangles();
146 } 151 }
147 } 152 }
148 } 153 }