Mercurial > hg > orthanc-stone
changeset 2033:23b0a42eea85 deep-learning
added support for floating-point images in OpenGLTexture
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 22 Jan 2023 10:48:22 +0100 |
parents | d10bab7cc396 |
children | 4b24b7533346 |
files | OrthancStone/Sources/OpenGL/OpenGLTexture.cpp |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/OpenGL/OpenGLTexture.cpp Sat Jan 21 16:48:56 2023 +0100 +++ b/OrthancStone/Sources/OpenGL/OpenGLTexture.cpp Sun Jan 22 10:48:22 2023 +0100 @@ -92,7 +92,7 @@ if (image.GetPitch() != image.GetBytesPerPixel() * image.GetWidth()) { throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, - "Unsupported non-zero padding"); + "Pitch is not the same as the row size"); } // Bind it @@ -121,6 +121,12 @@ pixelType = GL_UNSIGNED_BYTE; break; + case Orthanc::PixelFormat_Float32: + sourceFormat = GL_RED; + internalFormat = GL_R32F; // Don't use "GL_RED" here, as it clamps to [0,1] + pixelType = GL_FLOAT; + break; + default: throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "No support for this format in OpenGL textures: " + @@ -160,6 +166,7 @@ } std::unique_ptr<Orthanc::ImageAccessor> target(new Orthanc::Image(format, width_, height_, true)); + assert(target->GetPitch() == width_ * Orthanc::GetBytesPerPixel(format)); glBindTexture(GL_TEXTURE_2D, texture_); @@ -177,6 +184,10 @@ glGetTexImage(GL_TEXTURE_2D, 0 /* base level */, GL_RGBA, GL_UNSIGNED_BYTE, target->GetBuffer()); break; + case Orthanc::PixelFormat_Float32: + glGetTexImage(GL_TEXTURE_2D, 0 /* base level */, GL_RED, GL_FLOAT, target->GetBuffer()); + break; + default: throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); }