From b8167e73f6a4957e0f836b47667e46849342089e Mon Sep 17 00:00:00 2001 From: Sylvain Bougnoux Date: Wed, 19 Jan 2000 18:41:38 +0000 Subject: [PATCH] In order to make shared wxGLContext work,\nadd new wxGLCanvas ctor passing a wxGLCanvas\n instead of a wxGLContext, to share context with. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/glcanvas/gtk/glcanvas.cpp | 26 ++++++++++++++++++++------ utils/glcanvas/gtk/glcanvas.h | 27 ++++++++++++++++++--------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/utils/glcanvas/gtk/glcanvas.cpp b/utils/glcanvas/gtk/glcanvas.cpp index 71d8228192..68552f1b16 100644 --- a/utils/glcanvas/gtk/glcanvas.cpp +++ b/utils/glcanvas/gtk/glcanvas.cpp @@ -149,7 +149,10 @@ 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; } @@ -242,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, @@ -253,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, @@ -265,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; @@ -356,9 +372,7 @@ wxGLCanvas::~wxGLCanvas() { XVisualInfo *vi = (XVisualInfo *) m_vi; - if (vi) - XFree( vi ); - + if (vi) XFree( vi ); if (m_glContext) delete m_glContext; } diff --git a/utils/glcanvas/gtk/glcanvas.h b/utils/glcanvas/gtk/glcanvas.h index 3b7cb08cbd..b67e1ba7c8 100644 --- a/utils/glcanvas/gtk/glcanvas.h +++ b/utils/glcanvas/gtk/glcanvas.h @@ -94,6 +94,13 @@ private: class wxGLCanvas: public wxScrolledWindow { public: + inline wxGLCanvas() { + m_glContext = (wxGLContext*) NULL; + m_sharedContext = (wxGLContext*) NULL; + m_glWidget = (GtkWidget*) NULL; + m_vi = (void*) NULL; + m_exposed = FALSE; + } wxGLCanvas( wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -107,16 +114,17 @@ public: long style = 0, const wxString& name = "GLCanvas", int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); + wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); - inline wxGLCanvas() { - m_glContext = (wxGLContext*) NULL; - m_sharedContext = (wxGLContext*) NULL; - m_glWidget = (GtkWidget*) NULL; - m_vi = (void*) NULL; - m_exposed = FALSE; - } - - bool Create( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, + bool Create( wxWindow *parent, + const wxGLContext *shared = (wxGLContext*)NULL, + const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -140,6 +148,7 @@ public: wxGLContext *m_glContext, *m_sharedContext; + wxGLCanvas *m_sharedContextOf; void *m_vi; GtkWidget *m_glWidget; bool m_exposed; -- 2.47.2