@@ -440,26 +440,29 @@ void Texture2DArray::apply(State& state) const
440440 // generate texture
441441 GLenum texStorageSizedInternalFormat = extensions->isTextureStorageEnabled ? selectSizedInternalFormat () : 0 ;
442442
443- textureObject = generateAndAssignTextureObject (
444- contextID, GL_TEXTURE_2D_ARRAY, _numMipmapLevels,
445- texStorageSizedInternalFormat!=0 ? texStorageSizedInternalFormat :_internalFormat,
446- _textureWidth, _textureHeight, _textureDepth, 0 );
447-
448- textureObject->bind ();
449-
450- applyTexParameters (GL_TEXTURE_2D_ARRAY,state);
451-
452- if (texStorageSizedInternalFormat!=0 && !textureObject->_allocated )
443+ if (texStorageSizedInternalFormat != 0 )
453444 {
454- extensions->glTexStorage3D ( GL_TEXTURE_2D_ARRAY, osg::maximum (_numMipmapLevels,1 ), texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth);
445+ textureObject = generateAndAssignTextureObject (contextID, GL_TEXTURE_2D_ARRAY, _numMipmapLevels, texStorageSizedInternalFormat, _textureWidth, _textureHeight, _textureDepth, 0 );
446+ textureObject->bind ();
447+ applyTexParameters (GL_TEXTURE_2D_ARRAY, state);
448+ if (!textureObject->_allocated )
449+ {
450+ extensions->glTexStorage3D (GL_TEXTURE_2D_ARRAY, osg::maximum (_numMipmapLevels, 1 ), texStorageSizedInternalFormat,
451+ _textureWidth, _textureHeight, _textureDepth);
452+ }
455453 }
456454 else
457- extensions->glTexImage3D ( GL_TEXTURE_2D_ARRAY, 0 , _internalFormat,
458- _textureWidth, _textureHeight, _textureDepth,
459- _borderWidth,
460- _sourceFormat ? _sourceFormat : _internalFormat,
461- _sourceType ? _sourceType : GL_UNSIGNED_BYTE,
462- 0 );
455+ {
456+ GLenum internalFormat = _sourceFormat ? _sourceFormat : _internalFormat;
457+ textureObject = generateAndAssignTextureObject (contextID, GL_TEXTURE_2D_ARRAY, _numMipmapLevels, internalFormat, _textureWidth, _textureHeight, _textureDepth, 0 );
458+ textureObject->bind ();
459+ applyTexParameters (GL_TEXTURE_2D_ARRAY, state);
460+ extensions->glTexImage3D (GL_TEXTURE_2D_ARRAY, 0 , _internalFormat,
461+ _textureWidth, _textureHeight, _textureDepth, _borderWidth,
462+ internalFormat,
463+ _sourceType ? _sourceType : GL_UNSIGNED_BYTE,
464+ 0 );
465+ }
463466
464467 textureObject->setAllocated (_numMipmapLevels, texStorageSizedInternalFormat!=0 ? texStorageSizedInternalFormat :_internalFormat, _textureWidth, _textureHeight, _textureDepth, 0 );
465468 }
0 commit comments