Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [SOLVED]Same Texture Different QGLContext/QGLWidget
QtWS25 Last Chance

[SOLVED]Same Texture Different QGLContext/QGLWidget

Scheduled Pinned Locked Moved Game Development
3 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sapidol2002
    wrote on 29 Jul 2011, 18:05 last edited by
    #1

    hi
    I'm currently working for my final Assessment

    so here the situation
    I build three difference QGLWidget Class which has different function and purpose
    Let say I have
    GLWidgetLayer, GLWidgetImage, GLWidgetPreview

    each QGLWidget class render different object and geometry
    when I want to load Texture using bindTexture in GLWidgetLayer object and save TextureID in global variable

    how can I use the same texture in object GLWidgetImage / GLWidgetPreview
    without call bindTexture again?
    so I don't waste texture that already loaded in GLWidgetLayer

    I have read about share context between QGLContext using chooseContext and QGLWidget Contructor
    but I don't understand, how to use it, and can it solve my problem

    Thanks,
    Sapidol2002

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VitorAMJ
      wrote on 2 Aug 2011, 12:42 last edited by
      #2

      MAybe what you are trying to do is something like this.

      The QGLWidget constructor:
      @QGLWidget ( QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )@

      It includes a call to a sharing context widget. The only thing you need to do is to make your GL instance with a constructor similar to this one, like:
      @GLClass::GLClass(QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0)
      : QGLWidget(parent, shareGLWidget)
      {

      }@

      Finally:
      @ secondGLWidget= new SideWidget(this); //some QGLWidget instance...
      firstGLWidget = new GLClass(this, secondGLWidget); //QGLWidget that shares context w/ anotherQGLWidget@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sapidol2002
        wrote on 2 Aug 2011, 16:12 last edited by
        #3

        yes it's work!
        now I can loadTexture from secondGLWidget
        and then use it in firstGLWidget

        Thank you very much.

        1 Reply Last reply
        0

        1/3

        29 Jul 2011, 18:05

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved