summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2016-02-12 12:50:12 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-02 12:16:15 +0000
commit69f29b90322338bb7cd884a0cecdb8dd5dd2573e (patch)
treee0f9d7dd3d71b802fa25ca487bc232081179e1d0 /src/gui/opengl
parent6b0a577bf85845780e9a7b101260cdf72fa1d33c (diff)
Clean up resolving of OpenGL functions on Windows
Always try both e/wglGetProcAddress and ::GetProcAddress to resolve the methods. Like this QOpengGLContext::getProcAddress is able to return any OpenGL entry point, and we can both simplify the code we have in the QPA backend as well as get rid of windows specific code paths in Qt Gui. Task-number: QTBUG-39531 Change-Id: I1ddf1b0974f69b56b219a619655b723eb0134b14 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopengldebug.cpp12
-rw-r--r--src/gui/opengl/qopengltexturehelper.cpp15
-rw-r--r--src/gui/opengl/qopenglversionfunctions.cpp26
3 files changed, 8 insertions, 45 deletions
diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp
index 7bdf6ee443..24aa6094dd 100644
--- a/src/gui/opengl/qopengldebug.cpp
+++ b/src/gui/opengl/qopengldebug.cpp
@@ -1388,19 +1388,7 @@ bool QOpenGLDebugLogger::initialize()
GET_DEBUG_PROC_ADDRESS(glGetDebugMessageLog);
GET_DEBUG_PROC_ADDRESS(glPushDebugGroup);
GET_DEBUG_PROC_ADDRESS(glPopDebugGroup);
-
- // Windows' Desktop GL doesn't allow resolution of "basic GL entry points"
- // through wglGetProcAddress
-#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
- {
- HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
- if (!handle)
- handle = GetModuleHandleA("opengl32.dll");
- d->glGetPointerv = reinterpret_cast<qt_glGetPointerv_t>(GetProcAddress(handle, QByteArrayLiteral("glGetPointerv")));
- }
-#else
GET_DEBUG_PROC_ADDRESS(glGetPointerv)
-#endif
#undef GET_DEBUG_PROC_ADDRESS
diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp
index 23e5ef6579..be88946e90 100644
--- a/src/gui/opengl/qopengltexturehelper.cpp
+++ b/src/gui/opengl/qopengltexturehelper.cpp
@@ -143,17 +143,6 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TextureImage2DMultisample = &QOpenGLTextureHelper::qt_TextureImage2DMultisample;
}
-#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
- // wglGetProcAddress should not be used to (and indeed will not) load OpenGL <= 1.1 functions.
- // Hence, we resolve them "the hard way"
- HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
- if (!handle)
- handle = GetModuleHandleA("opengl32.dll");
-
- TexImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexImage1D")));
- TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexSubImage1D")));
-#endif
-
#if defined(QT_OPENGL_ES_2)
// Here we are targeting OpenGL ES 2.0+ only. This is likely using EGL, where,
// similarly to WGL, non-extension functions (i.e. any function that is part of the
@@ -227,6 +216,10 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
}
#ifndef QT_OPENGL_ES_2
+ // OpenGL 1.0 and 1.1
+ TexImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress("glTexImage1D"));
+ TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress("glTexSubImage1D"));\
+
// OpenGL 1.3
GetCompressedTexImage = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLvoid *)>(context->getProcAddress("glGetCompressedTexImage"));
CompressedTexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLsizei , const GLvoid *)>(context->getProcAddress("glCompressedTexSubImage1D"));
diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp
index 3fba00bc47..9fa224b0aa 100644
--- a/src/gui/opengl/qopenglversionfunctions.cpp
+++ b/src/gui/opengl/qopenglversionfunctions.cpp
@@ -67,24 +67,6 @@ void CLASS::init() \
} \
}
-#ifdef Q_OS_WIN
-#define QT_OPENGL_IMPLEMENT_WIN(CLASS, FUNCTIONS) \
-void CLASS::init() \
-{ \
- HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle()); \
- if (!handle) \
- handle = GetModuleHandleA("opengl32.dll"); \
- const char *names = FUNCTIONS(QT_OPENGL_FUNCTION_NAMES); \
- const char *name = names; \
- for (int i = 0; i < FUNCTIONS(QT_OPENGL_COUNT_FUNCTIONS); ++i) { \
- functions[i] = (QFunctionPointer)GetProcAddress(handle, name); \
- name += strlen(name) + 1; \
- } \
-}
-#else
-#define QT_OPENGL_IMPLEMENT_WIN QT_OPENGL_IMPLEMENT
-#endif
-
QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage()
: backends(0)
{
@@ -325,8 +307,8 @@ QOpenGLContext *QAbstractOpenGLFunctions::owningContext() const
#if !defined(QT_OPENGL_ES_2)
-QT_OPENGL_IMPLEMENT_WIN(QOpenGLFunctions_1_0_CoreBackend, QT_OPENGL_1_0_FUNCTIONS)
-QT_OPENGL_IMPLEMENT_WIN(QOpenGLFunctions_1_1_CoreBackend, QT_OPENGL_1_1_FUNCTIONS)
+QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_0_CoreBackend, QT_OPENGL_1_0_FUNCTIONS)
+QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_1_CoreBackend, QT_OPENGL_1_1_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_2_CoreBackend, QT_OPENGL_1_2_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_3_CoreBackend, QT_OPENGL_1_3_FUNCTIONS)
@@ -345,8 +327,8 @@ QT_OPENGL_IMPLEMENT(QOpenGLFunctions_4_3_CoreBackend, QT_OPENGL_4_3_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_4_4_CoreBackend, QT_OPENGL_4_4_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_4_5_CoreBackend, QT_OPENGL_4_5_FUNCTIONS)
-QT_OPENGL_IMPLEMENT_WIN(QOpenGLFunctions_1_0_DeprecatedBackend, QT_OPENGL_1_0_DEPRECATED_FUNCTIONS)
-QT_OPENGL_IMPLEMENT_WIN(QOpenGLFunctions_1_1_DeprecatedBackend, QT_OPENGL_1_1_DEPRECATED_FUNCTIONS)
+QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_0_DeprecatedBackend, QT_OPENGL_1_0_DEPRECATED_FUNCTIONS)
+QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_1_DeprecatedBackend, QT_OPENGL_1_1_DEPRECATED_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_2_DeprecatedBackend, QT_OPENGL_1_2_DEPRECATED_FUNCTIONS)
QT_OPENGL_IMPLEMENT(QOpenGLFunctions_1_3_DeprecatedBackend, QT_OPENGL_1_3_DEPRECATED_FUNCTIONS)