comparison Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp @ 947:1091b2adeb5a toa2019081001

Fixed animation frame stopping when returning false + big work on the OpenGL objects to make them lost context-safe + debug code to forcefully tag a context as lost + debug macros
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:07:31 +0200
parents 4d1f57773b5b
children 2d8ab34c8c91
comparison
equal deleted inserted replaced
946:dbe3e1e47019 947:1091b2adeb5a
59 59
60 namespace OrthancStone 60 namespace OrthancStone
61 { 61 {
62 namespace Internals 62 namespace Internals
63 { 63 {
64 OpenGLFloatTextureProgram::Data::Data(const Orthanc::ImageAccessor& texture, 64 OpenGLFloatTextureProgram::Data::Data(
65 bool isLinearInterpolation) 65 OpenGL::IOpenGLContext& context
66 , const Orthanc::ImageAccessor& texture
67 , bool isLinearInterpolation)
68 : texture_(context)
69 , offset_(0.0f)
70 , slope_(0.0f)
66 { 71 {
67 if (texture.GetFormat() != Orthanc::PixelFormat_Float32) 72 if (texture.GetFormat() != Orthanc::PixelFormat_Float32)
68 { 73 {
69 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); 74 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
70 } 75 }
125 130
126 texture_.Load(converted, isLinearInterpolation); 131 texture_.Load(converted, isLinearInterpolation);
127 } 132 }
128 133
129 134
130 OpenGLFloatTextureProgram::OpenGLFloatTextureProgram(OpenGL::IOpenGLContext& context) : 135 OpenGLFloatTextureProgram::OpenGLFloatTextureProgram(OpenGL::IOpenGLContext& context)
131 program_(context, FRAGMENT_SHADER) 136 : program_(context, FRAGMENT_SHADER)
137 , context_(context)
132 { 138 {
133 } 139 }
134 140
135 141
136 void OpenGLFloatTextureProgram::Apply(Data& data, 142 void OpenGLFloatTextureProgram::Apply(Data& data,
137 const AffineTransform2D& transform, 143 const AffineTransform2D& transform,
138 float windowCenter, 144 float windowCenter,
139 float windowWidth, 145 float windowWidth,
140 bool invert) 146 bool invert)
141 { 147 {
142 OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform); 148 if (!context_.IsContextLost())
149 {
150 OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform);
143 151
144 glUniform1f(execution.GetUniformLocation("u_slope"), data.GetSlope()); 152 glUniform1f(execution.GetUniformLocation("u_slope"), data.GetSlope());
145 glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset()); 153 glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset());
146 glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter); 154 glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter);
147 glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth); 155 glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth);
148 glUniform1f(execution.GetUniformLocation("u_invert"), invert); 156 glUniform1f(execution.GetUniformLocation("u_invert"), invert);
149 157
150 execution.DrawTriangles(); 158 execution.DrawTriangles();
159 }
151 } 160 }
152 } 161 }
153 } 162 }