Merge pull request #834 from 0871087123/tif_bug_fix
getInternalTextureFormat() failed after reading a tiff file
This commit is contained in:
commit
12084cd0e2
@ -809,20 +809,53 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
|
|||||||
int t = height_ret;
|
int t = height_ret;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
|
||||||
int internalFormat = numComponents_ret;
|
|
||||||
|
|
||||||
unsigned int pixelFormat =
|
unsigned int pixelFormat =
|
||||||
numComponents_ret == 1 ? GL_LUMINANCE :
|
numComponents_ret == 1 ? GL_LUMINANCE :
|
||||||
numComponents_ret == 2 ? GL_LUMINANCE_ALPHA :
|
numComponents_ret == 2 ? GL_LUMINANCE_ALPHA :
|
||||||
numComponents_ret == 3 ? GL_RGB :
|
numComponents_ret == 3 ? GL_RGB :
|
||||||
numComponents_ret == 4 ? GL_RGBA : (GLenum)-1;
|
numComponents_ret == 4 ? GL_RGBA : (GLenum)-1;
|
||||||
|
|
||||||
|
|
||||||
unsigned int dataType =
|
unsigned int dataType =
|
||||||
bitspersample_ret == 8 ? GL_UNSIGNED_BYTE :
|
bitspersample_ret == 8 ? GL_UNSIGNED_BYTE :
|
||||||
bitspersample_ret == 16 ? GL_UNSIGNED_SHORT :
|
bitspersample_ret == 16 ? GL_UNSIGNED_SHORT :
|
||||||
bitspersample_ret == 32 ? GL_FLOAT : (GLenum)-1;
|
bitspersample_ret == 32 ? GL_FLOAT : (GLenum)-1;
|
||||||
|
|
||||||
|
int internalFormat = 0;
|
||||||
|
switch (pixelFormat) {
|
||||||
|
case GL_LUMINANCE: {
|
||||||
|
switch (dataType) {
|
||||||
|
case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE8; break;
|
||||||
|
case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE16; break;
|
||||||
|
case GL_FLOAT : internalFormat = GL_LUMINANCE32F_ARB; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GL_LUMINANCE_ALPHA: {
|
||||||
|
switch (dataType) {
|
||||||
|
case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE_ALPHA8UI_EXT; break;
|
||||||
|
case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE_ALPHA16UI_EXT; break;
|
||||||
|
case GL_FLOAT: internalFormat = GL_LUMINANCE_ALPHA32F_ARB; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GL_RGB: {
|
||||||
|
switch (dataType) {
|
||||||
|
case GL_UNSIGNED_BYTE: internalFormat = GL_RGB8; break;
|
||||||
|
case GL_UNSIGNED_SHORT: internalFormat = GL_RGB16; break;
|
||||||
|
case GL_FLOAT: internalFormat = GL_RGB32F_ARB; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GL_RGBA : {
|
||||||
|
switch (dataType) {
|
||||||
|
case GL_UNSIGNED_BYTE: internalFormat = GL_RGBA8; break;
|
||||||
|
case GL_UNSIGNED_SHORT: internalFormat = GL_RGBA16; break;
|
||||||
|
case GL_FLOAT: internalFormat = GL_RGBA32F_ARB; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
osg::Image* pOsgImage = new osg::Image;
|
osg::Image* pOsgImage = new osg::Image;
|
||||||
pOsgImage->setImage(s,t,r,
|
pOsgImage->setImage(s,t,r,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
|
Loading…
Reference in New Issue
Block a user