+
+ XVisualInfo *vi = NULL;
+ if (wxTheApp->m_glVisualInfo != NULL)
+ {
+ vi = (XVisualInfo *) wxTheApp->m_glVisualInfo;
+ m_canFreeVi = FALSE; // owned by wxTheApp - don't free upon destruction
+ }
+ else
+ {
+ vi = (XVisualInfo *) ChooseGLVisual(attribList);
+ m_canFreeVi = TRUE;
+ }
+ m_vi = vi; // save for later use
+
+ wxCHECK_MSG( m_vi, FALSE, _T("required visual couldn't be found") );
+
+ GdkVisual *visual = gdkx_visual_get( vi->visualid );
+ GdkColormap *colormap = gdk_colormap_new( visual, TRUE );
+
+ gtk_widget_push_colormap( colormap );
+ gtk_widget_push_visual( visual );
+
+ wxWindow::Create( parent, id, pos, size, style, name );
+
+ m_glWidget = m_wxwindow;
+
+#ifdef __WXGTK20__
+ gtk_widget_set_double_buffered( m_glWidget, FALSE );
+#endif
+
+ gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
+ GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map",
+ GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
+
+#ifndef __WXGTK20__
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+ GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
+#endif
+
+ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
+ GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
+
+ gtk_widget_pop_visual();
+ gtk_widget_pop_colormap();
+
+ return TRUE;
+}
+
+wxGLCanvas::~wxGLCanvas()
+{
+ XVisualInfo *vi = (XVisualInfo *) m_vi;
+
+ if (vi && m_canFreeVi) XFree( vi );
+ delete m_glContext;
+}
+
+void* wxGLCanvas::ChooseGLVisual(int *attribList)
+{
+ int data[512];