From 1d61ebaca18624cadf455a8859c1d089db5e6a23 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 4 Oct 1999 19:54:25 +0000 Subject: [PATCH] OpenGl updates (still gives warnings..) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/glcanvas/gtk/glcanvas.cpp | 51 +++++++++++-------------- utils/glcanvas/samples/penguin/Makefile | 4 +- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/utils/glcanvas/gtk/glcanvas.cpp b/utils/glcanvas/gtk/glcanvas.cpp index a4b55c539e..132d2698e6 100644 --- a/utils/glcanvas/gtk/glcanvas.cpp +++ b/utils/glcanvas/gtk/glcanvas.cpp @@ -128,6 +128,18 @@ wxPalette wxGLContext::CreateDefaultPalette() return wxNullPalette; } +//----------------------------------------------------------------------------- +// "realize" from m_wxwindow +//----------------------------------------------------------------------------- + +static gint +gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) +{ + win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, win->m_glContext ); + + return FALSE; +} + //--------------------------------------------------------------------------- // wxGlCanvas //--------------------------------------------------------------------------- @@ -166,21 +178,13 @@ bool wxGLCanvas::Create( wxWindow *parent, int *attribList, const wxPalette& palette) { - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( _T("wxGLCanvas creation failed") ); - return FALSE; - } - + m_glContext = (wxGLContext*)shared; // const_cast + if (!attribList) { int data[] = { GLX_RGBA, GLX_DOUBLEBUFFER, - GLX_DEPTH_SIZE, 1, /* use largest available depth buffer */ + GLX_DEPTH_SIZE, 1, // use largest available depth buffer GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, @@ -225,37 +229,28 @@ bool wxGLCanvas::Create( wxWindow *parent, gtk_widget_push_colormap( colormap ); gtk_widget_push_visual( visual ); + + wxScrolledWindow::Create( parent, id, pos, size, style, name ); + + m_glWidget = m_wxwindow; - m_glWidget = gtk_myfixed_new(); - m_widget = m_glWidget; - + gtk_signal_connect( GTK_OBJECT(m_glWidget), "realize", + GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this ); gtk_widget_pop_visual(); gtk_widget_pop_colormap(); - m_parent->DoAddChild( this ); - /* must be realized for OpenGl output */ gtk_widget_realize( m_glWidget ); - m_glContext = new wxGLContext( TRUE, this, palette, shared ); - XFree( g_vi ); g_vi = (XVisualInfo*) NULL; - /* we pretend to have a m_wxwindow so that PostCreation hooks - up the events for expose and draw */ - m_wxwindow = m_glWidget; - PostCreation(); - - Show( TRUE ); - return TRUE; } wxGLCanvas::~wxGLCanvas() { if (m_glContext) delete m_glContext; - m_wxwindow = (GtkWidget*) NULL; } void wxGLCanvas::SwapBuffers() @@ -292,10 +287,10 @@ void wxGLCanvas::SetColour( const char *colour ) GtkWidget *wxGLCanvas::GetConnectWidget() { - return m_glWidget; + return m_wxwindow; } bool wxGLCanvas::IsOwnGtkWindow( GdkWindow *window ) { - return (window == m_glWidget->window); + return (window == m_wxwindow->window); } diff --git a/utils/glcanvas/samples/penguin/Makefile b/utils/glcanvas/samples/penguin/Makefile index 0401bb93aa..8e02865f70 100644 --- a/utils/glcanvas/samples/penguin/Makefile +++ b/utils/glcanvas/samples/penguin/Makefile @@ -21,7 +21,7 @@ Penguin: penguin.o trackball.o lw.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU penguin.o: penguin.cpp - $(CPP) `wx-config --cflags` -I../../gtk -c penguin.cpp + $(CPP) `wx-config --cflags` -g -I../../gtk -c penguin.cpp lw.o: lw.cpp $(CPP) `wx-config --cflags` -I../../gtk -c lw.cpp @@ -30,7 +30,7 @@ trackball.o: trackball.c $(CC) `wx-config --cflags` -I../../gtk -c trackball.c glcanvas.o: ../../gtk/glcanvas.cpp - $(CPP) `wx-config --cflags` `gtk-config --cflags` -I../../gtk -c ../../gtk/glcanvas.cpp + $(CPP) `wx-config --cflags` `gtk-config --cflags` -g -I../../gtk -c ../../gtk/glcanvas.cpp clean: rm -f *.o Penguin -- 2.45.2