qt-interest@trolltech.com
[Top] [All Lists]

Re: synchronizing of two widgets

Subject: Re: synchronizing of two widgets
From: Jordi Massaguer Pla
Date: Tue, 15 Mar 2005 17:14:20 +0100
Are you trying to render a window with the right eye perspective and another with the left eye perspective? (HMD is Head Mounted Display?)

I once was working on that too. So, what you want is to render the same scene with a small different perspective but synchronized, right? I mean, that when one scene is transformed, the other should be, too.

Each window has its own scene, as each window has it own WidgetGL object. A WidgetGL object has the openGL commands for rendering a scene ( look at the docs, please).

Well, that said, if you send the same events to both windows, they will get synchro, right? How to achieve this? There are different ways. You can get the events (QEvents) in one window and send them to the other; or you could call the functions that are called by the events; or you could have one window and two WidgetGL objects side-by-side, and connect the signals to the slots of both objects (signals are emited when an event is "received" by an object ( see the docs ) ).

How are you going to connect the PC to the HMD? Some time ago, I saw that nvidia had some special graphics card that, if you render one scene using opengl, it renders two scenes, one with the right eye perspective and one with the left eye perspective, and they are rendered in two different monitors.

I hope my guidelines help you to know which docs to look for ;)

good luck,

Jordi

Hick Reichelt wrote:

Thank you verry much for the code,

I have tried it and it generates me an error, and with "GLObjectWindow w2" alone, without (w), two stand-alone applications are generated, without synchronisation.

But I think, it would be better, to draw in an newView-Function a new GLObject, which only show one opengl-output, without the sliders.

So I read in the tutorials and I have made another attempt, which looks like

void GLObjectWindow::newView() //to add the HMD-View
{
GLObjectWindow *w = new GLObjectWindow( this, "newView" );
qApp->setMainWidget(w);
w->show();
qApp->setMainWidget(0);
}

But also with this code, it does not show two synchronized application.

Just for me, to check if I have understand the tutorials:

the new GLObjectWindow w owns form "this", what means, w becoms from the actual Widget all the commands but also the variables such as c1, and c2?

What you think to make a own class, as another atempt?

like:

void Fenster::pbStart_clicked()
{
   independentView = new Viewer(this, "Renderfenster");
   independentView->show();
}

and the class Viewer is defined as,

class Viewer : public QGLWidget
{
public:
   Viewer(QWidget *parent, char *name );
protected:
    void initializeGL();
    void resizeGL( int width, int height );
    void paintGL();
}

And also just for a controll:

"public" means, I can call Viewer, like I have done in the declaration of independentView and protected means, that this functions are only accessible by independentView

Thank you verry much for help




Am 15.03.2005 um 14:18 schrieb Jordi Massaguer Pla:

    Hick Reichelt wrote:

        Good morning,

        Why gives me this changed code from the main of Shared Box not
        two widget out?


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

        QApplication::setColorSpec( QApplication::CustomColor );
        QApplication b(argc,argv);

        if ( !QGLFormat::hasOpenGL() ) {
        qWarning( "This system has no OpenGL support. Exiting." );
        return -1;
        }

        GLObjectWindow w;
        w.resize( 800, 600 );
        a.setMainWidget( &w );
        b.setMainWidget( &w );
        w.show();
        return a.exec();
        return b.exec();
        }


    You are trying to start two *applications* at a time. I do not
    think you can do that, as you only have one event-loop ....
    moreover, when you do "return a.exec()" this will make your main
    end after application "a" finishes. Again, I do not thing you can
    do such a thing without *forking*, that is, without really having
    two applications.

    If I am understanding what you are trying, what you need is two
    *GLObjectWindow*s. Something like this:

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

    if ( !QGLFormat::hasOpenGL() ) {
    qWarning( "This system has no OpenGL support. Exiting." );
    return -1;
    }

    GLObjectWindow w;
    GLObjectWindow w2(w);
    w.resize( 800, 600 );
    w2.resize(800,600);
    a.setMainWidget( &w );

    w.show();
    w2.show();
    return a.exec();

    }


    And please, before copying and pasting code, try to understand it!

    jordi




-- List archive and information:
        http://lists.trolltech.com/qt-interest/



-- List archive and information: http://lists.trolltech.com/qt-interest/



--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>