annotate OrthancStone/Sources/Scene2D/Internals/OpenGLFloatTextureProgram.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp@30deba7bc8e2
children 85e117739eca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 947
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "OpenGLFloatTextureProgram.h"
611
e3f21a265be5 Added version directive to GLSL shader code + glew init function in sample code
Benjamin Golinvaux <bgo@osimis.io>
parents: 592
diff changeset
23 #include "OpenGLShaderVersionDirective.h"
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
25 #include <OrthancException.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
26 #include <Images/Image.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
27 #include <Images/ImageProcessing.h>
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 static const char* FRAGMENT_SHADER =
611
e3f21a265be5 Added version directive to GLSL shader code + glew init function in sample code
Benjamin Golinvaux <bgo@osimis.io>
parents: 592
diff changeset
31 ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE
771
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
32 "uniform float u_offset; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
33 "uniform float u_slope; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
34 "uniform float u_windowCenter; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
35 "uniform float u_windowWidth; \n"
914
4d1f57773b5b Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents: 771
diff changeset
36 "uniform bool u_invert; \n"
771
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
37 "uniform sampler2D u_texture; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
38 "varying vec2 v_texcoord; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
39 "void main() \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
40 "{ \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
41 " vec4 t = texture2D(u_texture, v_texcoord); \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
42 " float v = (t.r * 256.0 + t.g) * 256.0; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
43 " v = v * u_slope + u_offset; \n" // (*)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
44 " float a = u_windowCenter - u_windowWidth / 2.0; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
45 " float dy = 1.0 / u_windowWidth; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
46 " if (v <= a) \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
47 " v = 0.0; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
48 " else \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
49 " { \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
50 " v = (v - a) * dy; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
51 " if (v >= 1.0) \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
52 " v = 1.0; \n"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
53 " } \n"
914
4d1f57773b5b Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents: 771
diff changeset
54 " if (u_invert) \n"
4d1f57773b5b Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents: 771
diff changeset
55 " v = 1.0 - v; \n"
771
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 770
diff changeset
56 " gl_FragColor = vec4(v, v, v, 1); \n"
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 "}";
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 namespace OrthancStone
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 namespace Internals
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
64 OpenGLFloatTextureProgram::Data::Data(
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
65 OpenGL::IOpenGLContext& context
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
66 , const Orthanc::ImageAccessor& texture
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
67 , bool isLinearInterpolation)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
68 : texture_(context)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
69 , offset_(0.0f)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
70 , slope_(0.0f)
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 if (texture.GetFormat() != Orthanc::PixelFormat_Float32)
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 float minValue, maxValue;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, texture);
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 offset_ = minValue;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (LinearAlgebra::IsCloseToZero(maxValue - minValue))
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 slope_ = 1;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 else
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 slope_ = (maxValue - minValue) / 65536.0f;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 assert(!LinearAlgebra::IsCloseToZero(slope_));
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 const unsigned int width = texture.GetWidth();
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 const unsigned int height = texture.GetHeight();
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 Orthanc::Image converted(Orthanc::PixelFormat_RGB24, width, height, true);
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 for (unsigned int y = 0; y < height; y++)
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 const float *p = reinterpret_cast<const float*>(texture.GetConstRow(y));
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 uint8_t *q = reinterpret_cast<uint8_t*>(converted.GetRow(y));
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 for (unsigned int x = 0; x < width; x++)
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 /**
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 * At (*), the floating-point "value" is reconstructed as
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 * "value = texture * slope + offset".
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 * <=> texture = (value - offset) / slope
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 **/
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 float texture = (*p - offset_) / slope_;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 if (texture < 0)
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 texture = 0;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 else if (texture >= 65535.0f)
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 texture = 65535.0f;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 uint16_t t = static_cast<uint16_t>(texture);
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 q[0] = t / 256; // red
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 q[1] = t % 256; // green
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 q[2] = 0; // blue is unused
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 p++;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 q += 3;
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 texture_.Load(converted, isLinearInterpolation);
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
135 OpenGLFloatTextureProgram::OpenGLFloatTextureProgram(OpenGL::IOpenGLContext& context)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
136 : program_(context, FRAGMENT_SHADER)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
137 , context_(context)
592
bbe29efd3d1c OpenGLLinesProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 591
diff changeset
138 {
bbe29efd3d1c OpenGLLinesProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 591
diff changeset
139 }
bbe29efd3d1c OpenGLLinesProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 591
diff changeset
140
bbe29efd3d1c OpenGLLinesProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 591
diff changeset
141
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 void OpenGLFloatTextureProgram::Apply(Data& data,
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 const AffineTransform2D& transform,
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 float windowCenter,
914
4d1f57773b5b Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents: 771
diff changeset
145 float windowWidth,
4d1f57773b5b Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents: 771
diff changeset
146 bool invert)
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
148 if (!context_.IsContextLost())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
149 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
150 OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform);
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
152 glUniform1f(execution.GetUniformLocation("u_slope"), data.GetSlope());
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
153 glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset());
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
154 glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
155 glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
156 glUniform1f(execution.GetUniformLocation("u_invert"), invert);
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
158 execution.DrawTriangles();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 914
diff changeset
159 }
591
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
b66ced2c43d4 OpenGLTextureProgram
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }