Results 1 to 8 of 8

Thread: QGLWidget, QPainter and shared contexts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget, QPainter and shared contexts

    You can either report a bug and/or try to reuse the same texture for a new pixmap (I understand the problem is that the pixmap changes which causes memory usage to grow) and draw directly using GL code.

  2. #2

    Default Re: QGLWidget, QPainter and shared contexts

    Thanks,

    I reported a bug to trolltech last week about that.
    But I can't reuse the same GL texture as I don't have access to it.
    For now i just don't use a QPainter to draw on QGLWidgets. I draw everything I need in an offscreen QPixmap and then use my own code to upload and draw it with OpenGL.

    I'll post here references to the bug I reported if any are interested.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget, QPainter and shared contexts

    What do you mean you don't have access to it? So what calls BindTexture()?

  4. #4

    Default Re: QGLWidget, QPainter and shared contexts

    Qt does.
    I never dealt directly with OpenGL. I just used the QPainter and drawPixmap().
    Internally drawPixmap() creates GL textures for each of my QPixmap and store them in the cache. Whenever a QPixmap is modified, a new GL texture is associated to it. When the cache hits its size limit, Qt deletes GL textures but as my GL context is shared, glDeleteTexture() is never called (but the Qt wrapper around GL textures is deleted from the cache).

    Basically this is what I was doing :

    Qt Code:
    1. void draw_overlays(QGLWidget *p_GL)
    2. {
    3. QPainter l_Painter(p_GL);
    4.  
    5. // my overlays are QPixmaps
    6. // some of them can be updated often
    7. for_each_of_my_overlays()
    8. {
    9. // this will internally create a GL texture for the QPixmap
    10. // reusing the texture if the QPixmap is the same (cache system)
    11. l_Painter->drawPixmap(l_Overlay);
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    I hope I'm clear enough

    edit: I think I understand what you mean. I don't use QGLWidget::bindTexture() neither QGLContext::bindTexture() but I noticed in the docs that if the context is shared the GL texture won't be destroyed. But in my case, Qt creates GL texture, not me.
    Last edited by bamboo; 16th April 2007 at 10:46.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget, QPainter and shared contexts

    Ok, but this is an overlay. You do have some actual GL code underneath. So you can make a plane, place it orthogonal to the screen and instead of using QPainter simply apply a texture to the plane.

  6. #6

    Default Re: QGLWidget, QPainter and shared contexts

    Yep, that's what I do now to overcome this
    But using QPainter would have been "cleaner" and easier for me as it is designed fot this.
    Anyway I reported the bug to Trolltech as I don't think this is a normal behavior ...
    Thanks !

  7. #7

    Default Re: QGLWidget, QPainter and shared contexts

    Hi again,

    for those who might be interested, the bug has been verified by Qt's team and has been assigned #158971.
    http://www.trolltech.com/developer/t...ntry&id=158971

    Have a nice day !

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.