I need some help, how to draw on wxGLCanvas(GLCanvas1) included as an wxAUI pane, created with code::blocks and wxSmith.
here some code:
void Frame::OnGLCanvas1Paint(wxPaintEvent& event)
{
wxPaintDC dc(GLCanvas1);
int w, h;
GetClientSize(&w, &h);
if(GLCanvas1->GetContext()) {
GLCanvas1->SetCurrent();
glViewport(0, 0, (GLint)w, (GLint)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w/(float)h, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
else
{
return;
}
glClearColor(0.0, 0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(0.1, 0.1);
glVertex2f(-0.1, 0.1);
glVertex2f(-0.1, -0.1);
glVertex2f(0.1, -0.1);
glEnd();
glFlush();
GLCanvas2->SwapBuffers();
}
I am also using a patched version of the wxGLCanvas in wxSmith [...]
What does this patch? Is that relevant generally for C::B?
There is a difference in constructors for wxGLCanvas, between wx2.8.11 and wx2.9.1
The patch create a "#if wxCHECK_VERSION"
example:
#if wxCHECK_VERSION(2, 9, 0)
GLCanvas1 = new wxGLCanvas(Panel1, ID_GLCANVAS1, GLCanvasAttributes2_1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GLCANVAS1"));
#else
GLCanvas1 = new wxGLCanvas(Panel1, ID_GLCANVAS1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GLCANVAS1"), GLCanvasAttributes2_1);
#endif
That's all.
If you do not have the wxCHECK_VERSION, then compilation will fail with wxWidgets 2.9.1
I have posted here a plugin, not a patch: it is a wxSmith component, with the same name "wxGLCanvas"
I discourage to include it yet in the main source tree: it is not fully tested. It was a quick fix I have made for my personal usage. However, there are not a lot of risks to apply a patch: this plugin is mainly a copy of wxSmith files, with a few lines added.
Sebastien