summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsopengltester.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-22 10:05:23 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-26 18:10:42 +0000
commita8a0dffd1f78d27c04cfd1e20563e9ddda4a135c (patch)
treeba4aebe6554efafce1c6b3186b33510e3b57e91f /src/plugins/platforms/windows/qwindowsopengltester.cpp
parent6f53c2bc967641ef16d681e7cec0db200e4da244 (diff)
Windows QPA/GL: Fix build with MinGW/g++ 8.1 x64
Fix warnings about invalid function type casts (return types conflicting with the PROC returned by wglGetProcAddress()) like: qwindowsglcontext.cpp:1250:138: error: cast between incompatible function types from 'PROC' {aka 'long long int (*)()'} to 'GLenum (*)()' {aka 'unsigned int (*)()'} [-Werror=cast-function-type] m_getGraphicsResetStatus = (GLenum (APIENTRY *)()) QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetGraphicsResetStatusARB"); by introducing nested casts. Task-number: QTBUG-68742 Task-number: QTQAINFRA-2095 Change-Id: I7c51836f2b9f7e2a6fa17c5108d59b23c42fb99d Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsopengltester.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index a511cc6164..c52e4e612e 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -283,16 +283,21 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers()
bool QWindowsOpenGLTester::testDesktopGL()
{
#if !defined(QT_NO_OPENGL)
+ typedef HGLRC (WINAPI *CreateContextType)(HDC);
+ typedef BOOL (WINAPI *DeleteContextType)(HGLRC);
+ typedef BOOL (WINAPI *MakeCurrentType)(HDC, HGLRC);
+ typedef PROC (WINAPI *WglGetProcAddressType)(LPCSTR);
+
HMODULE lib = 0;
HWND wnd = 0;
HDC dc = 0;
HGLRC context = 0;
LPCTSTR className = L"qtopengltest";
- HGLRC (WINAPI * CreateContext)(HDC dc) = 0;
- BOOL (WINAPI * DeleteContext)(HGLRC context) = 0;
- BOOL (WINAPI * MakeCurrent)(HDC dc, HGLRC context) = 0;
- PROC (WINAPI * WGL_GetProcAddress)(LPCSTR name) = 0;
+ CreateContextType CreateContext = nullptr;
+ DeleteContextType DeleteContext = nullptr;
+ MakeCurrentType MakeCurrent = nullptr;
+ WglGetProcAddressType WGL_GetProcAddress = nullptr;
bool result = false;
@@ -300,16 +305,20 @@ bool QWindowsOpenGLTester::testDesktopGL()
// This will typically fail on systems that do not have a real OpenGL driver.
lib = LoadLibraryA("opengl32.dll");
if (lib) {
- CreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(::GetProcAddress(lib, "wglCreateContext"));
+ CreateContext = reinterpret_cast<CreateContextType>(
+ reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
if (!CreateContext)
goto cleanup;
- DeleteContext = reinterpret_cast<BOOL (WINAPI *)(HGLRC)>(::GetProcAddress(lib, "wglDeleteContext"));
+ DeleteContext = reinterpret_cast<DeleteContextType>(
+ reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglDeleteContext")));
if (!DeleteContext)
goto cleanup;
- MakeCurrent = reinterpret_cast<BOOL (WINAPI *)(HDC, HGLRC)>(::GetProcAddress(lib, "wglMakeCurrent"));
+ MakeCurrent = reinterpret_cast<MakeCurrentType>(
+ reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglMakeCurrent")));
if (!MakeCurrent)
goto cleanup;
- WGL_GetProcAddress = reinterpret_cast<PROC (WINAPI *)(LPCSTR)>(::GetProcAddress(lib, "wglGetProcAddress"));
+ WGL_GetProcAddress = reinterpret_cast<WglGetProcAddressType>(
+ reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglGetProcAddress")));
if (!WGL_GetProcAddress)
goto cleanup;
@@ -356,7 +365,8 @@ bool QWindowsOpenGLTester::testDesktopGL()
// Check the version. If we got 1.x then it's all hopeless and we can stop right here.
typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
- GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
+ GetString_t GetString = reinterpret_cast<GetString_t>(
+ reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "glGetString")));
if (GetString) {
if (const char *versionStr = reinterpret_cast<const char *>(GetString(GL_VERSION))) {
const QByteArray version(versionStr);