# HG changeset patch # User Sebastien Jodogne # Date 1674380902 -3600 # Node ID 23b0a42eea8577846b917b89d34ae815408f09ba # Parent d10bab7cc3969af954345ebdf0e3df51a802ac46 added support for floating-point images in OpenGLTexture diff -r d10bab7cc396 -r 23b0a42eea85 OrthancStone/Sources/OpenGL/OpenGLTexture.cpp --- 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 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); }