Search code examples
linuxopenglglewwxglcanvas

Initialize Glew from within wxGLCanvas under Linux


When the constuctor for my wxGLCanvas sub-class

MyGLCanvas::MyGLCanvas(wxWindow* parent)
        : wxGLCanvas(parent, wxID_ANY, 0)
{
    wxGLContext *m_context = new wxGLContext(this);
    SetCurrent(*m_context);

    GLenum err = glewInit();
}

is called glewInit() returns me the error-code for "Missing GL version".

This is only under Ubuntu, where I link with the flags -lGLEW -lGL, wxWidgets is version 2.8 and OpenGL 3.0 Mesa 10.1.3. Under Windows OS there is no error.

I'm thankfull for any pointers. Let me know if you need any additional information or a MWE.


Solution

  • I updated wxWidgets to version 3.1 and moved the SetCurrent and glewInit call from the constructor to an event-handler bound to wxEVT_PAINT and made sure it is called only once.

    Now it works.