Fix loading of 16bit PNG images

When a 16bit PNG image is loaded, the internalTextureFormat is set to unsized (i.e pixelFormat) constant. This results in 8 Bit Texture2D
This commit is contained in:
Denys Koch
2017-09-28 11:09:18 +02:00
committed by GitHub
parent 4bc1320709
commit b3c08a8ad6

View File

@@ -307,6 +307,18 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
pixelFormat = GL_RGBA;
int internalFormat = pixelFormat;
if (depth > 8)
{
switch(color)
{
case(GL_LUMINANCE): internalFormat = GL_LUMINANCE16; break;
case(GL_ALPHA): internalFormat = GL_ALPHA16; break;
case(GL_LUMINANCE_ALPHA): internalFormat = GL_LUMINANCE16_ALPHA16; break;
case(GL_RGB): internalFormat = GL_RGB16; break;
case(GL_RGBA): internalFormat = GL_RGBA16; break;
default: break;
}
}
png_destroy_read_struct(&png, &info, &endinfo);