问题
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)?
回答1:
There are multiple reasons for those two cases and the one in the comment:
1) As far as I am aware, the addition process was selective. Only those functions got added that you would need to resolve manually.
In the aforementioned glDrawArrays
case, that function have been available for a while, both in desktop OpenGL as well as ES where Qt is supported, so there is not much need to resolve anything there manually.
You can just use them right away the regular opengl way, including gl.h
and all that.
2) For the time being, Qt does not support OpenGL ES 3 through this interface. Your aforementioned functions, glMapBuffer
and glInvalidateFramebuffer
are likely to fall into this category. They are not available in OpenGL ES 2 "by default".
If there is any function not being exposed and not covered by the aforementioned reasons, it is likely to be an overlook or so.
回答2:
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 bothglMapBuffer
andglInvalidateFramebuffer
.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 instanceauto 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 instanceauto 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
.
来源:https://stackoverflow.com/questions/23865864/qopenglfunctions-missing-important-opengl-functions