[Qt-interest] invalid drawable with Cocoa/QGLWidget
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Fri Feb 26 10:44:54 CET 2010
Karl Merkley wrote on Thursday, February 25, 2010 9:16 PM:
> ...
> You must make sure that initializeGL is called prior to making any
> OpenGL calls.
That is not entirely true, as long as you make sure that you explicitly call makeCurrent() in the method where you want to call OpenGL functions. Qt makes sure that this is already the case (that the OpenGL context is made "current") for the methods initializeGL(), paintGL() and resizeGL(), so it is not necessary there.
Besides, initializeGL() is called before the first call to paintGL and resizeGL(), so I don't know any good use-case where you would want to initialize OpenGL stuff, other than in the initializeGL() method.
However, the following should work:
// c'tor
MyQGLWidget::MyQGLWidget(...)
{
this->doOpenGLStuff();
...
}
void MyQGLWidget::doOpenGLStuff()
{
// make the GL context current first
this->makeCurrent();
glWhatever(x, y, z);
...
}
But again, I would not know why one would want to do such stuff (and not in the initializeGL() method).
> If your window isn't being displayed it may be a
> timing problem with when the initialize is called.
I understood that at the time when the QGLWidget receives the first paint event it is not visible, because it is in some QScrollArea and outside of the viewable area. And that seems to be a problem with Cocoa and Mac OS 10.5 (10.6?).
Anyway, it can't be a "timing" problem because Qt makes sure that initializeGL() is called before any call to resizeGL() or paintGL(). See my other post.
So a possible solution could the to make sure that the QGLWidget does *not* receive a paint event, in that the parent "container" widget evaluates the rectangle to be drawn and only repaints this rectangle (only those widgets which are partly or fully visible in that rectangle). Maybe that helps.
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list