X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b59bea3dd0a8df4eecb61862647572caab49690..d624fd67f82a90d74c7f796b241508663367134f:/utils/glcanvas/gtk/glcanvas.cpp diff --git a/utils/glcanvas/gtk/glcanvas.cpp b/utils/glcanvas/gtk/glcanvas.cpp index 811c0fcb80..68552f1b16 100644 --- a/utils/glcanvas/gtk/glcanvas.cpp +++ b/utils/glcanvas/gtk/glcanvas.cpp @@ -149,7 +149,30 @@ wxPalette wxGLContext::CreateDefaultPalette() static gint gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) { - win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, win->m_sharedContext ); + wxGLContext *share= win->m_sharedContext; + if (share==NULL && win->m_sharedContextOf) share=win->m_sharedContextOf->GetContext(); + + win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, share ); + + return FALSE; +} + +//----------------------------------------------------------------------------- +// "map" from m_wxwindow +//----------------------------------------------------------------------------- + +static gint +gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) +{ + if (win->m_glContext/* && win->m_exposed*/) + { + wxPaintEvent event( win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); + + win->m_exposed = FALSE; + win->GetUpdateRegion().Clear(); + } return FALSE; } @@ -222,7 +245,7 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id, int *attribList, const wxPalette& palette ) { - Create( parent, NULL, id, pos, size, style, name, attribList, palette ); + Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette ); } wxGLCanvas::wxGLCanvas( wxWindow *parent, @@ -233,11 +256,23 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent, int *attribList, const wxPalette& palette ) { - Create( parent, shared, id, pos, size, style, name, attribList, palette ); + Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette ); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, + const wxGLCanvas *shared, + wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name, + int *attribList, + const wxPalette& palette ) +{ + Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette ); } bool wxGLCanvas::Create( wxWindow *parent, const wxGLContext *shared, + const wxGLCanvas *shared_context_of, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, @@ -245,6 +280,7 @@ bool wxGLCanvas::Create( wxWindow *parent, const wxPalette& palette) { m_sharedContext = (wxGLContext*)shared; // const_cast + m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast m_glContext = (wxGLContext*) NULL; m_exposed = FALSE; @@ -314,6 +350,9 @@ bool wxGLCanvas::Create( wxWindow *parent, 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 ); @@ -333,9 +372,7 @@ wxGLCanvas::~wxGLCanvas() { XVisualInfo *vi = (XVisualInfo *) m_vi; - if (vi) - XFree( vi ); - + if (vi) XFree( vi ); if (m_glContext) delete m_glContext; }