1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/// The size in bytes of one `UNSIGNED_SHORT` element: the stride of a
/// `Uint16` index buffer and of a 16-bit index byte offset.
pub const GL_U16_SIZE: u32 = 2;
/// The size in bytes of one `FLOAT` element, the width of every
/// `float32` vertex attribute component.
pub const GL_F32_SIZE: u32 = 4;
/// The size in bytes of one `UNSIGNED_INT` element: the stride of a
/// `Uint32` index buffer and of a 32-bit index byte offset.
pub const GL_U32_SIZE: u32 = 4;
/// The size in bytes of one RGBA texel, the stride of a tightly packed
/// `width * height * 4` pixel slice.
pub const GL_RGBA_TEXEL_SIZE: usize = 4;
/// The number of floats one `mat4` uniform column occupies, which is
/// also the length of the engine's own [`Matrix4x4`].
pub const GL_MAT4_FLOATS: usize = 16;
/// The size in bytes of one `mat4` uploaded through a uniform buffer,
/// the record stride of a block holding one transform per object.
pub const GL_MAT4_BYTES: u32 = 64;
/// The color-attachment index every single-target render-to-texture
/// framebuffer writes to.
pub const GL_DEFAULT_COLOR_ATTACHMENT: u32 = 0;
/// The `TEXTURE_2D` target every texture call in this module binds to.
pub const GL_TEXTURE_TARGET_2D: u32 = 0x0de1;
/// The mip level every allocation and sub-image write targets: the base
/// of the chain, and the only level a caller may write directly.
pub const GL_MIP_LEVEL_ZERO: f64 = 0.0;
/// The value the texture-unit shadow starts at, chosen so that unit zero
/// is a genuine change and the first bind of a frame is never skipped as
/// a no-op.
pub const GL_TEXTURE_UNIT_NONE: u32 = 0xffff_ffff;
/// The color-write mask that lets every channel through: red `0x1`,
/// green `0x2`, blue `0x4`, alpha `0x8`.
pub const GL_COLOR_WRITE_ALL: u32 = 0xf;
/// The red channel bit of a [`GlColorMask`].
pub const GL_COLOR_CHANNEL_RED: u32 = 0x1;
/// The green channel bit of a [`GlColorMask`].
pub const GL_COLOR_CHANNEL_GREEN: u32 = 0x2;
/// The blue channel bit of a [`GlColorMask`].
pub const GL_COLOR_CHANNEL_BLUE: u32 = 0x4;
/// The alpha channel bit of a [`GlColorMask`].
pub const GL_COLOR_CHANNEL_ALPHA: u32 = 0x8;
/// The address mode a sampler uses when its [`AddressMode`] is
/// `ClampToEdge`.
pub const GL_ADDRESS_CLAMP_TO_EDGE: u32 = 0x812f;
/// The address mode a sampler uses when its [`AddressMode`] is
/// `MirrorRepeat`.
pub const GL_ADDRESS_MIRRORED_REPEAT: u32 = 0x8370;
/// The address mode a sampler uses when its [`AddressMode`] is
/// `Repeat`.
pub const GL_ADDRESS_REPEAT: u32 = 0x2901;
/// The blend equation that adds the two scaled terms, the counterpart of
/// [`BlendOperation::Add`].
pub const GL_BLEND_EQUATION_ADD: u32 = 0x8006;
/// The blend factor that discards the term, the counterpart of
/// [`BlendFactor::Zero`].
pub const GL_BLEND_FACTOR_ZERO: u32 = 0;
/// The blend factor that passes the term through, the counterpart of
/// [`BlendFactor::One`].
pub const GL_BLEND_FACTOR_ONE: u32 = 1;
/// The blend factor `GL_ONE_MINUS_SRC_ALPHA`, the conventional
/// destination factor for alpha blending and the counterpart of
/// [`BlendFactor::OneMinusSourceAlpha`].
pub const GL_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: u32 = 0x0303;
/// The blend factor `GL_SRC_ALPHA`, the counterpart of
/// [`BlendFactor::SourceAlpha`].
pub const GL_BLEND_FACTOR_SRC_ALPHA: u32 = 0x0302;
/// The blend factor `GL_SRC_ALPHA_SATURATE`, the counterpart of
/// [`BlendFactor::SourceAlphaSaturated`].
pub const GL_BLEND_FACTOR_SRC_ALPHA_SATURATE: u32 = 0x0308;
/// The `FLOAT` vertex attribute component type, and the pixel type a
/// floating-point texture format uploads through.
pub const GL_TYPE_FLOAT: u32 = 0x1406;
/// The `INT` vertex attribute component type, the counterpart of
/// [`VertexAttributeFormat::Sint32`].
pub const GL_TYPE_INT: u32 = 0x1404;
/// The `UNSIGNED_BYTE` vertex attribute component type and the pixel type
/// every normalized eight-bit format uploads through.
pub const GL_TYPE_UNSIGNED_BYTE: u32 = 0x1401;
/// The `UNSIGNED_INT` vertex attribute component type, the counterpart of
/// [`VertexAttributeFormat::Uint32`].
pub const GL_TYPE_UNSIGNED_INT: u32 = 0x1405;
/// The `RED` sized-internal-format a single-channel `R32Float` texture
/// allocates.
pub const GL_FORMAT_R32F: u32 = 0x822e;
/// The `RED` pixel format matching [`GL_FORMAT_R32F`].
pub const GL_FORMAT_RED: u32 = 0x1903;
/// The info log substituted for a `createShader` that returned `None`,
/// which happens only when the context is lost or out of memory.
pub const GL_SHADER_CREATE_FAILED: &str = "createShader returned null";
/// The info log substituted for a `createProgram` that returned `None`,
/// which happens only when the context is lost or out of memory.
pub const GL_PROGRAM_CREATE_FAILED: &str = "createProgram returned null";
/// The name of the `texImage2D` method, looked up once and cached
/// because the `ImageBitmap` overload has no typed `web-sys` binding
/// without a feature this module does not enable for a single call.
pub const GL_METHOD_TEX_IMAGE_2D: &str = "texImage2D";
/// The `getContext` context id for a WebGL 2 context, which is a
/// different context object from the WebGL 1 one rather than a version
/// flag on the same object.
pub const GL_CONTEXT_ID_WEBGL2: &str = "webgl2";
/// The DOM tag name used when creating a throwaway canvas for the
/// capability probe.
pub const GL_DOM_TAG_CANVAS: &str = "canvas";
/// The stable error code reported when the configured selector matched no
/// element in the document.
pub const GL_ERROR_CANVAS_NOT_FOUND: &str = "WEBGL_CANVAS_NOT_FOUND";
/// The stable error code reported when the selector could not be
/// evaluated at all.
pub const GL_ERROR_CANVAS_QUERY: &str = "WEBGL_CANVAS_QUERY";
/// The stable error code reported when the browser exposes no WebGL 2
/// context for the canvas.
pub const GL_ERROR_CONTEXT_UNAVAILABLE: &str = "WEBGL_CONTEXT_UNAVAILABLE";
/// The stable error code reported when `getContext` threw instead of
/// returning `None`.
pub const GL_ERROR_CONTEXT_LOOKUP: &str = "WEBGL_CONTEXT_LOOKUP";
/// The stable error code reported when a `webgl2` context failed to cast
/// to `WebGl2RenderingContext`, which should not be reachable.
pub const GL_ERROR_CONTEXT_CAST: &str = "WEBGL_CONTEXT_CAST";