summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glutin/src/application.rs20
-rw-r--r--src/settings.rs12
-rw-r--r--winit/src/settings.rs6
3 files changed, 34 insertions, 4 deletions
diff --git a/glutin/src/application.rs b/glutin/src/application.rs
index 88e67220..27a932fc 100644
--- a/glutin/src/application.rs
+++ b/glutin/src/application.rs
@@ -61,11 +61,23 @@ where
settings.id,
);
- let context = ContextBuilder::new()
+ let opengl_builder = ContextBuilder::new()
.with_vsync(true)
- // .with_gl(glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (2, 0)))
- .with_multisampling(C::sample_count(&compositor_settings) as u16)
- .build_windowed(builder, &event_loop)
+ .with_multisampling(C::sample_count(&compositor_settings) as u16);
+
+ let opengles_builder = opengl_builder.clone().with_gl(
+ glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (2, 0)),
+ );
+
+ let (first_builder, second_builder) = if settings.try_opengles_first {
+ (opengles_builder, opengl_builder)
+ } else {
+ (opengl_builder, opengles_builder)
+ };
+
+ let context = first_builder
+ .build_windowed(builder.clone(), &event_loop)
+ .or_else(|_| second_builder.build_windowed(builder, &event_loop))
.map_err(|error| {
use glutin::CreationError;
diff --git a/src/settings.rs b/src/settings.rs
index f7940a0b..c521a62a 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -55,6 +55,15 @@ pub struct Settings<Flags> {
///
/// [`Application`]: crate::Application
pub exit_on_close_request: bool,
+
+ /// Whether the [`Application`] should try to build the context
+ /// using OpenGL ES first then OpenGL.
+ ///
+ /// By default, it is disabled.
+ /// **Note:** Only works for the `glow` backend.
+ ///
+ /// [`Application`]: crate::Application
+ pub try_opengles_first: bool,
}
impl<Flags> Settings<Flags> {
@@ -73,6 +82,7 @@ impl<Flags> Settings<Flags> {
text_multithreading: default_settings.text_multithreading,
antialiasing: default_settings.antialiasing,
exit_on_close_request: default_settings.exit_on_close_request,
+ try_opengles_first: default_settings.try_opengles_first,
}
}
}
@@ -91,6 +101,7 @@ where
text_multithreading: false,
antialiasing: false,
exit_on_close_request: true,
+ try_opengles_first: false,
}
}
}
@@ -103,6 +114,7 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
window: settings.window.into(),
flags: settings.flags,
exit_on_close_request: settings.exit_on_close_request,
+ try_opengles_first: settings.try_opengles_first,
}
}
}
diff --git a/winit/src/settings.rs b/winit/src/settings.rs
index 045cb156..9a93824a 100644
--- a/winit/src/settings.rs
+++ b/winit/src/settings.rs
@@ -38,6 +38,12 @@ pub struct Settings<Flags> {
/// Whether the [`Application`] should exit when the user requests the
/// window to close (e.g. the user presses the close button).
pub exit_on_close_request: bool,
+
+ /// Whether the [`Application`] should try to build the context
+ /// using OpenGL ES first then OpenGL.
+ ///
+ /// NOTE: Only works for the `glow` backend.
+ pub try_opengles_first: bool,
}
/// The window settings of an application.