Hello Richard,

I am trying to provide multiple views of an OpenSceneGraph scene within a Qt window.

[...]

But I am still not clear how to render each view. The examples use composite_viewer->frame() in the paint event but for me this only renders a single view and leaves the rest blank.
Is there an alternative way to render multiple views at the same time?

I've seen you're considering having separate viewers, but I would suggest you use a single CompositeViewer. That will make sure you get the benefits of OSG's threading of update, cull and draw traversals.

Just add views to your viewer, and have each view's camera have a GraphicsWindow whose inheritedWindowData is:

    traits->inheritedWindowData = new WindowData(winId());

(using the definition of WindowData at the top of QOSGWidget.cpp)

I personally realize() the graphics contexts at creation, because the CompositeViewer has a few early-exit conditions where it will not execute some branch if *one* of its views' contexts is realized, so I just want to make sure the all are.

Make sure you assign the scene data to your new view, and make sure your camera's projection matrix is sane. We had a problem where the window was first created by QT with a 0 width, so the initial projection matrix was not valid, and then any attempt to change the projection matrix (in the resizeEvent) would still use the invalid matrix as its starting point, so we would not see anything in the view.

Also, another caveat, often when reparenting a QT widget, its HWND (on Windows) changes. At that point of course, we need to recreate the graphics context, since it's tied to the widget's HWND, otherwise it would try to draw to an invalid HWND and fail.

Other than that, you might have to experiment with threading (when to create the context, when to stopThreading and startThreading, etc.). We still don't have an optimal solution, as you can see in the thread "CompositeViewer addView threading issue on Windows?".

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to