Rendering osgViewers to an FBO

60 views
Skip to first unread message

jasonb...@gmail.com

unread,
Jun 2, 2021, 2:37:23 PMJun 2
to OpenSceneGraph Users
Hi Robert,

I'm investigating the possibility of using Dear IMGUI in a full blown application instead of something more heavy weight like Qt.  We did a basic integration of Dear ImGui in osgEarth and it's been a game changer in terms of usability for our example apps and made writing debugging tools much easier.  With the imgui docking branch it's really possible to do some really nice GUI's with it and there are game engines like Hazel and Lumix that have built out their guis using imgui.

What I'm looking at doing right now is embedding an osg viewer WITHIN an imgui control.  To do this I'm trying to render a bunch of separate osgViewer's to their own FBO and then I'm using the ImGui::Image function to render the texture.  You can see an example of that here.imgui_interface.jpg
All of those different views are draggable and dockable and camera manipulation (mostly) works within the windows.

I'm not happy with how I'm currently doing this.  Right now each of those are a subclass of osgViewer::Viewer that creates a GraphicsWindowEmbedded as their context.  I make a slave camera for the viewer that is an RTT camera, and I'm setting the graphics contex ton the main camera to be null so it doesn't actually try to do anything to the frame buffer.  This is all a bit messy but seems to actually work so far.  I want them all to be actual osgViewer::View's at the very least and not just plain old PRE_RENDER osg::Camera's because I want them to have their own CameraManipulators and resizing logic.

Is there a simpler way to tell an osgViewer::Viewer (or even an osgViewer::View) to render only to a FBO and not the frame buffer?  It seems like it shouldn't be all that bad but I'm not seeing it.  

Jason

Robert Osfield

unread,
Jun 3, 2021, 11:48:54 PMJun 3
to OpenSceneGraph Users
Hi Jason,

On Wed, 2 Jun 2021 at 19:37, jasonb...@gmail.com <jasonb...@gmail.com> wrote:
I'm not happy with how I'm currently doing this.  Right now each of those are a subclass of osgViewer::Viewer that creates a GraphicsWindowEmbedded as their context.  I make a slave camera for the viewer that is an RTT camera, and I'm setting the graphics contex ton the main camera to be null so it doesn't actually try to do anything to the frame buffer.  This is all a bit messy but seems to actually work so far.  I want them all to be actual osgViewer::View's at the very least and not just plain old PRE_RENDER osg::Camera's because I want them to have their own CameraManipulators and resizing logic.

Is there a simpler way to tell an osgViewer::Viewer (or even an osgViewer::View) to render only to a FBO and not the frame buffer?  It seems like it shouldn't be all that bad but I'm not seeing it.  

It should be possible to set the Texture you want to write to the VIew's Camera's attachment list.

Cheers,
Robert.
 
Reply all
Reply to author
Forward
0 new messages