Unable to Force GLES2 Context (Still picks up the wrong GLES version)
p0ryae opened this issue · 5 comments
My device supports GLES2, but glutin instead uses GLES1 (OpenGL ES-CM 1.1), even when I force it via context:
let context_attributes = ContextAttributesBuilder::new()
.with_context_api(ContextApi::Gles(Some(glutin::context::Version::new(2, 0))))
.build(Some(raw_window_handle));
I also try to force the API level for the config:
let builder = ConfigTemplateBuilder::new()
.with_api(glutin::config::Api::GLES2)
.with_alpha_size(8)
.compatible_with_native_window(raw_window_handle)
.with_surface_type(ConfigSurfaceTypes::WINDOW);
Printing config.api() gives the following output, also indicating the existence of GLES2 support:
I/RustStdoutStderr( 3377): Config supports API: Api(GLES1 | GLES2)
The android device has an Ardeno 200 GPU, which has GLES2 support.
It's worth noting that I get an error about EGL_BAD_DISPLAY
initially before anything:
validate_display:254 error 3008 (EGL_BAD_DISPLAY)
I have no idea what's causing it anymore. Any ideas are appreciated.
Good news. Took me long but finally.
I managed to address this problem by adding CONTEXT_CLIENT_VERSION
attr, following with the major version (2 in my case).
if let Some(version) = version {
if version.major == 2 {
attrs.push(egl::CONTEXT_CLIENT_VERSION as EGLint);
attrs.push(version.major as EGLint);
}
}
Please note that this has to be right before the push for egl::NONE
attr. Otherwise, it is pointless.
I purposed my changes here: #1648
Please review on your appropriate time.
This somehow fell off my radar.
Could you tell me the EGL
version you have on that device? Because this API is an alias to
if let Some(version) = version {
attrs.push(egl::CONTEXT_MAJOR_VERSION as EGLint);
attrs.push(version.major as EGLint);
attrs.push(egl::CONTEXT_MINOR_VERSION as EGLint);
attrs.push(version.minor as EGLint);
}
We already have around.
To back that up with spec:
https://registry.khronos.org/EGL/sdk/docs/man/html/eglCreateContext.xhtml
EGL_CONTEXT_MAJOR_VERSION
Must be followed by an integer specifying the requested major version of an OpenGL or OpenGL ES context. The default value is 1. This attribute is an alias of the olderEGL_CONTEXT_CLIENT_VERSION
, and the tokens may be used interchangeably.
And in egl_bindings.rs
:
pub const CONTEXT_CLIENT_VERSION: types::EGLenum = 0x3098;
...
pub const CONTEXT_MAJOR_VERSION: types::EGLenum = 0x3098;
It's the same value
Yeah, but I think the issue is that EGL_CONTEXT_CLIENT_VERSION
is from version 1.3
, while the major/minor stuff is provided either from 1.5 or extensions, so should set it as a fallback when you don't have 1.5.