Skip to main content

script/dom/webgl/extensions/ext/
oestexturefloatlinear.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use dom_struct::dom_struct;
6use script_bindings::reflector::{Reflector, reflect_dom_object};
7
8use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions, constants as webgl};
9use crate::dom::bindings::reflector::DomGlobal;
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
12use crate::script_runtime::CanGc;
13
14#[dom_struct]
15pub(crate) struct OESTextureFloatLinear {
16    reflector_: Reflector,
17}
18
19impl OESTextureFloatLinear {
20    fn new_inherited() -> OESTextureFloatLinear {
21        Self {
22            reflector_: Reflector::new(),
23        }
24    }
25}
26
27impl WebGLExtension for OESTextureFloatLinear {
28    type Extension = OESTextureFloatLinear;
29    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureFloatLinear> {
30        reflect_dom_object(
31            Box::new(OESTextureFloatLinear::new_inherited()),
32            &*ctx.global(),
33            can_gc,
34        )
35    }
36
37    fn spec() -> WebGLExtensionSpec {
38        WebGLExtensionSpec::All
39    }
40
41    fn is_supported(ext: &WebGLExtensions) -> bool {
42        ext.supports_any_gl_extension(&["GL_OES_texture_float_linear", "GL_ARB_texture_float"])
43    }
44
45    fn enable(ext: &WebGLExtensions) {
46        ext.enable_filterable_tex_type(webgl::FLOAT);
47    }
48
49    fn name() -> &'static str {
50        "OES_texture_float_linear"
51    }
52}