Results 1 to 20 of 20

Thread: Mulitple openGL windows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    10

    Default Mulitple openGL windows

    Hello,

    I'm writing an app where I need multiple openGL windows running. This windows are created dynamically by the user. The problem is as soon as the second window opens the first stops processing mouse events and never repaints. The second window works fine but the first stops. I'm hoping this is just something stupid i've done wrong and there is an easy fix.
    Any ideas?
    Travis

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    Could you post the code that opens that new window?

  3. #3
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    CGraphContainer* tmp = new CGraphContainer(); tmp->GetGraph()->SetPowerSystem(m_graph->GetPowerSystem());
    tmp->GetGraph()->ConnectToServer("dell1.cs.umr.edu", 1208);
    tmp->GetGraph()->SetHistory(m_graph->GetHistory());
    tmp->show();
    m_graphList.append(tmp);

    CGraphContainer extends QMainWindow and is pretty basic just creates a new CGraph object which extends QGLWidget.

  4. #4
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    Well, it works fine when I have two separate instances of the application running, just not when I have two windows within the same app.

    Travis

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    Quote Originally Posted by tcsvw5
    CGraphContainer* tmp = new CGraphContainer(); tmp->GetGraph()->SetPowerSystem(m_graph->GetPowerSystem());
    tmp->GetGraph()->ConnectToServer("dell1.cs.umr.edu", 1208);
    tmp->GetGraph()->SetHistory(m_graph->GetHistory());
    tmp->show();
    m_graphList.append(tmp);
    There's nothing suspicious here. Maybe you block the event loop somewhere? Do you return from the method that shows that new window?

    Which Qt version do you use?

  6. #6
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Mulitple openGL windows

    I doubt there's anything wrong with your constructor. I ran into something similar with my MDI OGL app. Look at your input processor. Make sure you call updateGL() at the end - it will make that window's OpenGL context the current device context, then update that window. Remember, it will only update when you tell it to update. You either go with event-based updates (preferred) or timer-based updates. Your other window will use the same function (I'm assuming) and work accordingly.

    Also, if you don't need to update the display, but you do need data from it, use the makeCurrent() function to make your QGLWidget's device context the current context.
    Life without passion is death in disguise

  7. #7
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    I am using Qt 3.2.1 and both windows have a timer based update scheme every 100ms if needed. The odd thing is that sometimes for a short period of time both windows operate together correctly but eventually the first window stops working.

    Travis

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    How do you trigger the updates? Do you use QTimer?

  9. #9
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Mulitple openGL windows

    Then what you need to check is your timer function. Make sure it calls your QGLWidget's updateGL() function on every timer interrupt. I'm 99.9% sure this is what you're running into based on those symptoms.
    Life without passion is death in disguise

  10. #10
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    Yes, I'm using a QTimer to handle this, and it does call updateGL appropriately.
    When i break into paintGL both objects get rerendered, however the first qglwidget remains black. This seems to always happen after I resize the first window. Up until then it works fine (handles mouse events; drags the display), but one I resize that first window it goes blank. The second window however works great, no problems.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    Quote Originally Posted by tcsvw5
    This seems to always happen after I resize the first window.
    What do you do when that widget is resized? Did you reimplement the resizeEvent()?

  12. #12
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    Do you call makeCurrent ?
    I have the same problem one day, and the solution is to call makeCurrent in the QGLWidget before updateGL.

  13. #13
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Mulitple openGL windows

    As far as i understand only one 3d accelerated window can be active at a time.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mulitple openGL windows

    Quote Originally Posted by yogeshm02
    As far as i understand only one 3d accelerated window can be active at a time.
    This shouldn't be a problem. See opengl/textures example.

Similar Threads

  1. OpenGL and Qt Question
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2009, 18:04
  2. Replies: 5
    Last Post: 15th January 2009, 09:03
  3. QtWidget in Overlay Planes on Windows OpenGL
    By IVTdeveloper in forum Qt Programming
    Replies: 2
    Last Post: 20th August 2008, 11:00
  4. Qtopia Core & OpenGL ES?
    By zelko in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th May 2007, 07:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.