panic when trying to create GL context on GLES-only display
Closed this issue · 2 comments
When creating a new GL context with ContextBuilder
and sticking to the default GlAttributes
, the version: GlRequest
defaults to GlRequest::Latest
, which is documented as follows:
Request the latest version of the “best” API of this platform.
On desktop, will try OpenGL.
When connecting to a GLES-only display on Linux, for example, we hit an unimplemented!()
in src/api/egl/mod.rs
: First bind_and_get_api
is called with GlRequest::Latest
. The egl.BindAPI(ffi::egl::OPENGL_API)
fails and instead egl.BindAPI(ffi::egl::OPENGL_ES_API)
succeeds, causing the function to return Ok((None, Api::OpenGlEs))
, where None
represents the version part. Subsequently choose_fbconfig
is called with Api::OpenGlEs
as value for the api
parameter and None
for version
. That means we hit (Api::OpenGlEs, _) => unimplemented!(),
in the match in the function and the run-time panics.
I think the correct behavior would be to either
1. Try to request GLES 2.0 compatible configs ("something" that will likely work)
2. Gently fail with for example `Err(CreationError::NoAvailablePixelFormat)`
This happens with version 0.27.0.
I am also getting this error while running the tutorial for
https://bfnightly.bracketproductions.com/rustbook/chapter_1.html
Ive tracked it from bracket-lib down to this library.
3: core::option::Option<T>::unwrap
at /rustc/2885c474823637ae69c5967327327a337aebedb2/library/core/src/option.rs:746:21
4: glutin::api::egl::Context::new
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/api/egl/mod.rs:422:19
5: glutin::platform_impl::platform_impl::wayland::Context::new_raw_context
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/wayland.rs:124:13
6: glutin::platform_impl::platform_impl::wayland::Context::new
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/wayland.rs:105:23
7: glutin::platform_impl::platform_impl::Context::new_windowed
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/mod.rs:113:20
8: glutin::windowed::<impl glutin::ContextBuilder<T>>::build_windowed
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/windowed.rs:341:9
9: bracket_terminal::hal::native::init::init_raw
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/bracket-terminal-0.8.5/src/hal/native/init.rs:21:28
10: bracket_terminal::initializer::BTermBuilder::build
at /home/nbstrong/.cargo/registry/src/github.com-1ecc6299db9ec823/bracket-terminal-0.8.5/src/initializer.rs:488:27
11: rusty_dagger::main
at ./src/main.rs:13:19
This is on Windows 11 running Ubuntu through WSLg.
pub fn init_raw<S: ToString>(
width_pixels: u32,
height_pixels: u32,
window_title: S,
platform_hints: InitHints,
) -> BResult<BTerm> {
let el = EventLoop::new();
let wb = WindowBuilder::new()
.with_title(window_title.to_string())
.with_inner_size(LogicalSize::new(
f64::from(width_pixels),
f64::from(height_pixels),
));
let windowed_context = ContextBuilder::new()
.with_gl(platform_hints.gl_version)
.with_gl_profile(platform_hints.gl_profile)
.with_hardware_acceleration(Some(true))
.with_vsync(platform_hints.vsync)
.with_srgb(platform_hints.srgb)
.build_windowed(wb, &el)?;
let windowed_context = unsafe { windowed_context.make_current().unwrap() };