comparison OrthancStone/Sources/OpenGL/OpenGLTexture.cpp @ 2042:0fa4c0ca429d deep-learning

added OpenGLTexture::BindAsTextureUnit()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 Feb 2023 21:49:09 +0100
parents e0906b7c67b9
children f3d756e5503f
comparison
equal deleted inserted replaced
2041:85a20cbfcc04 2042:0fa4c0ca429d
154 glBindTexture(GL_TEXTURE_2D, texture_); 154 glBindTexture(GL_TEXTURE_2D, texture_);
155 glUniform1i(location, 0 /* texture unit */); 155 glUniform1i(location, 0 /* texture unit */);
156 } 156 }
157 157
158 158
159 void OpenGLTexture::BindAsTextureUnit(GLint location,
160 unsigned int unit) const
161 {
162 if (unit >= 32)
163 {
164 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
165 }
166
167 assert(GL_TEXTURE0 + 1 == GL_TEXTURE1 &&
168 GL_TEXTURE0 + 31 == GL_TEXTURE31);
169
170 glActiveTexture(GL_TEXTURE0 + unit);
171 glBindTexture(GL_TEXTURE_2D, texture_);
172 glUniform1i(location, unit /* texture unit */);
173 }
174
175
159 Orthanc::ImageAccessor* OpenGLTexture::Download(Orthanc::PixelFormat format) const 176 Orthanc::ImageAccessor* OpenGLTexture::Download(Orthanc::PixelFormat format) const
160 { 177 {
161 if (context_.IsContextLost()) 178 if (context_.IsContextLost())
162 { 179 {
163 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, 180 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,