[Qt-interest] invalid drawable with Cocoa/QGLWidget
Alan Norton
alan at ucar.edu
Thu Feb 25 23:27:40 CET 2010
Karl,
InitializeGL() does get called, well before the "invalid drawable"
message. I think that the problem is that initializeGL gets called too
early, before the window can be displayed. In Cocoa, the context needs
to get enabled at a time when the window can be drawn. I think I need
to postpone the initializeGL and other OpenGL preparation until the
window is ready to display. Unfortunately I don't know how to do
that. Qt tries to use the GL context when the containing widget is
first drawn, even though the QGLWidget is not visible, which results in
the error.
-Alan
On 2/25/10 1:16 PM, Karl Merkley wrote:
>
> On Feb 25, 2010, at 11:46 AM, Alan Norton wrote:
>
>> Thanks, Oliver.
>> I have a bit more information. This problem seems to only occur if the
>> qglwidget is not visible when it first gets a paintEvent(). In my
>> example the qglwidget is scrolled out of view when its containing widget
>> first is shown. I suspect that Qt is creating the OpenGL context right
>> before or right after the containing widget gets the first paintEvent(),
>> but I don't know how to intercept this before it fails.
>> -Alan
>> Oliver.Knoll at comit.ch wrote:
>>> Alan Norton wrote on Thursday, February 25, 2010 6:03 PM:
>>>
>>>
>>>> With Cocoa on Mac OSX10.5, I get a message "invalid drawable" (and a
>>>> defective image) whenever my QGLWidget redraws.
>>>>
>>>
>>> I can confirm that I use a QGLWidget with Qt 4.6 binary build Cocoa
>>> on Mac OS 10.6.2 without problems :) I know, that is little help to
>>> your problem, but it might make the "future" a bit brighter ;) (and
>>> be a strong hint that the problem really seems to be in the GL
>>> driver shipped with Mac OS 10.5 or wherever, assuming that you are
>>> also using the latest Qt 4.6.x).
>>>
>>> The stuff which is drawn is admittedly very simple: 2 triangles with
>>> a texture on it, using Qt shader programs (so basically I draw a
>>> "photo" ;)
>>>
>>> Cheers, Oliver
>>>
>
>
> You must make sure that initializeGL is called prior to making any
> OpenGL calls. If your window isn't being displayed it may be a
> timing problem with when the initialize is called.
>
> Karl
>
>
>
>
>
More information about the Qt-interest-old
mailing list