Hi Thomas,

15.10.2010 0:26, Thomas Hogarth wrote:
Hi Robert, Mikhail

Mikhail thanks for pointing me to this as a solution to my subload problems.

Robert, i'll take a look at the new code, but I assume this can be used to
solve my problem of not wanting the object released if the image demensions
are different to the texture dimensions?

Tom
In your case this would be a small hack. After release of texture object, you can reuse it using new generateTextureObject method.
For example:
<code>
osg::Texture::TextureObject* TextureSubloadCallback::generateTextureObject(const osg::Texture2D& texture, osg::State& state) const
{
  const osg::Image *image = texture.getImage();
  if(image && image->data())
  {
    texture.setNumMipmapLevels(1);
    int width = image->s();
    int height = image->t();
    texture.setTextureSize(width, height);

return osg::Texture::generateTextureObject(&texture, state.getContextID(),GL_TEXTURE_2D, texture.getNumMipmapLevels(),texture.getInternalFormat(),width,height,1,texture.getBorderWidth());
  }
  else
return osg::Texture2D::SubloadCallback::generateTextureObject(texture, state);
}
</code>

After that in load method you can check what texture object is already allocated and use subload instead load.

Mikhail.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to