: 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)
{}
{
GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
GetDocumentManager()->ActivateView(this, false);
+ if (m_pGLContext)
+ delete m_pGLContext;
}
bool
{
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);
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;
}
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);
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
double dRadius = maxValue<int> (nx, ny) * SQRT2 / 2;
if (m_pCanvas)
- m_pCanvas->SetCurrent();
+ m_pCanvas->SetCurrent(*m_pGLContext);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
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
}
int width, height;
GetClientSize (&width, &height);
- Reshape (width, height);
+ Reshape (width, height); // Crash
}
void
void
Graph3dFileCanvas::Reshape (int width, int height)
{
- SetCurrent();
+ SetCurrent(*m_pView->m_pGLContext);
glViewport (0, 0, (GLint)width, (GLint)height);
SwapBuffers();
}