Hi Jonathan,

You can get the context ID from the global osg::State object. You can also
use the osg::State object to bind the texture as well. So to read the image
for a texture, you could do the following:

osg::State *state; // TODO: Get access to state object

texture->apply(*state)
osg::ref_ptr<osg::Image> img = new osg::Image;
img->readImageFromCurrentTexture(state->getContextID(), false);


This code will need to be executed within the OpenGL context associated
with the state object.

Cheers,
Farshid



On Mon, Jun 3, 2013 at 8:51 AM, Jonathan Mclaughlin <jonat...@mve.com>wrote:

>  Hi,****
>
> ** **
>
> I am looking for a bit of help with a  problem I’ve been having. I’m
> trying to take a screenshot of an osg scene, scale it up while maintaining
> resolution,  and save the result out to an image file. ****
>
> ** **
>
> At the moment, I have looked at the osgdistortion example and have managed
> to create a texture and display it on a textured quad. However, when I
> attempt to read the pixels out to an image, whether from the camera or the
> texture, nothing is produced. I am unsure as to the best way to go about
> this as it seems it should be simple to read the pixels from the frame
> buffer object or the texture but I have had no joy as yet. ****
>
> It seems like perhaps using osg::Image:: 
> *readImageFromCurrentTexture*<http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00305.html#e7e7a51a074aa4b4e0931b7fd7a98af9>()
> would be the best way to do this but I was having problems getting the
> context ID. I could possibly get this within a camera call back?... I
> notice also within the documentation this methods description says “Read
> the contents of the current bound texture” – Is there something more I have
> to do to make the texture “bound”?****
>
> ** **
>
> Thanks for any info,****
>
> ** **
>
> ** **
>
> Jonathan McLaughlin
> Software Engineer
>
> ________________________________
> Midland Valley will next be presenting at Hedberg Research Conference,
> 23rd – 27th June 2013****
>
> Midland Valley Exploration Ltd.
> 144 West George Street
> Glasgow G2 2HG
> United Kingdom****
>
> Tel:     +44 (0) 141 332 2681
> Fax:    +44 (0) 141 332 6792****
>
> The structural geology experts ****
>
> ** **
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to