aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/renderer/platform.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-02-07 22:08:24 +0300
committerGitHub <noreply@github.com>2023-02-07 22:08:24 +0300
commit2d27fff796791bf164af8605f97eda16fcb0f724 (patch)
tree9e10e82e687f0dd08d7be58bd1d2ef47c5215ef6 /alacritty/src/renderer/platform.rs
parent8b3f229c3d26b9736a53698e9593b8ae5db6c6dd (diff)
downloadr-alacritty-2d27fff796791bf164af8605f97eda16fcb0f724.tar.gz
r-alacritty-2d27fff796791bf164af8605f97eda16fcb0f724.tar.bz2
r-alacritty-2d27fff796791bf164af8605f97eda16fcb0f724.zip
Make gles2 renderer actually gles2
Fixes #6209.
Diffstat (limited to 'alacritty/src/renderer/platform.rs')
-rw-r--r--alacritty/src/renderer/platform.rs38
1 files changed, 24 insertions, 14 deletions
diff --git a/alacritty/src/renderer/platform.rs b/alacritty/src/renderer/platform.rs
index 77826100..c9802e0a 100644
--- a/alacritty/src/renderer/platform.rs
+++ b/alacritty/src/renderer/platform.rs
@@ -81,21 +81,31 @@ pub fn create_gl_context(
gl_config: &Config,
raw_window_handle: Option<RawWindowHandle>,
) -> GlutinResult<NotCurrentContext> {
- let context_attributes = ContextAttributesBuilder::new()
- .with_context_api(ContextApi::OpenGl(Some(Version::new(3, 3))))
- .build(raw_window_handle);
-
- unsafe {
- if let Ok(gl_context) = gl_display.create_context(gl_config, &context_attributes) {
- Ok(gl_context)
- } else {
- let context_attributes = ContextAttributesBuilder::new()
- .with_profile(GlProfile::Compatibility)
- .with_context_api(ContextApi::OpenGl(Some(Version::new(2, 1))))
- .build(raw_window_handle);
- gl_display.create_context(gl_config, &context_attributes)
- }
+ let mut profiles = [
+ ContextAttributesBuilder::new()
+ .with_context_api(ContextApi::OpenGl(Some(Version::new(3, 3))))
+ .build(raw_window_handle),
+ // Try gles before OpenGL 2.1 as it tends to be more stable.
+ ContextAttributesBuilder::new()
+ .with_context_api(ContextApi::Gles(Some(Version::new(2, 0))))
+ .build(raw_window_handle),
+ ContextAttributesBuilder::new()
+ .with_profile(GlProfile::Compatibility)
+ .with_context_api(ContextApi::OpenGl(Some(Version::new(2, 1))))
+ .build(raw_window_handle),
+ ]
+ .into_iter();
+
+ // Try the optimal config first.
+ let mut picked_context =
+ unsafe { gl_display.create_context(gl_config, &profiles.next().unwrap()) };
+
+ // Try the fallback ones.
+ while let (Err(_), Some(profile)) = (picked_context.as_ref(), profiles.next()) {
+ picked_context = unsafe { gl_display.create_context(gl_config, &profile) };
}
+
+ picked_context
}
pub fn create_gl_surface(