diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs index 1a282eb6d5..55f9c6db77 100644 --- a/glutin/src/api/egl/display.rs +++ b/glutin/src/api/egl/display.rs @@ -259,38 +259,37 @@ impl Display { let extensions = CLIENT_EXTENSIONS.get().unwrap(); let mut attrs = Vec::::with_capacity(5); - let (platform, display) = match display { - RawDisplayHandle::Wayland(handle) - if extensions.contains("EGL_KHR_platform_wayland") => - { - (egl::PLATFORM_WAYLAND_KHR, handle.display.as_ptr()) - }, - RawDisplayHandle::Xlib(handle) if extensions.contains("EGL_KHR_platform_x11") => { - attrs.push(egl::PLATFORM_X11_SCREEN_KHR as EGLAttrib); - attrs.push(handle.screen as EGLAttrib); - ( - egl::PLATFORM_X11_KHR, - handle.display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()), - ) - }, - RawDisplayHandle::Gbm(handle) if extensions.contains("EGL_KHR_platform_gbm") => { - (egl::PLATFORM_GBM_KHR, handle.gbm_device.as_ptr()) - }, - RawDisplayHandle::Drm(_) => { - return Err(ErrorKind::NotSupported( + let (platform, display) = + match display { + RawDisplayHandle::Wayland(handle) + if extensions.contains("EGL_KHR_platform_wayland") => + { + (egl::PLATFORM_WAYLAND_KHR, handle.display.as_ptr()) + }, + RawDisplayHandle::Xlib(handle) if extensions.contains("EGL_KHR_platform_x11") => { + attrs.push(egl::PLATFORM_X11_SCREEN_KHR as EGLAttrib); + attrs.push(handle.screen as EGLAttrib); + ( + egl::PLATFORM_X11_KHR, + handle.display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()), + ) + }, + RawDisplayHandle::Gbm(handle) if extensions.contains("EGL_KHR_platform_gbm") => { + (egl::PLATFORM_GBM_KHR, handle.gbm_device.as_ptr()) + }, + RawDisplayHandle::Drm(_) => return Err(ErrorKind::NotSupported( "`DrmDisplayHandle` must be used with `egl::display::Display::with_device()`", ) - .into()) - }, - RawDisplayHandle::Android(_) if extensions.contains("EGL_KHR_platform_android") => { - (egl::PLATFORM_ANDROID_KHR, egl::DEFAULT_DISPLAY as *mut _) - }, - _ => { - return Err( - ErrorKind::NotSupported("provided display handle is not supported").into() - ) - }, - }; + .into()), + RawDisplayHandle::Android(_) if extensions.contains("EGL_KHR_platform_android") => { + (egl::PLATFORM_ANDROID_KHR, egl::DEFAULT_DISPLAY as *mut _) + }, + _ => { + return Err( + ErrorKind::NotSupported("provided display handle is not supported").into() + ) + }, + }; // Push at the end so we can pop it on failure let mut has_display_reference = extensions.contains("EGL_KHR_display_reference"); @@ -430,24 +429,25 @@ impl Display { } fn get_display(egl: &Egl, display: RawDisplayHandle) -> Result { - let display = match display { - RawDisplayHandle::Gbm(handle) => handle.gbm_device.as_ptr(), - RawDisplayHandle::Drm(_) => { - return Err(ErrorKind::NotSupported( + let display = + match display { + RawDisplayHandle::Gbm(handle) => handle.gbm_device.as_ptr(), + RawDisplayHandle::Drm(_) => return Err(ErrorKind::NotSupported( "`DrmDisplayHandle` must be used with `egl::display::Display::with_device()`", ) - .into()) - }, - RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => { - display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()) - }, - RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => egl::DEFAULT_DISPLAY as *mut _, - _ => { - return Err( - ErrorKind::NotSupported("provided display handle is not supported").into() - ) - }, - }; + .into()), + RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => { + display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()) + }, + RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => { + egl::DEFAULT_DISPLAY as *mut _ + }, + _ => { + return Err( + ErrorKind::NotSupported("provided display handle is not supported").into() + ) + }, + }; let display = unsafe { egl.GetDisplay(display) }; Self::check_display_error(display).map(EglDisplay::Legacy) diff --git a/glutin_egl_sys/build.rs b/glutin_egl_sys/build.rs index c8dbedf87a..1472556f22 100644 --- a/glutin_egl_sys/build.rs +++ b/glutin_egl_sys/build.rs @@ -19,35 +19,41 @@ fn main() { || target.contains("ios") { let mut file = File::create(dest.join("egl_bindings.rs")).unwrap(); - let reg = Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [ - "EGL_ANDROID_native_fence_sync", - "EGL_EXT_buffer_age", - "EGL_EXT_create_context_robustness", - "EGL_EXT_device_base", - "EGL_EXT_device_drm", - "EGL_EXT_device_drm_render_node", - "EGL_EXT_device_enumeration", - "EGL_EXT_device_query", - "EGL_EXT_device_query_name", - "EGL_EXT_pixel_format_float", - "EGL_EXT_platform_base", - "EGL_EXT_platform_device", - "EGL_EXT_platform_wayland", - "EGL_EXT_platform_x11", - "EGL_EXT_swap_buffers_with_damage", - "EGL_KHR_create_context", - "EGL_KHR_create_context_no_error", - "EGL_KHR_display_reference", - "EGL_KHR_fence_sync", - "EGL_KHR_image_base", - "EGL_KHR_platform_android", - "EGL_KHR_platform_gbm", - "EGL_KHR_platform_wayland", - "EGL_KHR_platform_x11", - "EGL_KHR_swap_buffers_with_damage", - "EGL_KHR_wait_sync", - "EGL_MESA_platform_gbm", - ]); + let reg = Registry::new( + Api::Egl, + (1, 5), + Profile::Core, + Fallbacks::All, + [ + "EGL_ANDROID_native_fence_sync", + "EGL_EXT_buffer_age", + "EGL_EXT_create_context_robustness", + "EGL_EXT_device_base", + "EGL_EXT_device_drm", + "EGL_EXT_device_drm_render_node", + "EGL_EXT_device_enumeration", + "EGL_EXT_device_query", + "EGL_EXT_device_query_name", + "EGL_EXT_pixel_format_float", + "EGL_EXT_platform_base", + "EGL_EXT_platform_device", + "EGL_EXT_platform_wayland", + "EGL_EXT_platform_x11", + "EGL_EXT_swap_buffers_with_damage", + "EGL_KHR_create_context", + "EGL_KHR_create_context_no_error", + "EGL_KHR_display_reference", + "EGL_KHR_fence_sync", + "EGL_KHR_image_base", + "EGL_KHR_platform_android", + "EGL_KHR_platform_gbm", + "EGL_KHR_platform_wayland", + "EGL_KHR_platform_x11", + "EGL_KHR_swap_buffers_with_damage", + "EGL_KHR_wait_sync", + "EGL_MESA_platform_gbm", + ], + ); if target.contains("ios") { reg.write_bindings(gl_generator::StaticStructGenerator, &mut file) diff --git a/glutin_glx_sys/build.rs b/glutin_glx_sys/build.rs index c9ce54b70b..0c933efb1a 100644 --- a/glutin_glx_sys/build.rs +++ b/glutin_glx_sys/build.rs @@ -21,22 +21,28 @@ fn main() { .unwrap(); let mut file = File::create(dest.join("glx_extra_bindings.rs")).unwrap(); - Registry::new(Api::Glx, (1, 4), Profile::Core, Fallbacks::All, [ - "GLX_ARB_context_flush_control", - "GLX_ARB_create_context", - "GLX_ARB_create_context_no_error", - "GLX_ARB_create_context_profile", - "GLX_ARB_create_context_robustness", - "GLX_ARB_fbconfig_float", - "GLX_ARB_framebuffer_sRGB", - "GLX_ARB_multisample", - "GLX_EXT_buffer_age", - "GLX_EXT_create_context_es2_profile", - "GLX_EXT_framebuffer_sRGB", - "GLX_EXT_swap_control", - "GLX_MESA_swap_control", - "GLX_SGI_swap_control", - ]) + Registry::new( + Api::Glx, + (1, 4), + Profile::Core, + Fallbacks::All, + [ + "GLX_ARB_context_flush_control", + "GLX_ARB_create_context", + "GLX_ARB_create_context_no_error", + "GLX_ARB_create_context_profile", + "GLX_ARB_create_context_robustness", + "GLX_ARB_fbconfig_float", + "GLX_ARB_framebuffer_sRGB", + "GLX_ARB_multisample", + "GLX_EXT_buffer_age", + "GLX_EXT_create_context_es2_profile", + "GLX_EXT_framebuffer_sRGB", + "GLX_EXT_swap_control", + "GLX_MESA_swap_control", + "GLX_SGI_swap_control", + ], + ) .write_bindings(gl_generator::StructGenerator, &mut file) .unwrap(); } diff --git a/glutin_wgl_sys/build.rs b/glutin_wgl_sys/build.rs index ab15682fd0..461395a363 100644 --- a/glutin_wgl_sys/build.rs +++ b/glutin_wgl_sys/build.rs @@ -16,22 +16,28 @@ fn main() { .unwrap(); let mut file = File::create(dest.join("wgl_extra_bindings.rs")).unwrap(); - Registry::new(Api::Wgl, (1, 0), Profile::Core, Fallbacks::All, [ - "WGL_ARB_context_flush_control", - "WGL_ARB_create_context", - "WGL_ARB_create_context_no_error", - "WGL_ARB_create_context_profile", - "WGL_ARB_create_context_robustness", - "WGL_ARB_extensions_string", - "WGL_ARB_framebuffer_sRGB", - "WGL_ARB_multisample", - "WGL_ARB_pixel_format", - "WGL_ARB_pixel_format_float", - "WGL_EXT_create_context_es2_profile", - "WGL_EXT_extensions_string", - "WGL_EXT_framebuffer_sRGB", - "WGL_EXT_swap_control", - ]) + Registry::new( + Api::Wgl, + (1, 0), + Profile::Core, + Fallbacks::All, + [ + "WGL_ARB_context_flush_control", + "WGL_ARB_create_context", + "WGL_ARB_create_context_no_error", + "WGL_ARB_create_context_profile", + "WGL_ARB_create_context_robustness", + "WGL_ARB_extensions_string", + "WGL_ARB_framebuffer_sRGB", + "WGL_ARB_multisample", + "WGL_ARB_pixel_format", + "WGL_ARB_pixel_format_float", + "WGL_EXT_create_context_es2_profile", + "WGL_EXT_extensions_string", + "WGL_EXT_framebuffer_sRGB", + "WGL_EXT_swap_control", + ], + ) .write_bindings(gl_generator::StructGenerator, &mut file) .unwrap(); }