Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QOpenGLFunctions missing important OpenGL functions

QOpenGLFunctions seems to be missing important functions such as glInvalidateFramebuffer and glMapBuffer. From what I understand QOpenGLFunctions loads the intersection of both desktop OpenGL functions and ES functions. If that's the case, why aren't these two functions present? From what I can tell glMapBuffer is in both.

Am I misunderstanding QOpenGLFunctions, or are they actually missing functions(unlikely)?

like image 426
Ben Avatar asked May 26 '14 08:05

Ben


Video Answer


1 Answers

QOpenGLFunctions just exposes the common subset of OpenGL 2 (+FBO) and OpenGL ES 2. That's why your functions are not there. glMapBuffer is in OpenGL 2 but not in ES 2 (but there's an OES extension); glInvalidateFramebuffer is in OpenGL 4.3.


If you need any other function apart from those of the common subset you can:

  • Starting with Qt 5.6, use QOpenGLExtraFunctions, which aims at the OpenGL ES 3.0 / 3.1 API (and the rough equivalent functionality on desktop OpenGL). As such, it does have both glMapBuffer and glInvalidateFramebuffer.

  • resolve it yourself via QOpenGLContext::getProcAddress

  • use QOpenGLContext::versionFunctions<T>() to get a function object containing all the functions for a given OpenGL version, for instance

    auto functions = context->versionFunctions<QOpenGLFunctions_4_3_Core>();
    if (!functions) error();
    functions->initializeOpenGLFunctions();
    functions->glInvalidateFramebuffer(...);
    
  • #include <QOpenGLExtensions> and use the class(es) wrapping the extensions you need, for instance

    auto functions = new QOpenGLExtension_ARB_invalidate_subdata;
    if (!functions->initializeOpenGLFunctions()) error();
    functions->glInvalidateFramebuffer(...)
    
  • wrap a combination of the above in a class that will use the resolved calls given a suitable GL version, or fall back to extensions, or fail (e.g.: QOpenGLTexture).

For glMapBuffer, it is actually exposed somehow wrapped by QOpenGLBuffer.

like image 193
peppe Avatar answered Oct 17 '22 07:10

peppe