Loading OpenGL extensions in Qt5



  • Hi,

    I've looked at loading extensions in Qt 5 from http://www.kdab.com/opengl-in-qt-5-1-part-1/ and following the Mr. Harmer' example, I'm trying to load the QOpenGLExtension_ARB_instanced_arrays extension, but when I build, I get:

    @error: undefined reference to QOpenGLExtension_ARB_instanced_arrays::QOpenGLExtension_ARB_instanced_arrays()' error: undefined reference toQOpenGLExtension_ARB_instanced_arrays::initializeOpenGLFunctions()'@

    I've made sure I have the extension through m_context->hasExtension(..) etc. Searching for the helper class here: http://code.woboq.org/qt5/qtbase/src/openglextensions/qopenglextensions.h.html, I don't see why it becomes undefined, as it's all there..

    Can any of you that's been using extensions in Qt5 tell me what I'm doing wrong?

    @ assert(m_context.hasExtension(QByteArrayLiteral("GL_ARB_instanced_arrays")));
    QOpenGLExtension_ARB_instanced_arrays* m_instanceFuncs = new QOpenGLExtension_ARB_instanced_arrays();
    m_instanceFuncs->initializeOpenGLFunctions();
    qDebug("extension loaded");@



  • Hi again,

    I've yet had any success regarding this. I've tried copying over the qopenglextensions.h to my own project and I've tried building the project on both a Linux system and a Windows 7 system (both systems use Qt5.3).

    It's frustrating because I need access to GL_ARB_shader_image_load_store or GL_ARB_shader_storage_buffer_object and I feel helpless at the moment.

    If the steps I've taken is typically enough to load extensions, I'd be very happy if someone else could confirm it so that I know there's something weird on my end here.


  • Moderators

    OpenGL and extensions live in a separate module. Be sure to add it in your .pro file and re-run qmake.
    @
    QT += opengl openglextensions
    @



  • And now it's working as it should...

    Thanks!



  • Hi guys,
    Thank you very much for that clarification!
    Is there any way to add this module to Visual? Can't find that module using Qt Visual Addin 1.2.3.
    And what include do you guys use:
    @#include <QOpenGLExtensions>@
    or
    @#include <QtGui/QOpenGLExtensions>@
    or
    @#include <QtOpenGLExtensions>@
    or
    @#include <qopenglextensions.h>@

    In advance, many thanks!



  • HI,

    I haven't used any recent version of the Visual Studio addin so I cannot make a comment for that.

    Try :
    #include <QtOpenGLExtensions/QOpenGLExtensions>



  • Sorry for the late reply, I was busy as hell!
    So just find how to add that using visual 2013.

    So as said by ArchW, you have to include @<QtOpenGLExtensions/QOpenGLExtensions>@ but not only, you will have to had the proper library to your project settings and you also have to add the Qt Preprocessor as the Qt visual addin do not know about that lib (modules if you prefer). And be carefull with the debug/no-debug version!

    Hope this will help.



  • note that the includes that you use doesn't matter. if you look at qt sources, the non-.h, captialized ones are literally just text files with a single line that does #include "./somethign.h". so its just style.


  • Lifetime Qt Champion

    Hi,

    The recommended Qt way to include is

    @#include <QOpenGLExtensions>@


Log in to reply
 

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