Remove the different flags when trying to resolve opengl
functions. Rather we simply try hard to find a matching method
by resolving over possible suffixes when we can't find the standard
name.

Change-Id: Ic73085faec3bd406f5214ed4219eb7b796651d8d
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
Lars Knoll 2016-02-03 09:23:48 +01:00 committed by Laszlo Agocs
parent d98bfedfe4
commit 35405858a3

View File

@ -2098,48 +2098,36 @@ void QOpenGLFunctions::initializeOpenGLFunctions()
namespace { namespace {
enum ResolvePolicy // this function tries hard to get the opengl function we're looking for by also
{ // trying to resolve it with some of the common extensions if the generic name
ResolveOES = 0x1, // can't be found.
ResolveEXT = 0x2, static QFunctionPointer getProcAddress(QOpenGLContext *context, const char *funcName)
ResolveANGLE = 0x4,
ResolveNV = 0x8
};
static QFunctionPointer getProcAddress(QOpenGLContext *context, const char *funcName, int policy = ResolveOES|ResolveEXT|ResolveANGLE|ResolveNV)
{ {
QFunctionPointer function = context->getProcAddress(funcName); QFunctionPointer function = context->getProcAddress(funcName);
if (!function && policy) { static const struct {
const char *name;
int len; // includes trailing \0
} extensions[] = {
{ "ARB", 4 },
{ "OES", 4 },
{ "EXT", 4 },
{ "ANGLE", 6 },
{ "NV", 3 },
};
if (!function) {
char fn[512]; char fn[512];
size_t size = strlen(funcName); size_t size = strlen(funcName);
Q_ASSERT(size < 500); Q_ASSERT(size < 500);
memcpy(fn, funcName, size); memcpy(fn, funcName, size);
char *ext = fn + size; char *ext = fn + size;
if (!function && (policy & ResolveOES)) {
memcpy(ext, "OES", 4);
function = context->getProcAddress(fn);
}
if (!function) { for (const auto &e : extensions) {
memcpy(ext, "ARB", 4); memcpy(ext, e.name, e.len);
function = context->getProcAddress(fn);
}
if (!function && (policy & ResolveEXT)) {
memcpy(ext, "EXT", 4);
function = context->getProcAddress(fn);
}
if (!function && (policy & ResolveANGLE)) {
memcpy(ext, "ANGLE", 6);
function = context->getProcAddress(fn);
}
if (!function && (policy & ResolveNV)) {
memcpy(ext, "NV", 3);
function = context->getProcAddress(fn); function = context->getProcAddress(fn);
if (function)
break;
} }
} }
@ -2147,15 +2135,15 @@ static QFunctionPointer getProcAddress(QOpenGLContext *context, const char *func
} }
template <typename Func> template <typename Func>
Func resolve(QOpenGLContext *context, const char *name, int policy, Func) Func resolve(QOpenGLContext *context, const char *name, Func)
{ {
return reinterpret_cast<Func>(getProcAddress(context, name, policy)); return reinterpret_cast<Func>(getProcAddress(context, name));
} }
} }
#define RESOLVE(name, policy) \ #define RESOLVE(name) \
resolve(context, "gl"#name, policy, name) resolve(context, "gl"#name, name)
#ifndef QT_OPENGL_ES_2 #ifndef QT_OPENGL_ES_2
@ -4523,9 +4511,9 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx)
{ {
QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLContext *context = QOpenGLContext::currentContext();
MapBuffer = RESOLVE(MapBuffer, ResolveOES); MapBuffer = RESOLVE(MapBuffer);
GetBufferSubData = RESOLVE(GetBufferSubData, ResolveEXT); GetBufferSubData = RESOLVE(GetBufferSubData);
DiscardFramebuffer = RESOLVE(DiscardFramebuffer, ResolveEXT); DiscardFramebuffer = RESOLVE(DiscardFramebuffer);
} }
void QOpenGLExtensions::flushShared() void QOpenGLExtensions::flushShared()