Hi, OpenGL rendering with Qt is kind of tricky. Qt wants to render from the main thread, while OSG performs much better with threading enabled. We have a working application with OSG 3.0.1, but it doesn't work anymore with OSG 3.1.2. I still need to investigate that. Qt also has improved OpenGL rendering from a different thread in Qt 4.8, so that might be worth investigating as well.
I did a google search on the topic a while ago and collected usefull information: http://web.nghk.nl/things-to-remember/qtandmultithreadedopenglrendering Bests, Nico On Fri, Sep 14, 2012 at 11:59 AM, Max Sergeev <[email protected]>wrote: > Hello! > > I'm stuck on one problem. > > There is kind of big project, and I need to make Qt interface on it. What > I try to do is make a camera for Qt-interface element. The problem comes > with using OpenThreads: I'm trying to run OSG rendering inside new thread, > yielding to rendering of Qt element, like in osgQtBrowser example. > First, I create class to handle thread creating: > > Code: > > class ViewerFrameThread : public OpenThreads::Thread > { > public: > > ViewerFrameThread(osgViewer::ViewerBase* viewerBase, bool > doQApplicationExit): > _viewerBase(viewerBase), > _doQApplicationExit(doQApplicationExit) {} > > ~ViewerFrameThread() > { > cancel(); > while(isRunning()) > { > OpenThreads::Thread::YieldCurrentThread(); > } > } > > int cancel() > { > _viewerBase->setDone(true); > return 0; > } > > void run() > { > int result = _viewerBase->run(); > > if (_doQApplicationExit) QApplication::exit(result); > } > > osg::ref_ptr<osgViewer::ViewerBase> _viewerBase; > bool _doQApplicationExit; > }; > > > > > Then I try to run my viewer using it: > > > Code: > > ViewerFrameThread frameThread(m_viewer.getViewerBase()); > frameThread.startThread(); > return QApplication::exec(); > > > > > And here comes problem: if I use "frameThread.startThread()" like in > example, my project gives me access violation, like every try in new place. > Otherwise, if I use "frameThread.run()", everything runs OK but Qt button > isnt getting rendered (just a white block in the corner of the screen) > > I've tried to make a simply application with just model and Qt-button, and > everything works fine with ".startThread()", as button doesnt get rendered > with ".run()" same as in my big project. Could not find any documentation > of OpenThreads. :( > > So the question is, like: is it possible to render Qt thingy with > ".run()", or what can possibly cause Access Violation with ".startThread()"? > > I'm sorry if the explanation wasnt very clear, though hopefully someone > can help :) > Thanks in advance! > > Cheers, > Max > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=50049#50049 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Nico Kruithof nghk.nl
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

