Results 1 to 15 of 15

Thread: old problem with QGLContext and render pixmap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default old problem with QGLContext and render pixmap

    hi, I have an old problem with render pixmap; after gen pixmap called, my textures are destroyed and I can't understand why.
    Qt Code:
    1. //inside a member of mainForm class
    2. qp = myWidget1->renderPixmap(800, 600, FALSE);
    3. qi=qp.convertToImage();
    4. qi = qi.smoothScale(500,500);
    5. qi.save(base_file+".png","PNG");
    To copy to clipboard, switch view to plain text mode 
    I know render pixmap do this: create a new contextGL call initializeGL(), resizeGL() an PaintGL(); after, it restore the previous context; but the previuos context is broken..also pixmap doesn't appear realistic: some textures are broken; but the texture broken on the final image image.jpg) and image on widgetGL aren't the same...
    I tried to do:
    Qt Code:
    1. myWidget1->initializeGL();
    2. myWidget1->resizeGL(myWidget1->width(), myWidget1->height());
    3. myWidget1->paintGL();
    To copy to clipboard, switch view to plain text mode 
    I thought this can see to me if some error in contextGL; but these 3 instrucion don't change the image in QGLWIdget....
    After this, if I put a new texture on my image (ie on one object, so that call every gl function that initialize texttures), the prevoius context is restored and every textures are in the right place)
    Help me, please; thanks
    Last edited by mickey; 14th July 2006 at 00:24.
    Regards

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

    Default Re: old problem with QGLContext and render pixmap

    If I remember well, in initializeGL() you create new textures and store their IDs in member variables. If you call initializeGL() from a different context, you will loose information about textures from previous one. You must find a way to preserve those IDs between contexts (for example copy them somewhere or keep them on a stack).

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: old problem with QGLContext and render pixmap

    sorry, I don't understand good but how copy it on the stack; thanks
    Regards

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

    Default Re: old problem with QGLContext and render pixmap

    Quote Originally Posted by mickey
    I don't understand good but how copy it on the stack
    If you have something like:
    Qt Code:
    1. void GlWidget::initializeGL()
    2. {
    3. ...
    4. _textureId = generateTexture();
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    then each time you invoke initializeGL() you will loose the previous value of _textureId member variable.

    You can avoid that like this:
    Qt Code:
    1. void GlWidget::renderPixmap(...)
    2. {
    3. int oldTextureId = _textureId;
    4. QPixmap result( QGLWidget::renderPixmap( ... ) );
    5. _textureId = oldTextureId;
    6. return result;
    7. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: old problem with QGLContext and render pixmap

    sorry but I can't understand what's the textureID; but after I call genPixmap (now I put It inside myWidget class and don't change everythings), I call updateGL(),and everythings appear as before; then I think my way to put texture is ok.; i think is only a context problem....could you explain better what do you want to do with saving this texture ids?? thanks
    Regards

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

    Default Re: old problem with QGLContext and render pixmap

    Quote Originally Posted by mickey
    could you explain better what do you want to do with saving this texture ids??
    Could you post your initializeGL()? I might not remember your program well.

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: old problem with QGLContext and render pixmap

    take it. thanks
    Attached Files Attached Files
    Regards

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

    Default Re: old problem with QGLContext and render pixmap

    What does plain.initGL() do?

  9. #9
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: old problem with QGLContext and render pixmap

    it initialize every textures....gen tex, bind....plain it's an object and onto this I put the texture...
    Regards

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

    Default Re: old problem with QGLContext and render pixmap

    Quote Originally Posted by mickey
    it initialize every textures....gen tex, bind....
    That's the place where the problem is. Can I see it?

  11. #11
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: old problem with QGLContext and render pixmap

    it's very complicated. Can I mail it you? thanks
    Regards

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.