Hello everyone,

i have touble with the performance of my QT-Application (Qt 4.2, OSG
2.4.6). It embeds multiple osgViewers based on the the QGLWidget from
the svn. I would really appreciate some points in the right direction.

First of all i have to say that i've done this stuff already as a pure
GL implementation as well as a mix of QT-Gl which runs pretty well in
both cases. Trying to port the App to OSG though introduces some
trouble.

A side note: The aim is to have multiple views of independent scenes
in one QT app.  This is due to reasons of rising demand of modularity
(widgets for data models are easy to integrate) as well as reusability
of the gui elements of QT4, like menus and sliders. 

I experience degrading performance the more views are integrated into
the application. No memleaks though. The App runs in all cases at 5-10
% CPU max. which should (in my experience) actually rise at least a
little with the rising number of views.  The rendering definitly slows
down, and same for the event-handling (mouse inputs gettin jittery/
lost).

A quote in a similar matter:

> Re: [osg-users] Memory leaks with QT and multiple osg::Viewers
>
> Robert Osfield
> Tue, 12 Jun 2007 03:26:45 -0700
>
> First things first, GrpahicsWidowEmbedded only works with
> SingleThreaded mode.  If you want multi-threading then don't use QT
> for creating the windows.

Do i need multi-threading to render multiple independent views on the
OSG end ? Am i touching some common OSG component which makes me want
to use multi-threading. I think as long as i'm not sharing scenes in
multiple views i should be fine. My !OSG apps don't use
multi-threading and are running quite fine (derived QGLWidget using a
slot to pass a pointer to the raw-data and a call to updateGL (with a
datarate is about 50 fps)). 

Basically (after 2 days playing around) i have the feeling the event
queue handling (qt's or osg's) is responsible for the degraded
performance and it should be quite possible to do this right somehow
with a splendid performance.

Am i better off using the QGLWidget or the QWidget implementation of
the example if i want to implement this ? (couldn't get the QWidget
thing to run multiple views embedded in separate widgets)

Should i write a new Viewer class ? (something like Composite Viewer)
or 
Should i play with a shared osg-event-queue among the OSGQTWidgets
first ?

Since the documentation on the osg codebase is quite sparse i'm having
trouble to find a reasonable starting point without reading all the
code. 

Any ideas or/and recommendation are very welcome. 

Lukas


// Here's some quick-hack code to demonstrate the problem and play
// around a little. It's using the svn examples AdapterWidget.cpp of
// the OpenSceneGraph/examples/osgviewerQT.  Don't forget to build
// with -DUSE_QT4 since we're talking about qt4 here.

#include <QtGui/QApplication>
#include <QtGui/QtGui>
#include <QtGui/QWidget>

#include "AdapterWidget.cpp"

#include <vector>
#include <iostream>

using std::vector;
using std::cout;
using std::endl;

int main ( int argc, char **argv )
{
    QApplication a ( argc, argv );

    if (argc<2)
    {
        std::cout << argv[0] <<": requires filename argument." <<
std::endl;
        return 1;
    }

    osg::ArgumentParser arguments (&argc, argv);

    // load the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles
(arguments);

    if (!loadedModel)
    {
        std::cout << arguments[0] <<": No data loaded." << std::endl;
        return 1;
    }

    int nbCowsX = 2;
    int nbCowsY = 2;

    vector <QWidget*> vWidgets;
    vector <ViewerQT*> vViewers;
    QGridLayout *uiLayout = new QGridLayout ();

    for (int x=0;x<nbCowsX; x++)
        for (int y=0;y<nbCowsY; y++)
        {
            QWidget *tmpW = new QWidget ();
            ViewerQT* tmpV = new ViewerQT (tmpW);
            tmpV->setGeometry(0,0,200,200);
            tmpV->setCameraManipulator (new
osgGA::TrackballManipulator);
            tmpV->setSceneData (loadedModel.get ());
            uiLayout->addWidget (tmpW, x,y);
            vWidgets.push_back (tmpW);
            vViewers.push_back (tmpV);
        }

    QWidget w;
    w.setLayout (uiLayout);
    w.resize (nbCowsX * 200, nbCowsY * 200);
    w.show ();

    vector <ViewerQT*>::iterator it = vViewers.begin();

    for (;it < vViewers.end (); it++)
    {
        ViewerQT *t = *it;
        t->resize (200,200);
    }

    a.connect ( &a, SIGNAL (lastWindowClosed ()), &a, SLOT (quit ())
);

    return a.exec ();
}
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to