[osg-users] Get RGB Values from Textrue
Sebastian Messerschmidt
sebastian.messerschmidt at gmx.de
Mon Nov 13 01:26:23 PST 2017
Hi Maxim,
> Hi,
>
> I have a osg::Texture2D that I'm using as a render to texture target.
> I can see that it is working on the screen, but I need to have access to the RGB values of the texture itself so I can also copy them to another API.
>
> How can I access the RGB values?
set a postDrawCallback to the pass/camera that writes to the texture.
In the callback:
virtual void operator () (osg::RenderInfo& render_info) const
{
osg::State* state=render_info.getState();
state->apply(render_info.getCurrentCamera()->getStateSet());
state->applyTextureAttribute(0, mTexture);
mTexture->apply(*state);
mImage->readImageFromCurrentTexture(render_info.getContextID(),true,
GL_FLOAT ); //change the GL_FLOAT to your needs
}
the mTexture is passed to the callback using the original texture
attached to the MRT.
Cheers
Sebastian
>
> After rendering a frame, if I access _image in the texture2D class, it is null, but I do see that the Texture of texture2D has an array size of 1.
> How and where are the RGB values stored?
>
> Thank you!
>
> Maxim
>
> ------------------------
> Thank you,
> --Maxim
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72322#72322
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
More information about the osg-users
mailing list