From 264f22613c68656b4e4a47b5be1eaca205eb31f1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Apr 2007 00:02:15 +0000 Subject: [PATCH] refresh GL canvas itself, not the frame, when the GL context changes, otherwise it doesn't redraw under wxGTK1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/opengl/cube/cube.cpp | 7 ++++++- samples/opengl/cube/cube.h | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp index b5f5ba419e..783ed604e7 100644 --- a/samples/opengl/cube/cube.cpp +++ b/samples/opengl/cube/cube.cpp @@ -243,7 +243,8 @@ void TestGLCanvas::OnKeyDown( wxKeyEvent& event ) i != wxTopLevelWindows.end(); ++i ) { - (*i)->Refresh(false); + MyFrame *frame = (MyFrame *)*i; + frame->RefreshCanvas(); } } @@ -287,3 +288,7 @@ void MyFrame::OnNewWindow( wxCommandEvent& WXUNUSED(event) ) (void) new MyFrame(); } +void MyFrame::RefreshCanvas() +{ + m_canvas->Refresh(false); +} diff --git a/samples/opengl/cube/cube.h b/samples/opengl/cube/cube.h index 56e6899fc7..1fa19dc7c9 100644 --- a/samples/opengl/cube/cube.h +++ b/samples/opengl/cube/cube.h @@ -40,12 +40,16 @@ class MyFrame: public wxFrame public: MyFrame(); + // update the image shown on the canvas (after the shared wxGLContext was + // updated, presumably) + void RefreshCanvas(); + +private: void OnExit(wxCommandEvent& event); void OnNewWindow(wxCommandEvent& event); void OnDefRotateLeftKey(wxCommandEvent& event); void OnDefRotateRightKey(wxCommandEvent& event); -private: TestGLCanvas *m_canvas; DECLARE_EVENT_TABLE() @@ -56,11 +60,11 @@ class TestGLCanvas : public wxGLCanvas public: TestGLCanvas(wxWindow *parent); +private: void OnPaint(wxPaintEvent& event); void OnSize(wxSizeEvent& event); void OnKeyDown(wxKeyEvent& event); -private: // OpenGL calls can't be done until we're initialized bool IsInitialized() const { return m_gllist != 0; } -- 2.47.2