From 48b9b25805644b34539801991bc5b95c62be1a0a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Feb 2012 12:03:14 +0000 Subject: [PATCH] From Johannes Baeurele, "The osg::Image class now contains a 'supportsTextureSubloading()' method that is used inside the Texture2D::apply method. For now it only checks for the etc1 format in which case it returns 'false'. All other formats lead to a return value of 'true'. Without the change the application does not work properly. First I get the notification that an OpenGL error occured. After some more of this error messages I see broken textures on the screen. With the changes attached to this message my application works as intended." Note from Robert Osfield, changed the Image::supportsTextureSubloading() to be const and to be implemented in the .cpp rather than inline. --- include/osg/Image | 7 +++++++ src/osg/Image.cpp | 11 +++++++++++ src/osg/Texture2D.cpp | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/osg/Image b/include/osg/Image index 2c9cb3655..6e252cb2c 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -92,6 +92,10 @@ #define GL_UNPACK_IMAGE_HEIGHT 0x806E #endif +#ifndef GL_OES_compressed_ETC1_RGB8_texture + #define GL_ETC1_RGB8_OES 0x8D64 +#endif + namespace osg { // forward declare @@ -396,6 +400,9 @@ class OSG_EXPORT Image : public BufferData return _data+getMipmapOffset(mipmapLevel); } + /** returns false for texture formats that do not support texture subloading */ + bool supportsTextureSubloading() const; + /** Return true if this image is translucent - i.e. it has alpha values that are less 1.0 (when normalized). */ virtual bool isImageTranslucent() const; diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 3994a016e..164b4fceb 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1431,6 +1431,17 @@ void Image::ensureValidSizeForTexturing(GLint maxTextureSize) } } +bool Image::supportsTextureSubloading() const +{ + switch(_internalTextureFormat) + { + case GL_ETC1_RGB8_OES: + return false; + default: + return true; + } +} + template bool _findLowerAlphaValueInRow(unsigned int num, T* data,T value, unsigned int delta) diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 09ce2b556..0c9e1ac92 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -247,7 +247,7 @@ void Texture2D::apply(State& state) const applyTexParameters(GL_TEXTURE_2D,state); - if (textureObject->isAllocated()) + if (textureObject->isAllocated() && image->supportsTextureSubloading()) { //OSG_NOTICE<<"Reusing texture object"<