osgQt icon indicating copy to clipboard operation
osgQt copied to clipboard

osgViewer::CompositeViewer missing?

Open unelsson opened this issue 4 years ago • 4 comments

I'm trying to update osgQt in project OpenMW-CS ( https://github.com/openmw/openmw ), a game world editor that should work with one or more windows and widgets. In that application, Qt widgets should be able to provide various different views. The previous OpenMW-CS version uses older osgQt, which was compatible with osgViewer::CompositeViewer.

The latest osgQt provides OSGRenderer, which uses osgViewer::Viewer. Is it possible to use osgViewer::CompositeViewer? Is it intentional that it's left out, or is it maybe a WIP?

To provide a context, my ongoing work is at https://github.com/OpenMW/openmw/pull/2786 , even if there isn't much to look at right now.

Thank you for your help.

unelsson avatar Apr 19 '20 21:04 unelsson

The following commits modify osgQOpenGLWidget and OSGRenderer to use osgViewer::CompositeViewer instead of osgViewer::Viewer. They can't be directly merged, but may be helpful examples for further development. https://github.com/OpenMW/openmw/commit/cf8eedd07e590cb6db4db3b6e584f50d0f0a645a https://github.com/OpenMW/openmw/commit/23c9c57f8b950890bf44f58560f2153d4713ff0a

unelsson avatar Nov 25 '20 21:11 unelsson

Here are two classes: updated osgQOpenGLWidget and CompositeOsgRenderer, which is a version of OSGRenderer that uses osgViewer::CompositeRenderer. I've unfortunately ran into rendering errors while using it - in OpenMW-CS objects don't randomly render as visible objects even when they are clearly editable in the scene. Also the floating mode of the widget causes error Warning: detected OpenGL error 'invalid value' at after RenderBin::draw(..). With these errors and lack of compatibility with osgQOpenGLWidget that uses osgRenderer(osgViewer::Viewer) can't be directly merged via a PR, but maybe these can provide useful for later development.

https://github.com/unelsson/openmw/tree/osgqopengl_2/extern/osgQt

Example use code (not minimal example...) https://github.com/unelsson/openmw/blob/2bb606b31d0fbed3919ff6d393c14a15e8a36c3a/apps/opencs/view/render/scenewidget.cpp#L78

unelsson avatar Dec 02 '20 17:12 unelsson

Here is a more minimal example of CompositeOSGRenderer use. The example osgViewerQt_CompositeViewer.cpp aims to emulate and test osgViewer::CompositeViewer with Qt5's windows/widgets, especially test QOpenGLWidget inside floating QDockWidget.

I think something like this should eventually get to osgQt codebase, but it should be somehow compatible with OSGRenderer and QOpenGLWidget and QOpenGLWindow (not just separate versions of them). Any suggestions on this? And how complete should the feature be before making a PR?

https://gitlab.com/unelsson/osgqt_tests/-/tree/master

unelsson avatar Dec 04 '20 21:12 unelsson

This a access to the OpenGL graphic context issue. Drawing needs to happen in Qt's main thread. Composite Viewer will create threads for rendering, and those will need a valid GC (which they won't because of Qt)

mathieu avatar Apr 01 '21 09:04 mathieu