[osg-users] How to use frame buffer object in existing (not osg) window and pipeline.

Robert Osfield robert.osfield at gmail.com
Sat Feb 18 00:56:08 PST 2017


HI Han,

The OSG has a sophisticated support for multiple pass rendering built
into the scene graph itself, tjhere is no need to mix viewer code with
multi-pass rendering in the way you are doing. I would recommend
against conflating viewer and low level rendering of the scene as it
limits the flexibility of your appication to handle new rendering
techniques - as you will have hardwired in the rendering technique at
the application level.

There are number of multiple pass examples that the OSG provides, see
osgdistortion, osghud, osgprerender, osgprerendercubemap.

Robert

On 18 February 2017 at 03:54, Han Hu <huhan8807 at gmail.com> wrote:
> Hi,
>
> I know OSG viewer can render into other window as shown in the glutviewer and sdl viewer example. But I do not know how to use fbo for this kind of work. The following code describes my purpose.
>
>
>
> Code:
>
>
> osg::ref_ptr<Viewer> viewer;
> /* The vierwer is properly set up for other window*/
>
> FrameBufferObject fbo;
> /* The fbo is properly initilize with color and depth texture attachment and bind to a FBO object. And the fbo class have access to the texture object and will be used for image based rendering technic*/
>
> /* The rendering loop */
> void draw()
> {
>         // only repaint the whole scene when needed, because my scene is rather static and heavy,
>         // draw fewer things
>         if(dragging){
>                 fbo.bind();
>                 /* draw a fewer things into fbo*/
>                 viewer.frame();
>                 fbo.unbind();
>         }
>
>         /* Draw heavier things */
>         if(need_repaint)
>         {
>                 fbo.bind();
>                 viewer.frame();
>                 fbo.unbind();
>         }
>
>         /* Do some post processing with fbo, e.g. eye dome lighting, which is  a image based rendering techniqe */
>         {
>                 /* filtering */
>                 filter(fbo);
>         }
>
>         /* blit the fbo onto backbuffer */
>         fbo.blit();
>
>         swapbuffer();
> }
>
>
>
>
>
> So my question is how to do this kind of fbo processing in OSG, because after investigate osg framebufferobject, I find the logic is not like this and a little confuse to understand.
>
> Thank you!
>
> Cheers,
> Han
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70240#70240
>
>
>
>
>
> _______________________________________________
> 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