I don't get the context working.
I have tried this minimal sample:
Code: Select all
#include <wx/wx.h>
#include <wx/glcanvas.h>
class wxMyCanvas : public wxGLCanvas
{
public:
wxMyCanvas(wxWindow* parent, int* attribList)
: wxGLCanvas(parent, -1, attribList, wxDefaultPosition, wxSize(800,600))
{}
virtual ~wxMyCanvas()
{
delete m_context;
}
void MyInit()
{
m_context = new wxGLContext(this);
}
void PaintIt(wxPaintEvent& e)
{
//wxPaintDC(this);
Render();
}
void Idle(wxIdleEvent& e)
{
Render();
e.RequestMore(true);
}
void Render()
{
//this->SetCurrent(*m_context);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
//glFinish();
this->SwapBuffers();
}
void dumpOpenGLInfo()
{
// OpenGL
char* gl_ven = (char*)glGetString(GL_VENDOR);
char* gl_ver = (char*)glGetString(GL_VERSION);
char* gl_render = (char*)glGetString(GL_RENDERER);
wxString s;
s.Printf("Version: %s", gl_ver);
wxMessageBox(s);
}
private:
wxGLContext* m_context;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxMyCanvas, wxGLCanvas)
EVT_PAINT(wxMyCanvas::PaintIt)
EVT_IDLE(wxMyCanvas::Idle)
END_EVENT_TABLE()
class Application : public wxApp
{
public:
virtual bool OnInit()
{
wxFrame* frame = new wxFrame(NULL, -1, "wxGLTest", wxDefaultPosition, wxSize(800,600));
wxMyCanvas* canvas = new wxMyCanvas(frame, NULL);
canvas->MyInit();
canvas->dumpOpenGLInfo();
frame->Show();
SetTopWindow(frame);
return true;
}
};
IMPLEMENT_APP(Application);
Is this me or is this broken in 2.9.2?
Can anyone test it please?
glGetString(GL_VERSION) remains NULL....
I have tried it with and without the commented sections, sticking to this sample:
http://wiki.wxwidgets.org/WxGLCanvas