PDA

View Full Version : rendering hidden QGLWidgets to disk



trskel
8th February 2008, 12:44
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

^NyAw^
8th February 2008, 14:58
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:



glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

This code defines the magnification and minimization filters that will be applied to the image to full display.