diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index aa273b4..03a9b55 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -253,11 +253,17 @@ impl> EGLDisplay { config_ids.set_len(num_configs as usize); } - // TODO: Deeper swap intervals might have some uses + if config_ids.is_empty() { + return Err(Error::NoAvailablePixelFormat); + } + let desired_swap_interval = if attributes.vsync { 1 } else { 0 }; - let config_ids = config_ids - .into_iter() + // try to select a config with the desired_swap_interval + // (but don't fail, as the margin might be very small on some cards and most configs are fine) + let config_id = config_ids + .iter() + .copied() .map(|config| unsafe { let mut min_swap_interval = 0; wrap_egl_call(|| { @@ -293,14 +299,8 @@ impl> EGLDisplay { .map_err(Error::ConfigFailed)? .into_iter() .flatten() - .collect::>(); - - if config_ids.is_empty() { - return Err(Error::NoAvailablePixelFormat); - } - - // TODO: Improve config selection - let config_id = config_ids[0]; + .next() + .unwrap_or_else(|| config_ids[0]); // analyzing each config macro_rules! attrib {