[SOLVED] QGLWidget and glew

Started by
2 comments, last by bensmith87 14 years, 9 months ago
Hi, I'm in the process of making an editor for an engine I'm working on. Just a learning experience really. Anyway, my call to glewInit() fails. Here is the relevant code...

class Renderer : public QGLWidget
{
public:
    Renderer();
    
    void addMeshNode(MeshNode *aMeshNode);
    
    void setCamera(Camera *aCamera);

    void initializeGL();
    void resizeGL(int aWidth, int aHeight);
    void paintGL();

private:
    std::vector<MeshNode *> fMeshNodes;
    Camera *fCamera;
    int fWidth;
    int fHeight;
};




void Renderer::initializeGL()
{
    std::cout << this << " Renderer::initializeGL()\n";

    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        std::cout << "error: glewInit() failed\n";
    }

    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}



I thought the only way it would fail, was if the OpenGL context hadn't been created yet, but I'm calling it after my QGLWidget has been created. Any help would be appreciated, I couldn't get glee to work either. I'm on Linux, using the latest QT Creator. Thanks in advance [Edited by - bensmith87 on July 21, 2009 5:36:50 PM]
Advertisement
bensmith87, are you sure you can use glew with QT? I mean, does not QT have anything to load extensions?
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
I had a similar problem, fixed it by calling makeCurrent() before glewInit();
My code looks like this:
QGLWidget* glw = new QGLWidget(graphicsView);
glw->makeCurrent();
glewInit();
graphicsView->setViewport(glw);
Thanks for all your help, adding makeCurrent() before glewInit() was all that was needed.

This topic is closed to new replies.

Advertisement