Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5.4 and GLEW MX => glewInit() fails

Qt5.4 and GLEW MX => glewInit() fails

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agrum
    wrote on last edited by
    #1

    Hi,

    We are migrating our project from Qt 4.8 to 5.4. We use multiple contexts in multiple thread. We use GLEW MX for this purpose (We make the context we desire current then call glewInit() on a local instance of GLEWContextStruct).

    I'm trying to change QGLWidget and QGLContext to QOpenGLWidget and QOpenGLContext but I ended up not being able to initialize glew anymore.
    GLEW doesn't return an error but glGetError() does.

    I did install Qt 5.4 64 with OpenGL version.

    Here is the code reduced to a minimum :

    @#include <GL/glew.h>

    #include <qopenglwidget.h>
    #include <qopenglcontext.h>
    #include <qwindow.h>
    #include <qapplication.h>

    //Function used by GLEW to support multiple rendering contexts.
    #define glewGetContext() ctx::_glewGetContext()

    class ctx {
    public:
    static GLEWContextStruct* _glewGetContext()
    {
    if (s_glewCtx == NULL)
    s_glewCtx = new GLEWContextStruct;
    return s_glewCtx;
    }

    private:
    static GLEWContextStruct* s_glewCtx;
    };

    GLEWContext* ctx::s_glewCtx = NULL;

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    bool errQt;
    int errGlew;
    GLenum errorGL;

    QSurfaceFormat requestedFormat;
    requestedFormat.setVersion(3, 3);

    //Create context
    QOpenGLContext context;
    context.setFormat(requestedFormat);
    errQt = context.create(); //true

    //Creates the QGLWidget using the current context:
    QOpenGLWidget widget;
    widget.winId();
    widget.setFormat(requestedFormat);

    //Bind context
    errQt = context.makeCurrent(widget.windowHandle()); //true

    //Init glew
    errorGL = glGetError(); //0
    errGlew = glewInit(); //0
    errorGL = glGetError(); //1280

    //Release context
    context.doneCurrent();
    }@

    When I remove the setFormat() for both the context and widget, it passes. But I need OpenGL 3.3.

    Any suggestion ? Is GLEW alright with Qt5.4 ?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved