diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index d97cc7c07..caef2aa80 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -803,6 +803,31 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima // select the internalFormat required for the texture. bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat()); + + // If the texture's internal format is a compressed type, then the + // user is requesting that the graphics card compress the image if it's + // not already compressed. However, if the image is not a multiple of + // four in each dimension the subsequent calls to glTexSubImage* will + // fail. Revert to uncompressed format in this case. + if (isCompressedInternalFormat(_internalFormat) && + (((inwidth >> 2) << 2) != inwidth || + ((inheight >> 2) << 2) != inheight)) + { + osg::notify(osg::NOTICE)<<"Received a request to compress an image, but image size is not a multiple of four ("<getPacking()); @@ -1036,6 +1061,19 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* } // else image size the same as when loaded so we can go ahead and subload + // If the texture's internal format is a compressed type, then the + // user is requesting that the graphics card compress the image if it's + // not already compressed. However, if the image is not a multiple of + // four in each dimension the subsequent calls to glTexSubImage* will + // fail. Revert to uncompressed format in this case. + if (isCompressedInternalFormat(_internalFormat) && + (((inwidth >> 2) << 2) != inwidth || + ((inheight >> 2) << 2) != inheight)) + { + applyTexImage2D_load(state, target, image, inwidth, inheight, numMipmapLevels); + return; + } + #ifdef DO_TIMING osg::Timer_t start_tick = osg::Timer::instance()->tick(); osg::notify(osg::NOTICE)<<"glTexSubImage2D pixelFormat = "<getPixelFormat()<