[osg-users] Problem reading back integer textures
Marianne Thieffry
marianne.thieffry at gmail.com
Wed Jul 22 05:29:52 PDT 2015
Hi everyone,
I have a problem regardint integer textures. The setup is as follows:
A rtt camera uses custom fragment shaders to push data into 3 textures:
COLOR_BUFFER0: color buffer
COLOR_BUFFER1: rgb uint id buffer
DEPTH_BUFFER: depth buffer
The data inside those buffers is correct. However, I need the id buffer on
the cpu, and can't get it to work. I create the id buffer as follows:
osg::ref_ptr<osg::Texture2D> TextureManager::create2DIdTexture()
{
osg::ref_ptr<osg::Texture2D> idTex = new osg::Texture2D();
idTex->setTextureSize(1, 1);
idTex->setInternalFormat(GL_RGB32UI_EXT);
idTex->setSourceFormat(GL_RGBA_INTEGER_EXT);
idTex->setSourceType(GL_UNSIGNED_INT);
idTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
idTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
idTex->setBorderWidth(0);
idTex->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);
idTex->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);
return idTex;
}
- I have tried setting an image for the id buffer and attaching that one
to the camera instead of the texture as in the osgprerender example, which
results in opengl errors once I attach it to the camera. Image creation:
m_idBuffer = TextureManager::get2DTexture(RttBufferType::Id);
osg::Image *img = new osg::Image();
img->allocateImage(m_idBuffer->getTextureWidth(),
m_idBuffer->getTextureHeight(), 1, GL_RGB32UI_EXT, GL_UNSIGNED_INT);
m_idBuffer->setImage(img);
- Using a camera callback to read the image data, I also get opengl
erros. To ensure that the correct texture is bound in the callback, I have
deactivated the other two during my tests.
void ReadBufferCallback::operator() (osg::RenderInfo& renderInfo) const
{
osg::Image *img = new osg::Image;
img->readPixels(0, 0, 1000, 1000, GL_RGB_INTEGER_EXT, GL_UNSIGNED_INT);
}
When I have tested doing the same with the color buffer, reading it back to
the cpu works just fine with the method of osgprerender (attaching the
image to the rtt camera instead of the texture).
Does someone know why I am getting these errors?
Regards,
Marianne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150722/1afe3918/attachment-0002.htm>
More information about the osg-users
mailing list