Results 1 to 5 of 5

Thread: Whats the difference in sharing a QGLContext and sharing a QGLWidget

  1. #1
    Join Date
    Aug 2007
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Whats the difference in sharing a QGLContext and sharing a QGLWidget

    Hi,
    In the QGLWidget constructor
    Qt Code:
    1. QGLWidget::QGLWidget ( QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )
    To copy to clipboard, switch view to plain text mode 

    How is sharing a QGLContext different from sharing a QGLWidget? It seems to me that passing in a context is the same as sharing a widget. The shared widget and the newly constructed QGLWidget will be sharing the same context any way. So, why is there the option to pass in a context?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Whats the difference in sharing a QGLContext and sharing a QGLWidget

    What do you mean when you say "sharing a QGLWidget"?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2007
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Whats the difference in sharing a QGLContext and sharing a QGLWidget

    When creating a QGLWidget you can pass its constructor a pointer to another QGLWidget to mutually share a context.
    Qt Code:
    1. QGLWidget::QGLWidget ( QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )
    To copy to clipboard, switch view to plain text mode 

    What does it mean to pass in a QGLContext and another QGLWidget, as in the following constructor.
    Qt Code:
    1. QGLWidget::QGLWidget ( QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Whats the difference in sharing a QGLContext and sharing a QGLWidget

    Here is what the docs say, maybe you can ask specifically what it is you don't understand in the following (for a shared QGLWidget):
    If shareWidget is a valid QGLWidget, this widget will share OpenGL display lists and texture objects with shareWidget. But if shareWidget and this widget have different formats, sharing might not be possible. You can check whether sharing is in effect by calling isSharing().
    And a context is:
    An OpenGL rendering context is a complete set of OpenGL state variables.

    As you can see, sharing openGL "resources" (as shared QGLWidget) and sharing "rendering state variables" is not the same.

    Did I help you?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. The following user says thank you to high_flyer for this useful post:

    Wali (17th October 2009)

  6. #5
    Join Date
    Aug 2007
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Whats the difference in sharing a QGLContext and sharing a QGLWidget

    Ok I think I understand thanks.

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.