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 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

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

    Default Re: Mulitple openGL windows

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

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

    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

  4. #4
    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.

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

    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()?

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

    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.

  7. #7
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    In resizeGL I don't call updateGL. Doesn't that happen automatically?
    The thing is when only one window is open and I resize it, it is updated correctly. It only happens when I have 2 (or more presumably) windows open.

    No I don't call makeCurrent before calling updateGL. That shouldn't be necessary though since the correct context is always guarrenteed current in paintGL.

    Also I'm using multiple QMainWindows for each of the frames housing my QGLWidgets. Is that possibly related to the problem?

    Travis

  8. #8
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    Essientially my app is going to be a graph of a power grid where you are able to see the power flowing through the various lines. What I want is to be able to click a button on the toolbar and pop up another view of the system (with different settings).
    So I have the first 'main' window which other windows will be created from. Now when I start two of theses windows from my main function everything appears to work correctly. However when i create a new window from within the first 'main' window (after a toolbar button click for example) i encounter the problems i mentioned before. And it is the exact same code as was used in the main function.

    Any ideas?
    Travis

  9. #9
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    Actually I take that back it doesn't appear to work even when the code is just in my main function.

    Travis

  10. #10
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    It seems that multiple QFrame based windows works fine, but the QMainWindow doesn't.
    Any ideas?

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

    Default Re: Mulitple openGL windows

    Unfortunately, I can only speculate. I suspect that you may be running into problems through the use of multiple QMainWindows. Generally, you'd only want one of those. Might I suggest sticking your OpenGL windows into a QWorkspace, contained within a single QMainWindow? This would allow you to move the windows around inside the application, which may or may not be desirable. It also provides an easy way to add or remove OpenGL views (again, may or may not be desirable in your application).

    If you don't want to use a QWorkspace to contain each QGLWidget, just use a QWidget for each QGLWidget (adding whatever else you need to the QWidget). You shouldn't need multiple QMainWindows.
    Life without passion is death in disguise

  12. #12
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Mulitple openGL windows

    Yeah that is probably the way this will have to go. Thanks for your help.

    One last question.
    I've also got a QPopupMenu set up as a right click menu on my openGl widgets however after the user selects an option on the popup menu (or clicks elsewhere to get rid of it) the openGL only renders under the portion of the screen where the popup menu had been.
    Similarly this happens when I drag another window over my openGL widget, the openGL only seems to render under the area which was 'covered up' before.
    This is happening with QT's openGL examples as well.
    Is there a way aroudn this?

    Thanks,
    Travis

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.