Hi,
I need to grab only my QGLWidget. but grabWidget take only QWidget?
This below grab only a gray square!
Is there a way or I must use grabWindow?Qt Code:
To copy to clipboard, switch view to plain text mode
Hi,
I need to grab only my QGLWidget. but grabWidget take only QWidget?
This below grab only a gray square!
Is there a way or I must use grabWindow?Qt Code:
To copy to clipboard, switch view to plain text mode
Regards
Use QGLWidget::renderPixmap().
the problem of this function is that (I read) will start initalizeGL, paintGL() etc...and after this call my contextGL() changes! There are some problem. I don't know if are there ways to avoid this...
I tried use grabWindow.it grab all widget are on my interest widgetBut very problem of this is that it grab also a QMessageBox::warning that is launched a bit before of grabbing. How can I avoid this?
Thanks
Regards
Why do you want avoid this? If you implement these methods properly you shouldn't have any problems.Originally Posted by mickey
In Qt3 QGLWidget bypasses the Qt painting engine, so you must use QGLWidget::renderPixmap(). You can also try to make a screenshot.Originally Posted by mickey
my texture are destroyed after renderPixmap! If I use grabWindow this not happen.....Originally Posted by jacek
Regards
How do you initialize those textures?Originally Posted by mickey
yes, in initalializeGL()
Regards
But how do you initialize those textures?Originally Posted by mickey
Qt Code:
//initializeGL() per.myinitGL(); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glDisable(GL_TEXTURE_2D);To copy to clipboard, switch view to plain text modeIs it ok? It seems works properly....Qt Code:To copy to clipboard, switch view to plain text mode
Regards
Every time initializeGL() is called, per.myinitGL() will overwrite the tex variable. Maybe it will be enough, if you check whether initializeGL() is called for the first time and only then call per.myinitGL()?Originally Posted by mickey
What is that "per" object?
'per' is my object on I put texture...a square; Are you saying me that when I call renderpixmap(), initializeGL() starts and tex is overwrite? (But tex should be the same before......).
But what is the advantage for renderPixmap() of re-call initializeGL and PaintGL()? Isn't it a time lose?
Regards
Your initializeGL() must be written in such way that it can be called multiple times and you must make sure that after renderPixmap() you restore the previous state. For example if you create textures in initializeGL() then after renderPixmap() you should use old texture ids.QPixmap QGLWidget::renderPixmap ( int w = 0, int h = 0, bool useContext = FALSE ) [virtual]
Renders the current scene on a pixmap and returns the pixmap.
[...]
This method will create a pixmap and a temporary QGLContext to render on the pixmap. It will then call initializeGL(), resizeGL(), and paintGL() on this context. Finally, the widget's original GL context is restored.
[...]
If useContext is TRUE, this method will try to be more efficient by using the existing GL context to render the pixmap. The default is FALSE. Only use TRUE if you understand the risks.
Overlays are not rendered onto the pixmap.
If the GL rendering context and the desktop have different bit depths, the result will most likely look surprising.
Note that the creation of display lists, modifications of the view frustum etc. should be done from within initializeGL(). If this is not done, the temporary QGLContext will not be initialized properly, and the rendered pixmap may be incomplete/corrupted.
You can also try to reuse the constext (see the docs), but pixmap may have a different colour depth than the screen.
Hi, the problem wasn't renderPixmap() ( that calls initializeGL() and paintGL().
renderPixmap() starts when I save my scene; it works properly if I simple save (without open saveDialogFile). If saveDialogFile starts and I click 'ok' button my contextGL broke;
It's strange.....
Regards
Bookmarks