From ca134dca2df6e1a385df8c931245be3cf79c7b0f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 12 Sep 2018 17:45:49 +0100 Subject: [PATCH] Standardized the glTexStorage*() calls to use osg::maximum(_numMipmapLevels,1) of rnumber of mipmaps to keep the usage consistent. Fixed the erronous Texture2DArray glTexStorage call so that it used the _numMipmapLevels as above to resolve bug in allocation. --- src/osg/Texture1D.cpp | 2 +- src/osg/Texture2D.cpp | 2 +- src/osg/Texture2DArray.cpp | 4 ++-- src/osg/Texture3D.cpp | 2 +- src/osg/TextureCubeMap.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osg/Texture1D.cpp b/src/osg/Texture1D.cpp index f316968ef..d24a77a49 100644 --- a/src/osg/Texture1D.cpp +++ b/src/osg/Texture1D.cpp @@ -239,7 +239,7 @@ void Texture1D::apply(State& state) const textureObject->bind(); applyTexParameters(GL_TEXTURE_1D, state); - extensions->glTexStorage1D( GL_TEXTURE_1D, (_numMipmapLevels >0)?_numMipmapLevels:1, texStorageSizedInternalFormat, _textureWidth); + extensions->glTexStorage1D( GL_TEXTURE_1D, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth); } else { diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 79778e775..2aac8b2b0 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -306,7 +306,7 @@ void Texture2D::apply(State& state) const textureObject = generateAndAssignTextureObject(contextID, GL_TEXTURE_2D, _numMipmapLevels, texStorageSizedInternalFormat, _textureWidth, _textureHeight, 1, _borderWidth); textureObject->bind(); applyTexParameters(GL_TEXTURE_2D, state); - extensions->glTexStorage2D( GL_TEXTURE_2D, (_numMipmapLevels >0)?_numMipmapLevels:1, texStorageSizedInternalFormat, + extensions->glTexStorage2D( GL_TEXTURE_2D, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth, _textureHeight); } else diff --git a/src/osg/Texture2DArray.cpp b/src/osg/Texture2DArray.cpp index 23178e91b..8edfe2c68 100644 --- a/src/osg/Texture2DArray.cpp +++ b/src/osg/Texture2DArray.cpp @@ -355,7 +355,7 @@ void Texture2DArray::apply(State& state) const // First we need to allocate the texture memory if(texStorageSizedInternalFormat!=0) { - extensions->glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, texStorageSizedInternalFormat, _textureWidth, _textureHeight, textureDepth); + extensions->glTexStorage3D(GL_TEXTURE_2D_ARRAY, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth, _textureHeight, textureDepth); } else { @@ -454,7 +454,7 @@ void Texture2DArray::apply(State& state) const if (texStorageSizedInternalFormat!=0) { - extensions->glTexStorage3D( GL_TEXTURE_2D_ARRAY, (_numMipmapLevels >0)?_numMipmapLevels:1, texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth); + extensions->glTexStorage3D( GL_TEXTURE_2D_ARRAY, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth); } else extensions->glTexImage3D( GL_TEXTURE_2D_ARRAY, 0, _internalFormat, diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index eee22cc6f..74fe713c9 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -323,7 +323,7 @@ void Texture3D::apply(State& state) const textureObject->bind(); applyTexParameters(GL_TEXTURE_3D, state); - extensions->glTexStorage3D( GL_TEXTURE_3D, (_numMipmapLevels >0)?_numMipmapLevels:1, texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth); + extensions->glTexStorage3D( GL_TEXTURE_3D, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth); } else { diff --git a/src/osg/TextureCubeMap.cpp b/src/osg/TextureCubeMap.cpp index e99f0c44d..ba61ba909 100644 --- a/src/osg/TextureCubeMap.cpp +++ b/src/osg/TextureCubeMap.cpp @@ -353,7 +353,7 @@ void TextureCubeMap::apply(State& state) const if(texStorageSizedInternalFormat!=0) { - extensions->glTexStorage2D(GL_TEXTURE_CUBE_MAP, _numMipmapLevels==0 ? 1 : _numMipmapLevels, texStorageSizedInternalFormat, _textureWidth, _textureHeight); + extensions->glTexStorage2D(GL_TEXTURE_CUBE_MAP, osg::maximum(_numMipmapLevels,1), texStorageSizedInternalFormat, _textureWidth, _textureHeight); } else