Jump to content
  • Advertisement
Sign in to follow this  
bensmith87

OpenGL [SOLVED] QGLWidget and glew

This topic is 3281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
bensmith87, are you sure you can use glew with QT? I mean, does not QT have anything to load extensions?

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!