[Solved] glBindBufferRange not found



  • I am trying to use the glBindBufferRange function in an OpenGL 3.3 or later Core context and I get the error @'glBindBufferRange': identifier not found@

    on compiling.

    I tried using Qt 5.3 and 5.4,
    I tried setting the context to 3.3 through 4.4,
    I have included QOpenGLFunctions, I tried including directly QOpenGLFunctions_3_3_Core.
    I have Qt += gui in my pro file.
    The class is a QWindow class.

    Any ideas?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure you have the latest version of you graphic card driver ?

    By the way, what version of Qt/OS combo are you using ?



  • Thank you!

    Sorry for not being more specific.
    OS: Windows 8.1 Pro
    Qt: 5.4 x64
    I have the latest driver and the card supports OpenGL 4.4 (AMD Radeon 290X).
    I checked the OpenGL context with the versionFunctions() function and it returns the header corresponding to the context I requested. So the function should be there.


  • Lifetime Qt Champion

    Can you post the code you are using to setup OpenGL ?



  • Sure:
    The OpenGL window inherits from QWindow and is initialized as follows:

    @ QSurfaceFormat format;

    format.setSamples(16);
    format.setDepthBufferSize(24);
    format.setMajorVersion(4);
    format.setMinorVersion(0);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    
    glWindow = new OpenGLWindow;
    glWindow->setFormat(format);
    glWindow->setAnimating(true);@
    

    The class is declared with
    @class OpenGLWindow : public QWindow, protected QOpenGLFunctions@

    The header for OpenGL functions included is
    @#include <QOpenGLFunctions>@

    I hope this helps.


  • Lifetime Qt Champion

    Aren't you missing something like:

    @
    void OpenGLWindow::initializeGL()
    {
    m_context->makeCurrent(this);
    initializeOpenGLFunctions();
    }@

    ?



  • I have that in the renderNow function:

    @void OpenGLWindow::renderNow()
    {
    if(!isExposed())
    {
    return;
    }

    bool needsInitialize = false;
    
    if(!context)
    {
        context = new QOpenGLContext(this);
        context->setFormat(requestedFormat());
        context->create();
    
        needsInitialize = true;
    }
    
    context->makeCurrent(this);
    
    if(needsInitialize)
    {
        initializeOpenGLFunctions();
        initialize();
    }
    
    render();
    
    context->swapBuffers(this);
    
    if(isAnimating)
    {
        renderLater();
    }
    

    }@


  • Lifetime Qt Champion

    Doesn't look like the recommended way to setup a QOpenGLWidget



  • It's not, because it's not a QOpenGLWidget. It's a QWindow. I did mention that. See here: "OpenGL Window Example":http://doc.qt.io/qt-5/qtgui-openglwindow-example.html.
    Anyway, this has nothing to do with initialization, that error is an include error.


  • Moderators

    @
    class OpenGLWindow : public QWindow, protected QOpenGLFunctions
    @
    QOpenGLFunctions exposes only the OpenGL ES 2.0 API.
    glBindBufferRange is not part of it. It is part of OpenGL ES 3.0, OpenGL 3.0 and up.
    Qt does not support OpenGL ES 3.0 yet, so you're left with any of the desktop versions: QOpenGLFunctions_3_0 or one of the higher, profiled ones.

    Use these instead of QOpenGLFunctions (include is not enough).



  • [quote author="Chris Kawa" date="1418430389"]@
    class OpenGLWindow : public QWindow, protected QOpenGLFunctions
    @
    Use these instead of QOpenGLFunctions (include is not enough).[/quote]

    Thank you, that got it working.
    If anybody runs into this, I just changed the include to @#include <QOpenGLFunctions_4_0_Core>@

    and the inheritance to
    @class OpenGLWindow : public QWindow, protected QOpenGLFunctions_4_0_Core@


Log in to reply
 

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