Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/OrthancStone/Sources/OpenGL/OpenGLFramebuffer.cpp Thu May 04 16:59:28 2023 +0200 +++ b/OrthancStone/Sources/OpenGL/OpenGLFramebuffer.cpp Thu May 04 17:18:14 2023 +0200 @@ -31,6 +31,7 @@ #include "OpenGLTexture.h" #include "OpenGLTextureArray.h" +#include "OpenGLTextureVolume.h" #include <OrthancException.h> @@ -216,6 +217,25 @@ } + void OpenGLFramebuffer::SetTarget(OpenGLTextureVolume& target, + unsigned int z) + { + if (z >= target.GetDepth()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + else + { + // Warning: "glFramebufferTexture3D()" is not available in WebGL 2 + glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target.GetId(), 0, z); + ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()"); + + SetupTextureTarget(); + glViewport(0, 0, target.GetWidth(), target.GetHeight()); + } + } + + void OpenGLFramebuffer::ReadTexture(Orthanc::ImageAccessor& target, const OpenGLTexture& source) { @@ -261,5 +281,33 @@ ReadContent(target); } } + + + void OpenGLFramebuffer::ReadTexture(Orthanc::ImageAccessor& target, + const OpenGLTextureVolume& source, + unsigned int z) + { + if (target.GetWidth() != source.GetWidth() || + target.GetHeight() != source.GetHeight()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize); + } + else if (target.GetFormat() != source.GetFormat()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); + } + else if (z >= source.GetDepth()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + else + { + // Warning: "glFramebufferTexture3D()" is not available in WebGL 2 + glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, source.GetId(), 0, z); + ORTHANC_OPENGL_CHECK("glFramebufferTextureLayer()"); + + ReadContent(target); + } + } } }