aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/egl
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-08-24 14:57:13 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-08-24 14:57:13 +0200
commite28a0bdb9775808b3885868f2369f9a1a0fe0bf3 (patch)
tree6680f85f6ec824e435dd0d535a33fab27b72e80e /src/api/egl
parent506c4ed6ea669c885c8a33668e0f8a00fd351989 (diff)
downloadglutin-e28a0bdb9775808b3885868f2369f9a1a0fe0bf3.tar.gz
glutin-e28a0bdb9775808b3885868f2369f9a1a0fe0bf3.zip
Do not crash in case of buggy EGL implementations that are missing eglGetPlatformDisplay
Diffstat (limited to 'src/api/egl')
-rw-r--r--src/api/egl/mod.rs36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs
index f6757ac..015396e 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -74,50 +74,70 @@ impl Context {
// calling `eglGetDisplay` or equivalent
let display = match native_display {
- NativeDisplay::X11(display) if has_dp_extension("EGL_KHR_platform_x11") => {
+ // Note: Some EGL implementations are missing the `eglGetPlatformDisplay(EXT)` symbol
+ // despite reporting `EGL_EXT_platform_base`. I'm pretty sure this is a bug.
+ // Therefore we detect whether the symbol is loaded in addition to checking for
+ // extensions.
+ NativeDisplay::X11(display) if has_dp_extension("EGL_KHR_platform_x11") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
// TODO: `PLATFORM_X11_SCREEN_KHR`
unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_X11_KHR, d as *mut _,
ptr::null()) }
},
- NativeDisplay::X11(display) if has_dp_extension("EGL_EXT_platform_x11") => {
+ NativeDisplay::X11(display) if has_dp_extension("EGL_EXT_platform_x11") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
// TODO: `PLATFORM_X11_SCREEN_EXT`
unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_X11_EXT, d as *mut _,
ptr::null()) }
},
- NativeDisplay::Gbm(display) if has_dp_extension("EGL_KHR_platform_gbm") => {
+ NativeDisplay::Gbm(display) if has_dp_extension("EGL_KHR_platform_gbm") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
ptr::null()) }
},
- NativeDisplay::Gbm(display) if has_dp_extension("EGL_MESA_platform_gbm") => {
+ NativeDisplay::Gbm(display) if has_dp_extension("EGL_MESA_platform_gbm") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
ptr::null()) }
},
- NativeDisplay::Wayland(display) if has_dp_extension("EGL_KHR_platform_wayland") => {
+ NativeDisplay::Wayland(display) if has_dp_extension("EGL_KHR_platform_wayland") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_WAYLAND_KHR, d as *mut _,
ptr::null()) }
},
- NativeDisplay::Wayland(display) if has_dp_extension("EGL_EXT_platform_wayland") => {
+ NativeDisplay::Wayland(display) if has_dp_extension("EGL_EXT_platform_wayland") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_WAYLAND_EXT, d as *mut _,
ptr::null()) }
},
- NativeDisplay::Android if has_dp_extension("EGL_KHR_platform_android") => {
+ NativeDisplay::Android if has_dp_extension("EGL_KHR_platform_android") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_ANDROID_KHR,
ffi::egl::DEFAULT_DISPLAY as *mut _, ptr::null()) }
},
- NativeDisplay::Device(display) if has_dp_extension("EGL_EXT_platform_device") => {
+ NativeDisplay::Device(display) if has_dp_extension("EGL_EXT_platform_device") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_DEVICE_EXT, display as *mut _,
ptr::null()) }
},