UNPKG

3.44 kBTypeScriptView Raw
1// render-gl1/declarations - WebGL 1 extension definitions (beyond TS lib)
2// Extracted from Stardazed - https://github.com/stardazed/stardazed
3
4interface HTMLCanvasElement {
5 getContext(
6 contextId: "webgl" | "experimental-webgl",
7 contextAttributes?: WebGLContextAttributes,
8 ): (WebGLRenderingContext & WebGL1Extensions) | null;
9}
10
11interface WebGL1Extensions {
12 getExtension(name: "EXT_color_buffer_half_float"): EXT_color_buffer_half_float;
13
14 getExtension(name: "WEBGL_compressed_texture_atc"): WEBGL_compressed_texture_atc;
15 getExtension(name: "WEBGL_compressed_texture_etc1"): WEBGL_compressed_texture_etc1;
16 getExtension(name: "WEBGL_compressed_texture_pvrtc"): WEBKIT_WEBGL_compressed_texture_pvrtc;
17
18 // Prefixed versions appearing in the wild as per February 2018
19 getExtension(name: "WEBKIT_EXT_texture_filter_anisotropic"): EXT_texture_filter_anisotropic; // Chrome
20 getExtension(name: "WEBKIT_WEBGL_compressed_texture_atc"): WEBGL_compressed_texture_atc; // Android
21 getExtension(name: "WEBKIT_WEBGL_compressed_texture_pvrtc"): WEBKIT_WEBGL_compressed_texture_pvrtc; // Safari iOS
22 getExtension(name: "WEBKIT_WEBGL_compressed_texture_s3tc"): WEBGL_compressed_texture_s3tc; // Chrome
23 getExtension(name: "WEBKIT_WEBGL_depth_texture"): WEBGL_depth_texture; // Chrome
24 getExtension(name: "WEBKIT_WEBGL_lose_context"): WEBGL_lose_context; // Chrome
25}
26
27// WebGL 1 Type Branding
28interface WebGLObject {
29 readonly __WebGLObject: void;
30}
31interface WebGLBuffer {
32 readonly __WebGLBuffer: void;
33}
34interface WebGLFramebuffer {
35 readonly __WebGLFramebuffer: void;
36}
37interface WebGLProgram {
38 readonly __WebGLProgram: void;
39}
40interface WebGLRenderbuffer {
41 readonly __WebGLRenderbuffer: void;
42}
43interface WebGLShader {
44 readonly __WebGLShader: void;
45}
46interface WebGLTexture {
47 readonly __WebGLTexture: void;
48}
49interface WebGLUniformLocation {
50 readonly __WebGLUniformLocation: void;
51}
52interface WebGLVertexArrayObjectOES extends WebGLObject {
53 readonly __WebGLVertexArrayObjectOES: void;
54}
55
56interface EXT_frag_depth {
57 readonly __EXT_frag_depth: void;
58}
59interface EXT_shader_texture_lod {
60 readonly __EXT_shader_texture_lod: void;
61}
62
63interface OES_element_index_uint {
64 readonly __OESElementIndexUint: void;
65}
66interface OES_texture_float {
67 readonly __OES_texture_float: void;
68}
69interface OES_texture_float_linear {
70 readonly __OES_texture_float_linear: void;
71}
72interface OES_texture_half_float_linear {
73 readonly __OES_texture_half_float_linear: void;
74}
75
76interface OES_vertex_array_object {
77 // TS's lib.dom (as of v3.1.3) does not specify the nulls
78 createVertexArrayOES(): WebGLVertexArrayObjectOES | null;
79 deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
80 isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): boolean;
81 bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
82}
83
84interface WEBGL_compressed_texture_atc {
85 readonly COMPRESSED_RGB_ATC_WEBGL: number;
86 readonly COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: number;
87 readonly COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: number;
88}
89
90interface WEBKIT_WEBGL_compressed_texture_pvrtc {
91 readonly COMPRESSED_RGB_PVRTC_4BPPV1_IMG: number;
92 readonly COMPRESSED_RGB_PVRTC_2BPPV1_IMG: number;
93 readonly COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: number;
94 readonly COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: number;
95}