comparison OrthancStone/Sources/OpenGL/OpenGLTexture.cpp @ 2044:c9dadbe7c7b0 deep-learning

notes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 05 Mar 2023 15:05:58 +0100
parents f3d756e5503f
children e5c812a36746
comparison
equal deleted inserted replaced
2043:f3d756e5503f 2044:c9dadbe7c7b0
112 // Load the texture from the image buffer 112 // Load the texture from the image buffer
113 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 113 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
114 0, sourceFormat, pixelType, data); 114 0, sourceFormat, pixelType, data);
115 115
116 #if !defined(__EMSCRIPTEN__) 116 #if !defined(__EMSCRIPTEN__)
117 // "glGetTexLevelParameteriv()" seems to be undefined on WebGL 117 // glGetTexLevelParameteriv() is not implemented yet in Emscripten 3.1.7
118 GLint w, h; 118 GLint w, h;
119 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); 119 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
120 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); 120 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
121 if (width != static_cast<unsigned int>(w) || 121 if (width != static_cast<unsigned int>(w) ||
122 height != static_cast<unsigned int>(h)) 122 height != static_cast<unsigned int>(h))
185 } 185 }
186 186
187 std::unique_ptr<Orthanc::ImageAccessor> target(new Orthanc::Image(format, width_, height_, true)); 187 std::unique_ptr<Orthanc::ImageAccessor> target(new Orthanc::Image(format, width_, height_, true));
188 assert(target->GetPitch() == width_ * Orthanc::GetBytesPerPixel(format)); 188 assert(target->GetPitch() == width_ * Orthanc::GetBytesPerPixel(format));
189 189
190 #if defined(__EMSCRIPTEN__)
191 /**
192 * The "glGetTexImage()" is unavailable in WebGL, it is
193 * necessary to use a framebuffer:
194 * https://stackoverflow.com/a/15064957
195 **/
196 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
197
198 #else
190 glBindTexture(GL_TEXTURE_2D, texture_); 199 glBindTexture(GL_TEXTURE_2D, texture_);
191 200
192 switch (format) 201 switch (format)
193 { 202 {
194 case Orthanc::PixelFormat_Grayscale8: 203 case Orthanc::PixelFormat_Grayscale8:
208 break; 217 break;
209 218
210 default: 219 default:
211 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 220 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
212 } 221 }
222 #endif
213 223
214 return target.release(); 224 return target.release();
215 } 225 }
216 226
217 227