diff --git a/include/osg/Image b/include/osg/Image index dac63c91a..a8d023288 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -46,6 +46,7 @@ #define GL_COMPRESSED_RGBA 0x84EE #endif + namespace osg { /** Image class for encapsulating the storage texture image data. */ @@ -210,6 +211,7 @@ class OSG_EXPORT Image : public Object static bool isPackedType(GLenum type); + static GLenum computePixelFormat(GLenum pixelFormat); static unsigned int computeNumComponents(GLenum pixelFormat); static unsigned int computePixelSizeInBits(GLenum pixelFormat,GLenum type); static unsigned int computeRowWidthInBytes(int width,GLenum pixelFormat,GLenum type,int packing); diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 44410b9bc..cf99615c7 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -143,6 +143,34 @@ bool Image::isPackedType(GLenum type) } } + +GLenum Image::computePixelFormat(GLenum format) +{ + switch(format) + { + case(GL_ALPHA16F_ARB): + case(GL_ALPHA32F_ARB): + return GL_ALPHA; + case(GL_LUMINANCE16F_ARB): + case(GL_LUMINANCE32F_ARB): + return GL_LUMINANCE; + case(GL_INTENSITY16F_ARB): + case(GL_INTENSITY32F_ARB): + return GL_INTENSITY; + case(GL_LUMINANCE_ALPHA16F_ARB): + case(GL_LUMINANCE_ALPHA32F_ARB): + return GL_LUMINANCE_ALPHA; + case(GL_RGB32F_ARB): + case(GL_RGB16F_ARB): + return GL_RGB; + case(GL_RGBA32F_ARB): + case(GL_RGBA16F_ARB): + return GL_RGBA; + default: + return format; + } +} + unsigned int Image::computeNumComponents(GLenum pixelFormat) { switch(pixelFormat) @@ -158,13 +186,23 @@ unsigned int Image::computeNumComponents(GLenum pixelFormat) case(GL_GREEN): return 1; case(GL_BLUE): return 1; case(GL_ALPHA): return 1; + case(GL_ALPHA16F_ARB): return 1; + case(GL_ALPHA32F_ARB): return 1; case(GL_RGB): return 3; case(GL_BGR): return 3; + case(GL_RGB16F_ARB): return 3; + case(GL_RGB32F_ARB): return 3; case(GL_RGBA): return 4; case(GL_BGRA): return 4; case(GL_LUMINANCE): return 1; + case(GL_LUMINANCE16F_ARB): return 1; + case(GL_LUMINANCE32F_ARB): return 1; case(GL_INTENSITY): return 1; + case(GL_INTENSITY16F_ARB): return 1; + case(GL_INTENSITY32F_ARB): return 1; case(GL_LUMINANCE_ALPHA): return 2; + case(GL_LUMINANCE_ALPHA16F_ARB): return 2; + case(GL_LUMINANCE_ALPHA32F_ARB): return 2; case(GL_HILO_NV): return 2; case(GL_DSDT_NV): return 2; case(GL_DSDT_MAG_NV): return 3; @@ -600,7 +638,7 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps _t = height; _r = depth; - _pixelFormat = internalformat; + _pixelFormat = computePixelFormat(internalformat); _dataType = type; _internalTextureFormat = internalformat; _mipmapData = mipMapData;