@thi.ng/wasm-api-webgl 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gl.js ADDED
@@ -0,0 +1,222 @@
1
+ import { GLType } from "@thi.ng/api/typedarray";
2
+ import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
3
+ import { unsupported } from "@thi.ng/errors/unsupported";
4
+ import { WasmDomModule } from "@thi.ng/wasm-api-dom";
5
+ import { ObjectIndex } from "@thi.ng/wasm-api/object-index";
6
+ import { compileModel } from "@thi.ng/webgl/buffer";
7
+ import { draw } from "@thi.ng/webgl/draw";
8
+ import { defShader } from "@thi.ng/webgl/shader";
9
+ import { defTexture } from "@thi.ng/webgl/texture";
10
+ import {
11
+ $AttribUpdateSpec,
12
+ $ModelSpec,
13
+ $ShaderSpec,
14
+ $TextureSpec,
15
+ $UniformValue,
16
+ $WebGLContextOpts,
17
+ ImageType,
18
+ ShaderAttribType,
19
+ UniformType,
20
+ WebGLPowerPreference
21
+ } from "./generated/api.js";
22
+ const WasmWebGLModule = {
23
+ id: "webgl",
24
+ deps: [WasmDomModule],
25
+ factory: () => new WasmWebGL()
26
+ };
27
+ class WasmWebGL {
28
+ parent;
29
+ dom;
30
+ contexts;
31
+ models;
32
+ shaders;
33
+ textures;
34
+ $ShaderSpec;
35
+ $ModelSpec;
36
+ $TextureSpec;
37
+ $UniformValue;
38
+ $AttribUpdateSpec;
39
+ $WebGLContextOpts;
40
+ async init(parent) {
41
+ this.parent = parent;
42
+ this.dom = this.parent.modules[WasmDomModule.id];
43
+ const defIndex = (name) => new ObjectIndex({ name, logger: parent.logger });
44
+ this.contexts = defIndex("ctx");
45
+ this.shaders = defIndex("sha");
46
+ this.models = defIndex("mod");
47
+ this.textures = defIndex("tex");
48
+ this.$AttribUpdateSpec = $AttribUpdateSpec(this.parent);
49
+ this.$ModelSpec = $ModelSpec(this.parent);
50
+ this.$ShaderSpec = $ShaderSpec(this.parent);
51
+ this.$TextureSpec = $TextureSpec(this.parent);
52
+ this.$UniformValue = $UniformValue(this.parent);
53
+ this.$WebGLContextOpts = $WebGLContextOpts(this.parent);
54
+ return true;
55
+ }
56
+ getImports() {
57
+ return {
58
+ canvasGLContext: (canvasID, optsAddr) => {
59
+ const opts = this.$WebGLContextOpts.instance(optsAddr);
60
+ const ctx = this.dom.elements.get(canvasID).getContext("webgl2", {
61
+ alpha: !!opts.alpha,
62
+ antialias: !!opts.antialias,
63
+ depth: !!opts.depth,
64
+ desynchronized: !!opts.desynchronized,
65
+ failIfMajorPerformanceCaveat: !!opts.failIfMajorPerformanceCaveat,
66
+ powerPreference: WebGLPowerPreference[opts.powerPreference].replace("_", "-"),
67
+ premultipliedAlpha: !!opts.premultipliedAlpha,
68
+ preserveDrawingBuffer: !!opts.preserveDrawingBuffer,
69
+ stencil: !!opts.stencil
70
+ });
71
+ if (!ctx) unsupported("WebGL2 not supported");
72
+ return this.contexts.addUnique(ctx);
73
+ },
74
+ createShader: (ctxID, addr) => {
75
+ const buildAttribs = (spec2) => {
76
+ const attribs = {};
77
+ for (let att of spec2.attribs) {
78
+ attribs[att.name.deref()] = ShaderAttribType[att.type];
79
+ }
80
+ return attribs;
81
+ };
82
+ const buildVarying = (spec2) => {
83
+ const varyings = {};
84
+ for (let v of spec2.varying) {
85
+ varyings[v.name.deref()] = ShaderAttribType[v.type];
86
+ }
87
+ return varyings;
88
+ };
89
+ const buildUniforms = (spec2) => {
90
+ const uniforms = {};
91
+ for (let uni of spec2.uniforms) {
92
+ uniforms[uni.name.deref()] = [
93
+ UniformType[uni.type],
94
+ uni.default[UniformType[uni.type]]
95
+ ];
96
+ }
97
+ return uniforms;
98
+ };
99
+ const gl = this.contexts.get(ctxID);
100
+ const spec = this.$ShaderSpec.instance(addr);
101
+ const $spec = {
102
+ vs: spec.vs.deref(),
103
+ fs: spec.fs.deref(),
104
+ attribs: buildAttribs(spec),
105
+ varying: buildVarying(spec),
106
+ uniforms: buildUniforms(spec)
107
+ };
108
+ const shader = defShader(gl, $spec, {
109
+ logger: this.parent.logger
110
+ });
111
+ return this.shaders.add(shader);
112
+ },
113
+ createModel: (ctxID, addr) => {
114
+ const buildAttribs = (specs) => {
115
+ const attribs = {};
116
+ for (let att of specs) {
117
+ attribs[att.name.deref()] = {
118
+ type: att.type,
119
+ size: att.size,
120
+ stride: att.stride,
121
+ offset: att.offset,
122
+ data: att.data[GLType[att.type].toLowerCase()]
123
+ };
124
+ }
125
+ return attribs;
126
+ };
127
+ const buildUniforms = (specs) => {
128
+ const uniforms = {};
129
+ for (let uni of specs) {
130
+ uniforms[uni.name.deref()] = uni.value[UniformType[uni.type]];
131
+ }
132
+ return uniforms;
133
+ };
134
+ const gl = this.contexts.get(ctxID);
135
+ const spec = this.$ModelSpec.instance(addr);
136
+ const modelSpec = {
137
+ shader: this.shaders.get(spec.shader),
138
+ attribs: buildAttribs(spec.attribs),
139
+ uniforms: buildUniforms(spec.uniforms),
140
+ mode: spec.mode,
141
+ num: spec.num
142
+ };
143
+ if (spec.numInstances) {
144
+ modelSpec.instances = {
145
+ attribs: buildAttribs(spec.instances),
146
+ num: spec.numInstances
147
+ };
148
+ }
149
+ if (spec.textures.length) {
150
+ modelSpec.textures = [...spec.textures].map(
151
+ (id) => this.textures.get(id)
152
+ );
153
+ }
154
+ return this.models.add(compileModel(gl, modelSpec));
155
+ },
156
+ createTexture: (ctxID, addr) => {
157
+ const gl = this.contexts.get(ctxID);
158
+ const spec = this.$TextureSpec.instance(addr);
159
+ const img = spec.imgType !== ImageType.none ? spec.img[ImageType[spec.imgType]] : null;
160
+ const tex = defTexture(gl, {
161
+ width: spec.width,
162
+ height: spec.height,
163
+ depth: spec.depth,
164
+ image: img,
165
+ filter: spec.filter,
166
+ format: spec.format,
167
+ wrap: spec.wrap,
168
+ target: spec.target,
169
+ type: spec.type
170
+ });
171
+ return this.textures.add(tex);
172
+ },
173
+ uniformInt: this.uniformScalar.bind(this),
174
+ uniformUInt: this.uniformScalar.bind(this),
175
+ uniformFloat: this.uniformScalar.bind(this),
176
+ uniformVec: (modelID, name, value, size) => this.uniformVec(modelID, name, "f32", value >> 2, size),
177
+ uniformIVec: (modelID, name, value, size) => this.uniformVec(modelID, name, "i32", value >> 2, size),
178
+ uniformUVec: (modelID, name, value, size) => this.uniformVec(modelID, name, "u32", value >> 2, size),
179
+ updateAttrib: (modelID, name, addr) => {
180
+ const model = this.models.get(modelID);
181
+ const id = this.parent.getString(name);
182
+ const attrib = model.attribs[id];
183
+ if (!attrib) illegalArgs(`unknown attrib: ${id}`);
184
+ const spec = this.$AttribUpdateSpec.instance(addr);
185
+ attrib.buffer.setChunk(
186
+ spec.data[GLType[spec.type].toLowerCase()],
187
+ spec.offset
188
+ );
189
+ },
190
+ draw: (modelID) => {
191
+ draw(this.models.get(modelID));
192
+ },
193
+ clear: (ctxID, r, g, b, a) => {
194
+ const gl = this.contexts.get(ctxID);
195
+ gl.clearColor(r, g, b, a);
196
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
197
+ }
198
+ };
199
+ }
200
+ /**
201
+ * Shared handler for setting a scalar uniform in a ModelSpec
202
+ *
203
+ * @param modelID
204
+ * @param name
205
+ * @param value
206
+ */
207
+ uniformScalar(modelID, name, value) {
208
+ const spec = this.models.get(modelID);
209
+ const id = this.parent.getString(name);
210
+ spec.uniforms[id] = value;
211
+ }
212
+ uniformVec(modelID, name, type, addr, size) {
213
+ const spec = this.models.get(modelID);
214
+ const id = this.parent.getString(name);
215
+ const val = this.parent[type].subarray(addr, addr + size).slice();
216
+ spec.uniforms[id] = val;
217
+ }
218
+ }
219
+ export {
220
+ WasmWebGL,
221
+ WasmWebGLModule
222
+ };
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./api.js";
2
+ export * from "./gl.js";
3
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./gl.js";
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@thi.ng/wasm-api-webgl",
3
+ "version": "0.1.0",
4
+ "description": "WebGL bridge API for hybrid TypeScript & WASM (Zig) applications",
5
+ "type": "module",
6
+ "module": "./index.js",
7
+ "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/thi-ng/umbrella.git"
12
+ },
13
+ "homepage": "https://thi.ng/wasm-api-webgl",
14
+ "funding": [
15
+ {
16
+ "type": "github",
17
+ "url": "https://github.com/sponsors/postspectacular"
18
+ },
19
+ {
20
+ "type": "patreon",
21
+ "url": "https://patreon.com/thing_umbrella"
22
+ }
23
+ ],
24
+ "author": "Karsten Schmidt (https://thi.ng)",
25
+ "license": "Apache-2.0",
26
+ "scripts": {
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
30
+ "build:types": "npx wasm-api-bindgen -a analytics.json --config src/typedefs-config.json --lang ts -o src/generated/api.ts --lang zig -o zig/api.zig src/typedefs.json",
31
+ "clean": "bun ../../tools/src/clean-package.ts",
32
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
33
+ "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
34
+ "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
35
+ "pub": "yarn npm publish --access public",
36
+ "test": "bun test",
37
+ "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
38
+ },
39
+ "dependencies": {
40
+ "@thi.ng/api": "^8.11.9",
41
+ "@thi.ng/errors": "^2.5.15",
42
+ "@thi.ng/wasm-api": "^2.0.0",
43
+ "@thi.ng/wasm-api-dom": "^1.0.0",
44
+ "@thi.ng/webgl": "^6.9.12"
45
+ },
46
+ "devDependencies": {
47
+ "@microsoft/api-extractor": "^7.47.5",
48
+ "@thi.ng/wasm-api-bindgen": "^0.6.0",
49
+ "esbuild": "^0.23.0",
50
+ "typedoc": "^0.26.5",
51
+ "typescript": "^5.5.4"
52
+ },
53
+ "keywords": [
54
+ "browser",
55
+ "codegen",
56
+ "interop",
57
+ "shader",
58
+ "typescript",
59
+ "webassembly",
60
+ "webgl",
61
+ "zig"
62
+ ],
63
+ "publishConfig": {
64
+ "access": "public"
65
+ },
66
+ "browser": {
67
+ "process": false,
68
+ "setTimeout": false
69
+ },
70
+ "engines": {
71
+ "node": ">=18"
72
+ },
73
+ "files": [
74
+ "./*.js",
75
+ "./*.d.ts",
76
+ "zig",
77
+ "generated"
78
+ ],
79
+ "exports": {
80
+ ".": {
81
+ "default": "./index.js"
82
+ },
83
+ "./api": {
84
+ "default": "./api.js"
85
+ },
86
+ "./gl": {
87
+ "default": "./gl.js"
88
+ }
89
+ },
90
+ "thi.ng": {
91
+ "parent": "@thi.ng/wasm-api",
92
+ "related": [
93
+ "wasm-api-canvas",
94
+ "webgl"
95
+ ],
96
+ "status": "alpha",
97
+ "year": 2024
98
+ },
99
+ "gitHead": "f6e26ea1142525171de5d36b9c3119f2782bb437\n"
100
+ }
package/zig/api.zig ADDED
@@ -0,0 +1,360 @@
1
+ //! Generated by @thi.ng/wasm-api-bindgen at 2024-08-17T16:17:33.290Z
2
+ //! DO NOT EDIT!
3
+
4
+ const std = @import("std");
5
+ const bindgen = @import("wasm-api-bindgen");
6
+
7
+ pub const ShaderAttribSpecSlice = bindgen.Slice([]ShaderAttribSpec, [*]ShaderAttribSpec);
8
+ pub const ConstShaderAttribSpecSlice = bindgen.Slice([]const ShaderAttribSpec, [*]const ShaderAttribSpec);
9
+
10
+ pub const ShaderVaryingSpecSlice = bindgen.Slice([]ShaderVaryingSpec, [*]ShaderVaryingSpec);
11
+ pub const ConstShaderVaryingSpecSlice = bindgen.Slice([]const ShaderVaryingSpec, [*]const ShaderVaryingSpec);
12
+
13
+ pub const ShaderUniformSpecSlice = bindgen.Slice([]ShaderUniformSpec, [*]ShaderUniformSpec);
14
+ pub const ConstShaderUniformSpecSlice = bindgen.Slice([]const ShaderUniformSpec, [*]const ShaderUniformSpec);
15
+
16
+ pub const ModelAttribSpecSlice = bindgen.Slice([]ModelAttribSpec, [*]ModelAttribSpec);
17
+ pub const ConstModelAttribSpecSlice = bindgen.Slice([]const ModelAttribSpec, [*]const ModelAttribSpec);
18
+
19
+ pub const ModelUniformSlice = bindgen.Slice([]ModelUniform, [*]ModelUniform);
20
+ pub const ConstModelUniformSlice = bindgen.Slice([]const ModelUniform, [*]const ModelUniform);
21
+
22
+ pub const I32Slice = bindgen.Slice([]i32, [*]i32);
23
+ pub const ConstI32Slice = bindgen.Slice([]const i32, [*]const i32);
24
+
25
+ pub const I8Slice = bindgen.Slice([]i8, [*]i8);
26
+ pub const ConstI8Slice = bindgen.Slice([]const i8, [*]const i8);
27
+
28
+ pub const U8Slice = bindgen.Slice([]u8, [*]u8);
29
+ pub const ConstU8Slice = bindgen.Slice([]const u8, [*]const u8);
30
+
31
+ pub const I16Slice = bindgen.Slice([]i16, [*]i16);
32
+ pub const ConstI16Slice = bindgen.Slice([]const i16, [*]const i16);
33
+
34
+ pub const U16Slice = bindgen.Slice([]u16, [*]u16);
35
+ pub const ConstU16Slice = bindgen.Slice([]const u16, [*]const u16);
36
+
37
+ pub const U32Slice = bindgen.Slice([]u32, [*]u32);
38
+ pub const ConstU32Slice = bindgen.Slice([]const u32, [*]const u32);
39
+
40
+ pub const F32Slice = bindgen.Slice([]f32, [*]f32);
41
+ pub const ConstF32Slice = bindgen.Slice([]const f32, [*]const f32);
42
+
43
+ /// Syntax sugar for: `ConstModelAttribSpecSlice.wrap()`
44
+ pub inline fn modelAttribs(items: []const ModelAttribSpec) ConstModelAttribSpecSlice {
45
+ return ConstModelAttribSpecSlice.wrap(items);
46
+ }
47
+ /// Syntax sugar for: `ConstModelUniformSlice.wrap()`
48
+ pub inline fn modelUniforms(items: []const ModelUniform) ConstModelUniformSlice {
49
+ return ConstModelUniformSlice.wrap(items);
50
+ }
51
+ /// Syntax sugar for: `ConstShaderAttribSpecSlice.wrap()`
52
+ pub inline fn shaderAttribs(items: []const ShaderAttribSpec) ConstShaderAttribSpecSlice {
53
+ return ConstShaderAttribSpecSlice.wrap(items);
54
+ }
55
+
56
+ /// Syntax sugar for: `ShaderVaryingSpecSlice.wrap()`
57
+ pub inline fn shaderVaryings(items: []const ShaderVaryingSpec) ConstShaderVaryingSpecSlice {
58
+ return ConstShaderVaryingSpecSlice.wrap(items);
59
+ }
60
+
61
+ /// Syntax sugar for: `ConstShaderUniformSpecSlice.wrap()`
62
+ pub inline fn shaderUniforms(items: []const ShaderUniformSpec) ConstShaderUniformSpecSlice {
63
+ return ConstShaderUniformSpecSlice.wrap(items);
64
+ }
65
+
66
+ /// WebGL rendering context options, used by `createCanvasContext()`
67
+ pub const WebGLContextOpts = extern struct {
68
+ alpha: u8 = 0,
69
+ antialias: u8 = 0,
70
+ depth: u8 = 1,
71
+ desynchronized: u8 = 0,
72
+ failIfMajorPerformanceCaveat: u8 = 0,
73
+ powerPreference: WebGLPowerPreference = .default,
74
+ premultipliedAlpha: u8 = 0,
75
+ preserveDrawingBuffer: u8 = 0,
76
+ stencil: u8 = 0,
77
+ };
78
+
79
+ pub const WebGLPowerPreference = enum(u8) {
80
+ default,
81
+ high_performance,
82
+ low_power,
83
+ };
84
+
85
+ pub const ShaderSpec = extern struct {
86
+ vs: bindgen.ConstStringPtr,
87
+ fs: bindgen.ConstStringPtr,
88
+ /// Slice of shader attribute specs
89
+ attribs: ConstShaderAttribSpecSlice = shaderAttribs(&[_]ShaderAttribSpec{}),
90
+ /// Slice of shader varying specs
91
+ varying: ConstShaderVaryingSpecSlice = shaderVaryings(&[_]ShaderVaryingSpec{}),
92
+ /// Slice of shader uniform specs
93
+ uniforms: ConstShaderUniformSpecSlice = shaderUniforms(&[_]ShaderUniformSpec{}),
94
+ };
95
+
96
+ pub const ShaderAttribSpec = extern struct {
97
+ name: bindgen.ConstStringPtr,
98
+ type: ShaderAttribType,
99
+ };
100
+
101
+ pub const ShaderVaryingSpec = extern struct {
102
+ name: bindgen.ConstStringPtr,
103
+ type: ShaderAttribType,
104
+ };
105
+
106
+ pub const ShaderUniformSpec = extern struct {
107
+ name: bindgen.ConstStringPtr,
108
+ type: UniformType,
109
+ default: UniformValue = .{ .float = 0 },
110
+ };
111
+
112
+ pub const ModelSpec = extern struct {
113
+ /// Slice of model attribute specs
114
+ attribs: ConstModelAttribSpecSlice = modelAttribs(&[_]ModelAttribSpec{}),
115
+ /// Slice of instance attribute specs
116
+ instances: ConstModelAttribSpecSlice = modelAttribs(&[_]ModelAttribSpec{}),
117
+ /// Slice of model uniforms
118
+ uniforms: ConstModelUniformSlice = modelUniforms(&[_]ModelUniform{}),
119
+ textures: ConstI32Slice = ConstI32Slice.wrap(&[_]i32{}),
120
+ shader: i32,
121
+ num: u32,
122
+ numInstances: u32 = 0,
123
+ mode: DrawMode = .triangles,
124
+ };
125
+
126
+ pub const ModelAttribSpec = extern struct {
127
+ name: bindgen.ConstStringPtr,
128
+ data: ModelAttribData,
129
+ type: ModelAttribType = .f32,
130
+ offset: u32 = 0,
131
+ stride: u32 = 0,
132
+ size: u32,
133
+ };
134
+
135
+ pub const ModelAttribData = extern union {
136
+ u8: ConstI8Slice,
137
+ i8: ConstU8Slice,
138
+ i16: ConstI16Slice,
139
+ u16: ConstU16Slice,
140
+ u32: ConstI32Slice,
141
+ i32: ConstU32Slice,
142
+ f32: ConstF32Slice,
143
+ };
144
+
145
+ pub const AttribUpdateSpec = extern struct {
146
+ data: ModelAttribData,
147
+ type: ModelAttribType = .f32,
148
+ /// Start byte offset in WebGL buffer
149
+ offset: u32 = 0,
150
+ };
151
+
152
+ pub const ModelUniform = extern struct {
153
+ name: bindgen.ConstStringPtr,
154
+ type: UniformType,
155
+ value: UniformValue,
156
+ };
157
+
158
+ pub const UniformValue = extern union {
159
+ float: f32,
160
+ vec2: @Vector(2, f32),
161
+ vec3: @Vector(3, f32),
162
+ vec4: @Vector(4, f32),
163
+ };
164
+
165
+ pub const TextureSpec = extern struct {
166
+ img: ImageData = .{ .none = 0 },
167
+ width: u16,
168
+ height: u16,
169
+ depth: u16 = 0,
170
+ format: TextureFormat = .rgba,
171
+ target: TextureTarget = .texture_2d,
172
+ type: TextureType = .auto,
173
+ filter: TextureFilter = .nearest,
174
+ wrap: TextureRepeat = .clamp,
175
+ imgType: ImageType = .none,
176
+ };
177
+
178
+ pub const ImageData = extern union {
179
+ none: u32,
180
+ u8: ConstU8Slice,
181
+ u16: ConstU16Slice,
182
+ u32: ConstU32Slice,
183
+ f32: ConstF32Slice,
184
+ };
185
+
186
+ pub const ImageType = enum(u8) {
187
+ none,
188
+ u8,
189
+ u16,
190
+ u32,
191
+ f32,
192
+ };
193
+
194
+ /// Same as https://docs.thi.ng/umbrella/api/enums/GLType.html
195
+ pub const ModelAttribType = enum(u16) {
196
+ i8 = 5120,
197
+ u8 = 5121,
198
+ i16 = 5122,
199
+ u16 = 5123,
200
+ i32 = 5124,
201
+ u32 = 5125,
202
+ f32 = 5126,
203
+ };
204
+
205
+ pub const ShaderAttribType = enum(u8) {
206
+ float,
207
+ int,
208
+ uint,
209
+ vec2,
210
+ vec3,
211
+ vec4,
212
+ mat22,
213
+ mat33,
214
+ mat44,
215
+ };
216
+
217
+ pub const UniformType = enum(u8) {
218
+ float,
219
+ int,
220
+ uint,
221
+ vec2,
222
+ vec3,
223
+ vec4,
224
+ mat22,
225
+ mat33,
226
+ mat44,
227
+ sampler2D,
228
+ sampler3D,
229
+ samplerCube,
230
+ };
231
+
232
+ /// Visualization mode for how geometry will be interpreted
233
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/DrawMode.html
234
+ pub const DrawMode = enum(u8) {
235
+ points,
236
+ lines,
237
+ line_loop,
238
+ line_strip,
239
+ triangles,
240
+ triangle_strip,
241
+ triangle_fan,
242
+ };
243
+
244
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/TextureFilter.html
245
+ pub const TextureFilter = enum(u16) {
246
+ linear = 9729,
247
+ nearest = 9728,
248
+ nearest_mipmap_nearest = 9984,
249
+ linear_mipmap_nearest,
250
+ nearest_mipmap_linear,
251
+ linear_mipmap_linear,
252
+ };
253
+
254
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/TextureFormat.html
255
+ pub const TextureFormat = enum(u16) {
256
+ alpha = 6406,
257
+ depth_component = 6402,
258
+ depth_component16 = 33189,
259
+ depth_component24 = 33190,
260
+ depth_component32f = 36012,
261
+ depth_stencil = 34041,
262
+ depth24_stencil8 = 35056,
263
+ depth32f_stencil8 = 36013,
264
+ luminance = 6409,
265
+ luminance_alpha = 6410,
266
+ r11f_g11f_b10f = 35898,
267
+ r16f = 33325,
268
+ r16i = 33331,
269
+ r16ui = 33332,
270
+ r32f = 33326,
271
+ r32i = 33333,
272
+ r32ui = 33334,
273
+ r8 = 33321,
274
+ r8_snorm = 36756,
275
+ r8i = 33329,
276
+ r8ui = 33330,
277
+ red = 6403,
278
+ red_integer = 36244,
279
+ rg = 33319,
280
+ rg_integer = 33320,
281
+ rg16f = 33327,
282
+ rg16i = 33337,
283
+ rg16ui = 33338,
284
+ rg32f = 33328,
285
+ rg32i = 33339,
286
+ rg32ui = 33340,
287
+ rg8 = 33323,
288
+ rg8_snorm = 36757,
289
+ rg8i = 33335,
290
+ rg8ui = 33336,
291
+ rgb = 6407,
292
+ rgb_integer = 36248,
293
+ rgb10_a2 = 32857,
294
+ rgb10_a2ui = 36975,
295
+ rgb16f = 34843,
296
+ rgb16i = 36233,
297
+ rgb16ui = 36215,
298
+ rgb32f = 34837,
299
+ rgb32i = 36227,
300
+ rgb32ui = 36209,
301
+ rgb5_a1 = 32855,
302
+ rgb565 = 36194,
303
+ rgb8 = 32849,
304
+ rgb8_snorm = 36758,
305
+ rgb8i = 36239,
306
+ rgb8ui = 36221,
307
+ rgb9_e5 = 35901,
308
+ rgba = 6408,
309
+ rgba_integer = 36249,
310
+ rgba16f = 34842,
311
+ rgba16i = 36232,
312
+ rgba16ui = 36214,
313
+ rgba32f = 34836,
314
+ rgba32i = 36226,
315
+ rgba32ui = 36208,
316
+ rgba4 = 32854,
317
+ rgba8 = 32856,
318
+ rgba8_snorm = 36759,
319
+ rgba8i = 36238,
320
+ rgba8ui = 36220,
321
+ srgb8 = 35905,
322
+ srgb8_alpha8 = 35907,
323
+ };
324
+
325
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/TextureRepeat.html
326
+ pub const TextureRepeat = enum(u16) {
327
+ repeat = 10497,
328
+ clamp = 33071,
329
+ repeat_mirror = 33648,
330
+ };
331
+
332
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/TextureTarget.html
333
+ pub const TextureTarget = enum(u16) {
334
+ texture_2d = 3553,
335
+ texture_3d = 32879,
336
+ texture_cube_map = 34067,
337
+ texture_2d_array = 35866,
338
+ };
339
+
340
+ /// Same as: https://docs.thi.ng/umbrella/webgl/enums/TextureType.html
341
+ pub const TextureType = enum(u16) {
342
+ auto = 0,
343
+ byte = 5120,
344
+ unsigned_byte = 5121,
345
+ short = 5122,
346
+ unsigned_short = 5123,
347
+ int = 5124,
348
+ unsigned_int = 5125,
349
+ float = 5126,
350
+ half_float = 5131,
351
+ unsigned_short_4_4_4_4 = 32819,
352
+ unsigned_short_5_5_5_1 = 32820,
353
+ unsigned_short_5_6_5 = 33635,
354
+ unsigned_int_2_10_10_10_rev = 33640,
355
+ unsigned_int_24_8 = 34042,
356
+ unsigned_int_10f_11f_11f_rev = 35899,
357
+ unsigned_int_5_9_9_9_rev = 35902,
358
+ half_float_oes = 36193,
359
+ float_32_unsigned_int_24_8_rev = 36269,
360
+ };