My case is like this, I just want to get the field of WebGlContextAttributes
struct.
let antialias_info = gl.get_context_attributes().unwrap();
match antialias_info.antialias {
// ...
}
I get the following error:
attempted to take value of method `antialias` on type `web_sys::WebGlContextAttributes` method, not a field.
And I have read the doc WebGlContextAttributes, but still don't know how to get field value of it.
It does look like the
WebGlContextAttributes
type is solely designed as a builder to be used withHtmlCanvasElement::get_context_with_context_options()
but that disregards that it should also be used to get attributes fromWebGlRenderingContext::get_context_attributes()
. I see you have already created an issue to address this.As a workaround, you should be able to use the generic mechanism for getting object properties. From Accessing Properties of Untyped JavaScript Values in the wasm-bindgen guide you can use
js_sys::Reflect::get()
like so: