Results 1 to 9 of 9

Thread: Textures + Multiple QGLWidgets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Textures + Multiple QGLWidgets

    Hmm... if that's really all you're doing, I think you're going about it in the wrong way. When you subclass QGLWidget, note that there are multiple constructors available. Specifically, there is a pointer to a "shareWidget" (docs) in all the constructors. What you do is have a central QGLWidget to pass to all your other QGLWidget sub-classes which will share texture memory and display lists.

    In my case, I created what I call a "hidden viewport" - Basically a viewport that always exists (even if there are no visible OpenGL widgets in existence) whose only purpose is to be the place to centrally store all the textures and display lists and share them out to the other widgets. Just pass a pointer to this widget right after you give a parent to your GLWidget and you should be set. Here's a short example:
    Qt Code:
    1. QGLWidget * hiddenViewPort = new QGLWidget(this);
    2. myViewPort * mvp = new myViewPort(this, hiddenViewPort);
    To copy to clipboard, switch view to plain text mode 
    Now all the textures and display lists are shared between these viewports. Do the same with any future viewports and you should be set. Just be careful that they have compatible formats (see the docs link above).
    Life without passion is death in disguise

  2. #2
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Textures + Multiple QGLWidgets

    Let me see if I understand your suggest and say what I understand of Qt & GL.

    As I see, when I load my texture to the texture memory, it becomes available to the first QGLWidget what is created, and for that reason the others widgets can't access to the memory texture as the first one does, right?

    What you propose is to create a first GLWidget with that "privilege" of accessing the texture memory and passes it as the shareWidget parameter to the others widgets (which displays some stuff) and to share with them that "privilege", right?

    Following what you posted, I did this:

    Qt Code:
    1. QGLWidget *central = new QGLWidget(this);
    2. . . .
    3. wVolume = new Rendering(mainWidget, central);
    4. wPlane1 = new Rendering(frame1, central);
    5. wplane2 = new Rendering(fram2, central);
    6. . . .
    To copy to clipboard, switch view to plain text mode 

    where mainWidget is the main window of my app, and frame1 and frame2 contain wPlane1 and wPlane2 respectively.

  3. #3
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Textures + Multiple QGLWidgets

    I started a new thread (before find this one). It is "Share a 3D texture in four QGLWidgets" where there is more information about the problem. Can you move to that thread? There are already some replies.

  4. #4
    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: Textures + Multiple QGLWidgets

    I'm posting further replies in the topic you mentioned
    Life without passion is death in disguise

Similar Threads

  1. Opengl - Textures - Qt
    By Alex63 in forum Installation and Deployment
    Replies: 1
    Last Post: 29th June 2006, 09:32
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23
  3. Multiple shortuts for the action
    By Lemming in forum Qt Programming
    Replies: 6
    Last Post: 6th April 2006, 22:29
  4. Replies: 25
    Last Post: 15th January 2006, 00:53

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.