Skip to content

Commit

Permalink
Check Opengl version is 3.3+ before creating a context.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapdorian committed Jul 19, 2024
1 parent 12e07eb commit aa50156
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,42 @@ impl Inner {
.query_string(Some(display), khronos_egl::CLIENT_APIS)
.unwrap()
.to_string_lossy();
client_apis
if client_apis
.split(' ')
.any(|client_api| client_api == "OpenGL")
{
// check if GL version is supported
egl.bind_api(khronos_egl::OPENGL_API).unwrap();
let ctx = 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));
unsafe {
let gl = 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
}
} else {
false
}
} else {
false
};

egl.bind_api(if supports_opengl {
khronos_egl::OPENGL_API
} else {
Expand Down

0 comments on commit aa50156

Please sign in to comment.