From 66b8acfb4bfb2780bc95864a6af7764f78ccd09b Mon Sep 17 00:00:00 2001 From: Steven Lovegrove Date: Mon, 22 Aug 2016 18:49:14 -0700 Subject: [PATCH] Support displaying more image formats. --- include/pangolin/gl/gl.h | 4 ++-- include/pangolin/gl/gl.hpp | 17 ++++++++++++++--- include/pangolin/gl/glformattraits.h | 8 ++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/pangolin/gl/gl.h b/include/pangolin/gl/gl.h index d3effa900..4c921e5e2 100644 --- a/include/pangolin/gl/gl.h +++ b/include/pangolin/gl/gl.h @@ -55,7 +55,7 @@ class PANGOLIN_EXPORT GlTexture { public: //! internal_format normally one of GL_RGBA8, GL_LUMINANCE8, GL_INTENSITY16 - GlTexture(GLint width, GLint height, GLint internal_format = GL_RGBA, bool sampling_linear = true, int border = 0, GLenum glformat = GL_RGBA, GLenum gltype = GL_UNSIGNED_BYTE, GLvoid* data = NULL ); + GlTexture(GLint width, GLint height, GLint internal_format = GL_RGBA8, bool sampling_linear = true, int border = 0, GLenum glformat = GL_RGBA, GLenum gltype = GL_UNSIGNED_BYTE, GLvoid* data = NULL ); #ifdef CALLEE_HAS_RVALREF //! Move Constructor @@ -72,7 +72,7 @@ class PANGOLIN_EXPORT GlTexture void Delete(); //! Reinitialise teture width / height / format - void Reinitialise(GLsizei width, GLsizei height, GLint internal_format = GL_RGBA, bool sampling_linear = true, int border = 0, GLenum glformat = GL_RGBA, GLenum gltype = GL_UNSIGNED_BYTE, GLvoid* data = NULL ); + void Reinitialise(GLsizei width, GLsizei height, GLint internal_format = GL_RGBA8, bool sampling_linear = true, int border = 0, GLenum glformat = GL_RGBA, GLenum gltype = GL_UNSIGNED_BYTE, GLvoid* data = NULL ); void Bind() const; void Unbind() const; diff --git a/include/pangolin/gl/gl.hpp b/include/pangolin/gl/gl.hpp index bc0c2140f..eec13e15c 100644 --- a/include/pangolin/gl/gl.hpp +++ b/include/pangolin/gl/gl.hpp @@ -238,28 +238,39 @@ inline void GlTexture::Download(TypedImage& image) const image.Alloc(width, height, VideoFormatFromString("GRAY8") ); Download(image.ptr, GL_LUMINANCE, GL_UNSIGNED_BYTE); break; - case GL_RGB: + case GL_LUMINANCE16: + image.Alloc(width, height, VideoFormatFromString("GRAY16LE") ); + Download(image.ptr, GL_LUMINANCE, GL_UNSIGNED_SHORT); + break; + case GL_RGB8: image.Alloc(width, height, VideoFormatFromString("RGB24")); Download(image.ptr, GL_RGB, GL_UNSIGNED_BYTE); break; - case GL_RGBA: + case GL_RGBA8: image.Alloc(width, height, VideoFormatFromString("RGBA32")); Download(image.ptr, GL_RGBA, GL_UNSIGNED_BYTE); break; + case GL_LUMINANCE: case GL_LUMINANCE32F_ARB: image.Alloc(width, height, VideoFormatFromString("GRAY32F")); Download(image.ptr, GL_LUMINANCE, GL_FLOAT); break; + case GL_RGB: case GL_RGB32F: image.Alloc(width, height, VideoFormatFromString("RGB96F")); Download(image.ptr, GL_RGB, GL_FLOAT); break; + case GL_RGBA: case GL_RGBA32F: image.Alloc(width, height, VideoFormatFromString("RGBA128F")); Download(image.ptr, GL_RGBA, GL_FLOAT); break; default: - throw std::runtime_error( "GlTexture::Download - Unknown internal format"); + throw std::runtime_error( + "GlTexture::Download - Unknown internal format (" + + pangolin::Convert::Do(internal_format) + + ")" + ); } } diff --git a/include/pangolin/gl/glformattraits.h b/include/pangolin/gl/glformattraits.h index d265d83ee..cf6124f7c 100644 --- a/include/pangolin/gl/glformattraits.h +++ b/include/pangolin/gl/glformattraits.h @@ -66,7 +66,7 @@ struct GlFormatTraits template<> struct GlFormatTraits { - static const GLint glinternalformat = GL_LUMINANCE; + static const GLint glinternalformat = GL_LUMINANCE32F_ARB; static const GLenum glformat = GL_LUMINANCE; static const GLenum gltype = GL_UNSIGNED_BYTE; }; @@ -76,7 +76,7 @@ struct GlFormatTraits template<> struct GlFormatTraits { - static const GLint glinternalformat = GL_LUMINANCE; + static const GLint glinternalformat = GL_LUMINANCE32F_ARB; static const GLenum glformat = GL_LUMINANCE; static const GLenum gltype = GL_UNSIGNED_SHORT; }; @@ -84,7 +84,7 @@ struct GlFormatTraits template<> struct GlFormatTraits { - static const GLint glinternalformat = GL_LUMINANCE; + static const GLint glinternalformat = GL_LUMINANCE32F_ARB; static const GLenum glformat = GL_LUMINANCE; static const GLenum gltype = GL_UNSIGNED_INT; }; @@ -92,7 +92,7 @@ struct GlFormatTraits template<> struct GlFormatTraits { - static const GLint glinternalformat = GL_LUMINANCE; + static const GLint glinternalformat = GL_LUMINANCE32F_ARB; static const GLenum glformat = GL_LUMINANCE; static const GLenum gltype = GL_INT; };