Hi Martin,

in reference to my submission here:
http://forum.openscenegraph.org/viewtopic.php?p=54555#54555

as I said, I simply submitted Vitezslavs patch. I can certainly try to remove 
the extra hooks from the osg main classes.
The moveToThread command must be called with the Qt widget and the Qt graphics 
thread before makeCurrent is called the first time.
Maybe there is a way to achieve multithreaded rendering in a non-intrusive way by simply calling both new members (moveToThread and moveBack) from GraphicsWindowQt itself. We could overload GraphicsContext::setGraphicsThread and GraphicsContext::releaseContextImplementation with something like this:

void GraphicsWindowQt::setGraphicsThread(osg::GraphicsThread* gt)
{
    if (gt)
    {
        moveToThread(gt);
    }

    osgViewer::GraphicsWindow::setGraphicsThread(gt);
}

bool GraphicsWindowQt::releaseContextImplementation()
{
    existing stuff here ...

    // move context back to main thread
    if (_widget->context()->thread() != qApp->thread())
    {
        moveBack();
    }

    return result;
}

Of course, setGraphicsThread should be made virtual if not already.

Another thing I just realized: The code will only work when CMake option 
BUILD_OPENTHREADS_WITH_QT  is set! Otherwise the static_cast in 
GraphicsWindowQt::moveToThread will fail.
How can I solve this? For multithreading to work with Qt5 it seems we need the 
render threads to be QThreads. Maybe add a flag to OpenThreads/Config and 
#ifdef against that?

Flag is ok ... or maybe we could add new api to OT, an api that can return string like "qt", "win32", "pthreads", "sproc", "c++11"... , benign but useful ...

Robert Milharcic
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to