script/dom/webgl/extensions/ext/
oestexturefloat.rs1use canvas_traits::webgl::{TexFormat, WebGLVersion};
6use dom_struct::dom_struct;
7
8use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions, constants as webgl};
9use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
12use crate::script_runtime::CanGc;
13
14#[dom_struct]
15pub(crate) struct OESTextureFloat {
16 reflector_: Reflector,
17}
18
19impl OESTextureFloat {
20 fn new_inherited() -> OESTextureFloat {
21 Self {
22 reflector_: Reflector::new(),
23 }
24 }
25}
26
27impl WebGLExtension for OESTextureFloat {
28 type Extension = OESTextureFloat;
29 fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureFloat> {
30 reflect_dom_object(
31 Box::new(OESTextureFloat::new_inherited()),
32 &*ctx.global(),
33 can_gc,
34 )
35 }
36
37 fn spec() -> WebGLExtensionSpec {
38 WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
39 }
40
41 fn is_supported(ext: &WebGLExtensions) -> bool {
42 ext.supports_any_gl_extension(&[
43 "GL_OES_texture_float",
44 "GL_ARB_texture_float",
45 "GL_EXT_color_buffer_float",
46 ])
47 }
48
49 fn enable(ext: &WebGLExtensions) {
50 ext.enable_tex_type(webgl::FLOAT);
51 ext.add_effective_tex_internal_format(TexFormat::RGBA, webgl::FLOAT, TexFormat::RGBA32f);
52 ext.add_effective_tex_internal_format(TexFormat::RGB, webgl::FLOAT, TexFormat::RGB32f);
53 ext.add_effective_tex_internal_format(
54 TexFormat::Luminance,
55 webgl::FLOAT,
56 TexFormat::Luminance32f,
57 );
58 ext.add_effective_tex_internal_format(TexFormat::Alpha, webgl::FLOAT, TexFormat::Alpha32f);
59 ext.add_effective_tex_internal_format(
60 TexFormat::LuminanceAlpha,
61 webgl::FLOAT,
62 TexFormat::LuminanceAlpha32f,
63 );
64 }
65
66 fn name() -> &'static str {
67 "OES_texture_float"
68 }
69}