From Chuck Seberion, added support reading ARB float format textures.

This commit is contained in:
Robert Osfield
2006-10-14 21:50:29 +00:00
parent 660cda57c8
commit f257285efc
2 changed files with 41 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;