[osg-users] Render to texture

Ivan Bolčina ivan.bolcina at gmail.com
Tue Sep 4 23:29:52 PDT 2007


Thanks Zach.

The point is, I need images drawn only once, before game main loop.
Prerender example sets up dynamic prerender to texture with usage of
callbacks. So every frame prerendering gets called.

I was wondering if there is a way, to prerender node to a image (or
texture). Then when game runs, i would like to display this image on hud.

Thanks!

2007/9/4, Zach Deedler <mynamezach at gmail.com>:
>
>  Hi Ivan,
>
>
>
> I have this code:
>
> for(Viewer::EventHandlerList::iterator itr =
> m_poViewer->getEventHandlerList().begin();
>
>             itr != m_poViewer->getEventHandlerList().end();
>
>             ++itr){
>
>       ViewerEventHandler* viewerEventHandler =
>
>          dynamic_cast<ViewerEventHandler*>(itr->get());
>
>       if (viewerEventHandler){
>
>          viewerEventHandler->setWriteImageFileName(pszFile);
>
>          viewerEventHandler->setWriteImageOnNextFrame(true);
>
>          return 0;
>
>       }
>
>    }
>
>
>
> Maybe you can search the code for setWriteImageFileName and back track
> from there?
>
>
>
> I believe there is a function call to do what you want for a camera.
>
>
>
> Also, osgprerender renders a scene to a texture every frame.  If you did
> that then you can probably just save off the texture by calling an
> osg::Texture or osg::Image call.
>
>
>  ------------------------------
>
> *From:* osg-users-bounces at lists.openscenegraph.org [mailto:
> osg-users-bounces at lists.openscenegraph.org] *On Behalf Of *Ivan Bolcina
> *Sent:* Tuesday, September 04, 2007 3:44 PM
> *To:* osg-users at lists.openscenegraph.org
> *Subject:* [osg-users] Render to texture
>
>
>
>
> Hi.
>
> I just want to render a simple node to a texture. All the examples are
> using callbacks, osg viewer,etc.. I don't understand all that, I just want
> to set up geometry, projection and new camera and then take one shoot with
> camera and that's it.
>
> So I need a simple function like this
>
> osg::Image * CreateTopDownShotOfNode( osg::Node * node);
>
> The main problem is how to tell osg to render using that camera.
>
> thx
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070905/bcda096e/attachment-0003.htm>


More information about the osg-users mailing list