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