Added automatic creation of texture when size is set but not osg::Image is assigned.

This is useful for FBO usage.
This commit is contained in:
Robert Osfield
2005-06-15 20:05:47 +00:00
parent 92087ee5ac
commit bc76fbf60d

View File

@@ -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 );