From d7bdb504267eaac64947a1622540bb7f75ab7c27 Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Tue, 11 Aug 2009 23:45:22 -0600 Subject: [PATCH] wx2.8 compatibility changes --- src/graph3dview.cpp | 53 ++++++++++++++++++++++----------------------- src/graph3dview.h | 24 ++++++++++---------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/graph3dview.cpp b/src/graph3dview.cpp index d694b32..dbcd2b0 100644 --- a/src/graph3dview.cpp +++ b/src/graph3dview.cpp @@ -143,9 +143,9 @@ Graph3dFileView::Graph3dFileView () : m_pFileMenu(NULL), m_pViewMenu(NULL), m_pStatusBar(NULL), m_pCanvas(NULL), m_dXRotate(-180), m_dYRotate(-210), m_dZRotate(195), m_bDoubleBuffer(true), m_bSmooth(true), m_bWireframe(false), - m_bLighting(false), m_bColor(true), m_bUseVertexArrays(false), + m_bLighting(false), m_bColor(true), m_bColorScaleMinSet(false), m_bColorScaleMaxSet(false), - m_pFrame(NULL) + m_pGLContext(NULL), m_pFrame(NULL) {} @@ -153,6 +153,8 @@ Graph3dFileView::~Graph3dFileView() { GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu); GetDocumentManager()->ActivateView(this, false); + if (m_pGLContext) + delete m_pGLContext; } bool @@ -160,15 +162,6 @@ Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) { m_pFrame = CreateChildFrame(doc, this); SetFrame (m_pFrame); - m_pCanvas = CreateCanvas (m_pFrame); - - m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); - m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); - m_pFrame->SetTitle(_T("Graph3dFileView")); - - m_pCanvas->SetCurrent(); - InitGL(); - m_pCanvas->SwapBuffers(); m_pViewMenu->Check (GRAPH3D_VIEW_COLOR, m_bColor); m_pViewMenu->Check (GRAPH3D_VIEW_LIGHTING, m_bLighting); @@ -179,6 +172,18 @@ Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) m_pFrame->Show(true); Activate(true); +#if 1 + m_pCanvas = CreateCanvas (m_pFrame); + m_pGLContext = new wxGLContext (m_pCanvas); + m_pFrame->SetClientSize (m_pCanvas->GetBestSize()); + m_pCanvas->SetClientSize (m_pCanvas->GetBestSize()); + m_pFrame->SetTitle(doc->GetFilename()); + + m_pCanvas->SetCurrent(*m_pGLContext); + InitGL(); // Crash + m_pCanvas->SwapBuffers(); +#endif + return true; } @@ -186,7 +191,8 @@ Graph3dFileCanvas* Graph3dFileView::CreateCanvas (wxFrame* parent) { Graph3dFileCanvas* pCanvas = - new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), + new Graph3dFileCanvas (this, parent, NULL, + wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE); pCanvas->SetBackgroundColour(*wxWHITE); @@ -408,7 +414,7 @@ void Graph3dFileView::OnDraw (wxDC* dc) { if (m_pCanvas) { - m_pCanvas->SetCurrent(); + m_pCanvas->SetCurrent(*m_pGLContext); #ifdef DEBUG *theApp->getLog() << _T("Drawing 3d surface\n"); #endif @@ -617,7 +623,7 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) double dRadius = maxValue (nx, ny) * SQRT2 / 2; if (m_pCanvas) - m_pCanvas->SetCurrent(); + m_pCanvas->SetCurrent(*m_pGLContext); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -841,19 +847,12 @@ EVT_ERASE_BACKGROUND(Graph3dFileCanvas::OnEraseBackground) END_EVENT_TABLE() - -Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, const wxPoint& pos, +Graph3dFileCanvas::Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, + int* attribList, + const wxPoint& pos, const wxSize& size, long style) - : wxGLCanvas (parent, -1, pos, size, style), m_pView(view) +: wxGLCanvas (parent, wxID_ANY, attribList, pos, size, style), m_pView(view) { -// parent->Show (true); -#if 0 - // Make sure server supports the vertex array extension - char* extensions = (char *) glGetString( GL_EXTENSIONS ); - if (!extensions || !strstr( extensions, "GL_EXT_vertex_array" )) { - m_pView->m_bUseVertexArrays = GL_FALSE; - } -#endif } @@ -885,7 +884,7 @@ Graph3dFileCanvas::OnSize (wxSizeEvent& event) int width, height; GetClientSize (&width, &height); - Reshape (width, height); + Reshape (width, height); // Crash } void @@ -941,7 +940,7 @@ Graph3dFileCanvas::OnChar(wxKeyEvent& event) void Graph3dFileCanvas::Reshape (int width, int height) { - SetCurrent(); + SetCurrent(*m_pView->m_pGLContext); glViewport (0, 0, (GLint)width, (GLint)height); SwapBuffers(); } diff --git a/src/graph3dview.h b/src/graph3dview.h index eeade71..b21072f 100644 --- a/src/graph3dview.h +++ b/src/graph3dview.h @@ -56,7 +56,6 @@ private: bool m_bWireframe; bool m_bLighting; bool m_bColor; - bool m_bUseVertexArrays; bool m_bColorScaleMinSet; bool m_bColorScaleMaxSet; enum { @@ -68,14 +67,7 @@ private: double m_dGraphMax; double m_dColorScaleMin; double m_dColorScaleMax; - - void Draw(); - void DrawSurface(); - void CreateDisplayList(); - void InitMaterials(); - void InitGL(); - - Graph3dFileCanvas *CreateCanvas (wxFrame* parent); + wxGLContext *m_pGLContext; #if CTSIM_MDI wxDocMDIChildFrame* m_pFrame; @@ -85,6 +77,14 @@ private: wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view); #endif + void Draw(); + void DrawSurface(); + void CreateDisplayList(); + void InitMaterials(); + void InitGL(); + + Graph3dFileCanvas *CreateCanvas (wxFrame* parent); + wxWindow* getFrameForChild() #if CTSIM_MDI { return theApp->getMainFrame(); } @@ -135,8 +135,10 @@ private: Graph3dFileView* m_pView; public: - Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0); + Graph3dFileCanvas (Graph3dFileView* view, wxWindow *parent, + int* attribList, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0); virtual ~Graph3dFileCanvas(); void OnPaint(wxPaintEvent& event); -- 2.34.1