summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowseglcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowseglcontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp67
1 files changed, 43 insertions, 24 deletions
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 23a6f35576..6124b004b6 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -201,26 +201,9 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display)
{
}
-QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType)
+bool QWindowsEGLStaticContext::initializeAngle(QWindowsOpenGLTester::Renderers preferredType, HDC dc,
+ EGLDisplay *display, EGLint *major, EGLint *minor)
{
- const HDC dc = QWindowsContext::instance()->displayContext();
- if (!dc){
- qWarning("%s: No Display", __FUNCTION__);
- return 0;
- }
-
- if (!libEGL.init()) {
- qWarning("%s: Failed to load and resolve libEGL functions", __FUNCTION__);
- return 0;
- }
- if (!libGLESv2.init()) {
- qWarning("%s: Failed to load and resolve libGLESv2 functions", __FUNCTION__);
- return 0;
- }
-
- EGLDisplay display = EGL_NO_DISPLAY;
- EGLint major = 0;
- EGLint minor = 0;
#ifdef EGL_ANGLE_platform_angle
if (libEGL.eglGetPlatformDisplayEXT
&& (preferredType & QWindowsOpenGLTester::AngleBackendMask)) {
@@ -238,16 +221,52 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp)
attributes = anglePlatformAttributes[2];
if (attributes) {
- display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
- if (!libEGL.eglInitialize(display, &major, &minor)) {
- display = EGL_NO_DISPLAY;
- major = minor = 0;
+ *display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
+ if (!libEGL.eglInitialize(*display, major, minor)) {
+ libEGL.eglTerminate(*display);
+ *display = EGL_NO_DISPLAY;
+ *major = *minor = 0;
+ return false;
}
}
}
#else // EGL_ANGLE_platform_angle
- Q_UNUSED(preferredType)
+ Q_UNUSED(preferredType);
+ Q_UNUSED(dc);
+ Q_UNUSED(display);
+ Q_UNUSED(major);
+ Q_UNUSED(minor);
#endif
+ return true;
+}
+
+QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType)
+{
+ const HDC dc = QWindowsContext::instance()->displayContext();
+ if (!dc){
+ qWarning("%s: No Display", __FUNCTION__);
+ return 0;
+ }
+
+ if (!libEGL.init()) {
+ qWarning("%s: Failed to load and resolve libEGL functions", __FUNCTION__);
+ return 0;
+ }
+ if (!libGLESv2.init()) {
+ qWarning("%s: Failed to load and resolve libGLESv2 functions", __FUNCTION__);
+ return 0;
+ }
+
+ EGLDisplay display = EGL_NO_DISPLAY;
+ EGLint major = 0;
+ EGLint minor = 0;
+
+ if (!initializeAngle(preferredType, dc, &display, &major, &minor)
+ && (preferredType & QWindowsOpenGLTester::AngleRendererD3d11)) {
+ preferredType &= ~QWindowsOpenGLTester::AngleRendererD3d11;
+ initializeAngle(preferredType, dc, &display, &major, &minor);
+ }
+
if (display == EGL_NO_DISPLAY)
display = libEGL.eglGetDisplay(dc);
if (!display) {