"Correct" use of QOpenGLFunctions_X_X_Core

  • Hi,

    I'm currently porting my visualization software from Qt4 to Qt5. In the process I replaced GLEW and want to use the built in Qt OpenGL features now. My software has several GLWidgets, some share context some not. I require at least OpenGL 3.3. The rendering happens in renderer classes which all inherit from a base renderer class. Now somewhere I found the hint that I just could inherit that base class from QOpenGLFunctions_3_3_Core and be good but that doesn't work.

    In the docs I found this snippet
    @QOpenGLFunctions_3_3_Core* funcs = 0;

    funcs = context()->contextHandle()->versionFunctions<QOpenGLFunctions_3_3_Core>();
    if (!funcs) {
        qWarning() << "Could not obtain required OpenGL context version";

    But that would mean that I need to store this pointer globally and use it for every gl function call.
    @const GLubyte *renderer = GLFunctions::f->glGetString( GL_RENDERER );@
    That looks ugly and I would like to avoid it.

    Any hint what would be a better and more convinient way to use that?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.