windows: Use EGL extensions as they ought to be used
We take some shortcuts still because we know that with ANGLE the header with the extension constants is always available. A proper implementation would not rely on the constants being available and would dynamically check for the extension and would take care of defining the constants if not available. However, just getting the extension list to check if the functions needed to get the display are available is already a chicken-egg problem so we won't go there. Using eglGetProcAddress properly solves the issues with static builds too since this always works. Task-number: QTBUG-46284 Change-Id: Iff23669ebacaffa0c5f76fd2c928af689307874f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Gunnar Roth Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
This commit is contained in:
parent
bccdb62340
commit
a47dbb010f
@ -39,7 +39,6 @@
|
||||
#include <QtGui/QOpenGLContext>
|
||||
|
||||
#if defined(QT_OPENGL_ES_2_ANGLE) || defined(QT_OPENGL_DYNAMIC)
|
||||
# define EGL_EGLEXT_PROTOTYPES
|
||||
# include <QtANGLE/EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
@ -137,7 +136,6 @@ bool QWindowsLibEGL::init()
|
||||
|
||||
eglGetError = RESOLVE((EGLint (EGLAPIENTRY *)(void)), eglGetError);
|
||||
eglGetDisplay = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLNativeDisplayType)), eglGetDisplay);
|
||||
eglGetPlatformDisplayEXT = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLenum platform, void *native_display, const EGLint *attrib_list)), eglGetPlatformDisplayEXT);
|
||||
eglInitialize = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, EGLint *, EGLint *)), eglInitialize);
|
||||
eglTerminate = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay)), eglTerminate);
|
||||
eglChooseConfig = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *)), eglChooseConfig);
|
||||
@ -156,7 +154,15 @@ bool QWindowsLibEGL::init()
|
||||
eglSwapBuffers = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay , EGLSurface)), eglSwapBuffers);
|
||||
eglGetProcAddress = RESOLVE((__eglMustCastToProperFunctionPointerType (EGLAPIENTRY * )(const char *)), eglGetProcAddress);
|
||||
|
||||
return eglGetError && eglGetDisplay && eglInitialize;
|
||||
if (!eglGetError || !eglGetDisplay || !eglInitialize || !eglGetProcAddress)
|
||||
return false;
|
||||
|
||||
eglGetPlatformDisplayEXT = 0;
|
||||
#ifdef EGL_ANGLE_platform_angle
|
||||
eglGetPlatformDisplayEXT = reinterpret_cast<EGLDisplay (EGLAPIENTRY *)(EGLenum, void *, const EGLint *)>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
|
||||
@ -360,7 +366,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
|
||||
EGLDisplay display = EGL_NO_DISPLAY;
|
||||
EGLint major = 0;
|
||||
EGLint minor = 0;
|
||||
#ifdef EGL_ANGLE_platform_angle_opengl
|
||||
#ifdef EGL_ANGLE_platform_angle
|
||||
if (libEGL.eglGetPlatformDisplayEXT
|
||||
&& (preferredType & QWindowsOpenGLTester::AngleBackendMask)) {
|
||||
const EGLint anglePlatformAttributes[][5] = {
|
||||
@ -384,7 +390,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // EGL_ANGLE_platform_angle_opengl
|
||||
#else // EGL_ANGLE_platform_angle
|
||||
Q_UNUSED(preferredType)
|
||||
#endif
|
||||
if (display == EGL_NO_DISPLAY)
|
||||
|
@ -46,7 +46,6 @@ struct QWindowsLibEGL
|
||||
|
||||
EGLint (EGLAPIENTRY * eglGetError)(void);
|
||||
EGLDisplay (EGLAPIENTRY * eglGetDisplay)(EGLNativeDisplayType display_id);
|
||||
EGLDisplay (EGLAPIENTRY * eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list);
|
||||
EGLBoolean (EGLAPIENTRY * eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
EGLBoolean (EGLAPIENTRY * eglTerminate)(EGLDisplay dpy);
|
||||
EGLBoolean (EGLAPIENTRY * eglChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list,
|
||||
@ -74,6 +73,8 @@ struct QWindowsLibEGL
|
||||
EGLBoolean (EGLAPIENTRY * eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
|
||||
__eglMustCastToProperFunctionPointerType (EGLAPIENTRY * eglGetProcAddress)(const char *procname);
|
||||
|
||||
EGLDisplay (EGLAPIENTRY * eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list);
|
||||
|
||||
private:
|
||||
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
|
||||
void *resolve(const char *name);
|
||||
|
Loading…
Reference in New Issue
Block a user