Skip to content

Commit

Permalink
If checking GL version fails attempt to create a GL ES context
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapdorian committed Jul 26, 2024
1 parent 901d326 commit 195ebfa
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,29 +538,33 @@ impl Inner {
{
// check if GL version is supported
egl.bind_api(khronos_egl::OPENGL_API).unwrap();
let ctx = egl
match egl
.create_context(display, config, None, &[khronos_egl::NONE])
.map_err(|e| {
crate::InstanceError::with_source(
String::from("unable to create GL context"),
e,
)
})?;
let _ = egl.make_current(display, None, None, Some(ctx));
let gl = unsafe {
glow::Context::from_loader_function(|name| {
egl.get_proc_address(name)
.map_or(ptr::null(), |p| p as *const _)
})
};
let gl_version_supported = *gl.version()
>= (glow::Version {
major: 3,
minor: 3,
..gl.version().clone()
});
let _ = egl.destroy_context(display, ctx);
gl_version_supported
}) {
Ok(ctx) => {
let _ = egl.make_current(display, None, None, Some(ctx));
let gl = unsafe {
glow::Context::from_loader_function(|name| {
egl.get_proc_address(name)
.map_or(ptr::null(), |p| p as *const _)
})
};
let gl_version_supported = *gl.version()
>= (glow::Version {
major: 3,
minor: 3,
..gl.version().clone()
});
let _ = egl.destroy_context(display, ctx);
gl_version_supported
}
Err(_) => false,
}
} else {
false
}
Expand Down

0 comments on commit 195ebfa

Please sign in to comment.