From bc76fbf60d2ba79c064fc5518bfe75fe55a68f90 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 15 Jun 2005 20:05:47 +0000 Subject: [PATCH] Added automatic creation of texture when size is set but not osg::Image is assigned. This is useful for FBO usage. --- src/osg/Texture2D.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index d1e04cdf7..e8f125be1 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -206,6 +206,22 @@ void Texture2D::apply(State& state) const //glBindTexture( GL_TEXTURE_2D, handle ); } + else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_internalFormat!=0) ) + { + _textureObjectBuffer[contextID] = textureObject = generateTextureObject( + contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0); + + textureObject->bind(); + + applyTexParameters(GL_TEXTURE_2D,state); + + // no image present, but dimensions at set so less create the texture + glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat, + _textureWidth, _textureHeight, _borderWidth, + _internalFormat, + GL_UNSIGNED_BYTE, + 0); + } else { glBindTexture( GL_TEXTURE_2D, 0 );