Results 1 to 2 of 2

Thread: rendering hidden QGLWidgets to disk

  1. #1
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default rendering hidden QGLWidgets to disk

    Hi all!
    I want to render some OpenGLimages on a QGLWidget and then save them to disk using get_buffer() to grab the image to a QImage.
    Ideally I would like the image not to be visible to the user while rendered , so I call hide() on the GL widget before doing the render, but then it seems that no OpenGL stuff is rendered because the resulting image is blank. Also, if the image is bigger than the screen, only the part that is within the screen limits gets rendered and the rest gets blank.
    Is there any way to overcome this and force QGLWidget to render even in parts where it is not visible?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: rendering hidden QGLWidgets to disk

    Hi,

    Do it on a buffer, not directly to the display. Take a look at Qt OpenGL examples that use buffers. You can render the image into the buffer and then grab it to a QImage.
    If you want to display the image using all the space of the viewport you will have to tell openGL the magnification and minimization filters:

    Qt Code:
    1. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    2. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    To copy to clipboard, switch view to plain text mode 
    This code defines the magnification and minimization filters that will be applied to the image to full display.
    Òscar Llarch i Galán

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.