comparison OrthancStone/Sources/OpenGL/OpenGLFramebuffer.cpp @ 2066:cf3d85eb291c deep-learning

added class OpenGLTextureVolume
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 May 2023 17:18:14 +0200
parents 4e31d76c7ecd
children
comparison
equal deleted inserted replaced
2065:15f2e52835a1 2066:cf3d85eb291c
29 # endif 29 # endif
30 #endif 30 #endif
31 31
32 #include "OpenGLTexture.h" 32 #include "OpenGLTexture.h"
33 #include "OpenGLTextureArray.h" 33 #include "OpenGLTextureArray.h"
34 #include "OpenGLTextureVolume.h"
34 35
35 #include <OrthancException.h> 36 #include <OrthancException.h>
36 37
37 38
38 namespace OrthancStone 39 namespace OrthancStone
214 glViewport(0, 0, target.GetWidth(), target.GetHeight()); 215 glViewport(0, 0, target.GetWidth(), target.GetHeight());
215 } 216 }
216 } 217 }
217 218
218 219
220 void OpenGLFramebuffer::SetTarget(OpenGLTextureVolume& target,
221 unsigned int z)
222 {
223 if (z >= target.GetDepth())
224 {
225 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
226 }
227 else
228 {
229 // Warning: "glFramebufferTexture3D()" is not available in WebGL 2
230 glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target.GetId(), 0, z);
231 ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()");
232
233 SetupTextureTarget();
234 glViewport(0, 0, target.GetWidth(), target.GetHeight());
235 }
236 }
237
238
219 void OpenGLFramebuffer::ReadTexture(Orthanc::ImageAccessor& target, 239 void OpenGLFramebuffer::ReadTexture(Orthanc::ImageAccessor& target,
220 const OpenGLTexture& source) 240 const OpenGLTexture& source)
221 { 241 {
222 if (target.GetWidth() != source.GetWidth() || 242 if (target.GetWidth() != source.GetWidth() ||
223 target.GetHeight() != source.GetHeight()) 243 target.GetHeight() != source.GetHeight())
259 glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, source.GetId(), 0, layer); 279 glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, source.GetId(), 0, layer);
260 ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()"); 280 ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()");
261 ReadContent(target); 281 ReadContent(target);
262 } 282 }
263 } 283 }
284
285
286 void OpenGLFramebuffer::ReadTexture(Orthanc::ImageAccessor& target,
287 const OpenGLTextureVolume& source,
288 unsigned int z)
289 {
290 if (target.GetWidth() != source.GetWidth() ||
291 target.GetHeight() != source.GetHeight())
292 {
293 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
294 }
295 else if (target.GetFormat() != source.GetFormat())
296 {
297 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
298 }
299 else if (z >= source.GetDepth())
300 {
301 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
302 }
303 else
304 {
305 // Warning: "glFramebufferTexture3D()" is not available in WebGL 2
306 glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, source.GetId(), 0, z);
307 ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()");
308
309 ReadContent(target);
310 }
311 }
264 } 312 }
265 } 313 }