Fix automatic mipmap generation for Canvas textures
When using glTexStorage2D, OSG doesn't allocate storage for the levels of the mipmap above the base unless an image is assigned to the texture.
This commit is contained in:
parent
5fdf6ef4f3
commit
325b89e023
@ -250,10 +250,16 @@ namespace canvas
|
||||
|
||||
if( !texture )
|
||||
{
|
||||
// It shouldn't be necessary to allocate an image for the
|
||||
// texture that is the target of dynamic rendering, but
|
||||
// otherwise OSG won't construct all the mipmaps for the texture
|
||||
// and dynamic mipmap generation doesn't work.
|
||||
osg::Image* image = new osg::Image;
|
||||
image->allocateImage(_size_x, _size_y, 1, GL_RGBA, GL_UNSIGNED_BYTE);
|
||||
texture = new osg::Texture2D;
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setTextureSize(_size_x, _size_y);
|
||||
texture->setInternalFormat(GL_RGBA);
|
||||
texture->setImage(image);
|
||||
texture->setUnRefImageDataAfterApply(true);
|
||||
}
|
||||
|
||||
updateSampling();
|
||||
|
Loading…
Reference in New Issue
Block a user