"Gtk-CRITICAL **: gtk_widget_set_colormap: assertion `!
GTK_WIDGET_REALIZED (widget)` failed"
A Google search indicates that this error shows up because the parent
control shouldn't be visible when the canvas is added. The GTK API
has this to say about calling gtk_widget_set_colormap:
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-set-colormap
Despite this warning, the wxGLCanvas appears and operates just fine.
However, another page on my search suggested hiding the parent widget,
adding the canvas, and then showing the parent again. I did this and
the GTK error went away. However, the redrawing of the canvas now has
a persistent white flicker that did not appear when I didn't Hide()/
Show() the parent control. I mimic all the code contained in the
OpenGL samples for my wxGLCanvas, and the flicker only appears if the
parent panel is hidden and then reshown.
Can anyone explain what might be different in the Hide()/Show()
interaction that results in this flicker? Or, can the GTK issue be
resolved in some way? Thanks for any help!
- Chris
[...]
> Despite this warning, the wxGLCanvas appears and operates just fine.
> However, another page on my search suggested hiding the parent widget,
> adding the canvas, and then showing the parent again. I did this and
> the GTK error went away. However, the redrawing of the canvas now has
> a persistent white flicker that did not appear when I didn't Hide()/
> Show() the parent control.
A further moment's consideration led to me investigate the attributes
I sent to the wxGLCanvas constructor. I had failed to add in
WX_GL_DOUBLEBUFFER, and I am silly. This fixes my problem now, and
the GTK issue has gone away thanks to calling Hide() and Show() on the
parent widget.
However, I have no idea why flashing did not occur when the GTK issue
was present. Looking in src/gtk/glcanvas.cpp, I see that right after
the gtk_widget_set_colormap call, a call is made to
gtk_widget_set_double_buffered(m_glWidget, FALSE). I presume this is
FALSE because X itself maintains the two buffers, and we don't want to
GTK to maintain its own. Perhaps the failure of the colormap call
causes the second call to have no effect, and my canvas is then double
buffered by GTK? Am I understanding correctly?
- Chris