@geastack/native-webgl-angle 0.1.6
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/LICENSE +202 -0
- package/README.md +184 -0
- package/geatsc-plugin-batched-probe.mjs +98 -0
- package/geatsc-plugin-instancing.mjs +160 -0
- package/geatsc-plugin-uniforms.mjs +1955 -0
- package/geatsc-plugin-uploads.mjs +29 -0
- package/geatsc-plugin.mjs +10275 -0
- package/native/angle_webgl_host.mm +2687 -0
- package/native/audio_host.mm +857 -0
- package/native/audio_uwp.h +116 -0
- package/package.json +70 -0
- package/src/gea-native-types.d.ts +4 -0
- package/src/nativeAudioHost.ts +296 -0
- package/src/nativeThreeUtils.ts +11 -0
- package/src/nativeWebGL.ts +1211 -0
- package/src/nativeWebGLAnimation.ts +13 -0
- package/src/nativeWebGLHost.ts +333 -0
- package/src/nativeWebXRManager.ts +48 -0
- package/src/text/atlas-sans.ts +195 -0
- package/src/text/atlas-serif-italic.ts +195 -0
- package/src/text/atlas-serif.ts +195 -0
- package/src/text/native-text-types.ts +17 -0
- package/src/text/native-text.ts +203 -0
- package/src/troika-three-text.ts +248 -0
- package/test/auto-instanced-render-scene.ts +66 -0
- package/test/batched-render-scene.ts +58 -0
|
@@ -0,0 +1,1211 @@
|
|
|
1
|
+
/// <reference path="./gea-native-types.d.ts" />
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
logNativeWebGL,
|
|
5
|
+
nativeWebGLActiveTexture,
|
|
6
|
+
nativeWebGLAttachShader,
|
|
7
|
+
nativeWebGLBindBuffer,
|
|
8
|
+
nativeWebGLBindFramebuffer,
|
|
9
|
+
nativeWebGLBindRenderbuffer,
|
|
10
|
+
nativeWebGLBindTexture,
|
|
11
|
+
nativeWebGLBindVertexArray,
|
|
12
|
+
nativeWebGLBlendEquation,
|
|
13
|
+
nativeWebGLBlendEquationSeparate,
|
|
14
|
+
nativeWebGLBlendFunc,
|
|
15
|
+
nativeWebGLBlendFuncSeparate,
|
|
16
|
+
nativeWebGLCheckFramebufferStatus,
|
|
17
|
+
nativeWebGLClear,
|
|
18
|
+
nativeWebGLClearColor,
|
|
19
|
+
nativeWebGLClearDepth,
|
|
20
|
+
nativeWebGLClearStencil,
|
|
21
|
+
nativeWebGLColorMask,
|
|
22
|
+
nativeWebGLCompileShader,
|
|
23
|
+
nativeWebGLCreateBuffer,
|
|
24
|
+
nativeWebGLCreateFramebuffer,
|
|
25
|
+
nativeWebGLCreateProgram,
|
|
26
|
+
nativeWebGLCreateRenderbuffer,
|
|
27
|
+
nativeWebGLCreateShader,
|
|
28
|
+
nativeWebGLCreateTexture,
|
|
29
|
+
nativeWebGLCreateVertexArray,
|
|
30
|
+
nativeWebGLCullFace,
|
|
31
|
+
nativeWebGLDeleteBuffer,
|
|
32
|
+
nativeWebGLDeleteFramebuffer,
|
|
33
|
+
nativeWebGLDeleteProgram,
|
|
34
|
+
nativeWebGLDeleteRenderbuffer,
|
|
35
|
+
nativeWebGLDeleteShader,
|
|
36
|
+
nativeWebGLDeleteTexture,
|
|
37
|
+
nativeWebGLDeleteVertexArray,
|
|
38
|
+
nativeWebGLDepthFunc,
|
|
39
|
+
nativeWebGLDepthMask,
|
|
40
|
+
nativeWebGLDisable,
|
|
41
|
+
nativeWebGLDisableVertexAttribArray,
|
|
42
|
+
nativeWebGLDrawArrays,
|
|
43
|
+
nativeWebGLDrawArraysInstanced,
|
|
44
|
+
nativeWebGLDrawElementsInstanced,
|
|
45
|
+
nativeWebGLVertexAttribDivisor,
|
|
46
|
+
nativeWebGLDrawBuffers,
|
|
47
|
+
nativeWebGLDrawElements,
|
|
48
|
+
nativeWebGLEnable,
|
|
49
|
+
nativeWebGLEnableVertexAttribArray,
|
|
50
|
+
nativeWebGLFramebufferRenderbuffer,
|
|
51
|
+
nativeWebGLFramebufferTexture2D,
|
|
52
|
+
nativeWebGLFrontFace,
|
|
53
|
+
nativeWebGLGenerateMipmap,
|
|
54
|
+
nativeWebGLGetAttribLocation,
|
|
55
|
+
nativeWebGLGetError,
|
|
56
|
+
nativeWebGLGetActiveAttribInfo,
|
|
57
|
+
nativeWebGLGetActiveUniformInfo,
|
|
58
|
+
nativeWebGLGetProgramParameter,
|
|
59
|
+
nativeWebGLGetShaderParameter,
|
|
60
|
+
nativeWebGLGetUniformLocation,
|
|
61
|
+
nativeWebGLHeight,
|
|
62
|
+
nativeWebGLLineWidth,
|
|
63
|
+
nativeWebGLLinkProgram,
|
|
64
|
+
nativeWebGLPixelStorei,
|
|
65
|
+
nativeWebGLPolygonOffset,
|
|
66
|
+
nativeWebGLRenderbufferStorage,
|
|
67
|
+
nativeWebGLScissor,
|
|
68
|
+
nativeWebGLShaderSource,
|
|
69
|
+
nativeWebGLStencilFunc,
|
|
70
|
+
nativeWebGLStencilFuncSeparate,
|
|
71
|
+
nativeWebGLStencilMask,
|
|
72
|
+
nativeWebGLStencilMaskSeparate,
|
|
73
|
+
nativeWebGLStencilOp,
|
|
74
|
+
nativeWebGLStencilOpSeparate,
|
|
75
|
+
nativeWebGLSwap,
|
|
76
|
+
nativeWebGLTexParameteri,
|
|
77
|
+
nativeWebGLUniform1f,
|
|
78
|
+
nativeWebGLUniform1i,
|
|
79
|
+
nativeWebGLUniform2f,
|
|
80
|
+
nativeWebGLUniform3f,
|
|
81
|
+
nativeWebGLUniform4f,
|
|
82
|
+
nativeWebGLUseProgram,
|
|
83
|
+
nativeWebGLVertexAttribPointer,
|
|
84
|
+
nativeWebGLViewport,
|
|
85
|
+
nativeWebGLWidth,
|
|
86
|
+
} from './nativeWebGLHost'
|
|
87
|
+
|
|
88
|
+
type NativeHandleKind =
|
|
89
|
+
| 'buffer'
|
|
90
|
+
| 'framebuffer'
|
|
91
|
+
| 'program'
|
|
92
|
+
| 'renderbuffer'
|
|
93
|
+
| 'shader'
|
|
94
|
+
| 'texture'
|
|
95
|
+
| 'uniform'
|
|
96
|
+
| 'vertexArray'
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @gea-refcount
|
|
100
|
+
* Deliberately NOT marked no-runtime-bridge: a NativeHandle stored on a
|
|
101
|
+
* gcv-boxed object (e.g. `uniform.addr`) is read back as a gea_cpp_value at the
|
|
102
|
+
* WebGL intrinsic boundary, where the location is recovered via
|
|
103
|
+
* record_get_literal on the nativeHandle field. Without the runtime bridge that
|
|
104
|
+
* read returned missing so every uniform location resolved to 0 (all matrices
|
|
105
|
+
* clobbered uniform 0 -> black cube). The bridge exposes the public
|
|
106
|
+
* __nativeHandle field so the location survives the box round-trip.
|
|
107
|
+
*/
|
|
108
|
+
export class NativeHandle {
|
|
109
|
+
readonly __nativeKind: NativeHandleKind
|
|
110
|
+
readonly __nativeHandle: number
|
|
111
|
+
|
|
112
|
+
constructor(kind: NativeHandleKind, handle: number) {
|
|
113
|
+
this.__nativeKind = kind
|
|
114
|
+
this.__nativeHandle = handle
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// A field-only refcount class qualifies for runtime-value-bridge OMISSION
|
|
118
|
+
// (classCanOmitRuntimeValueBridge), so a boxed NativeHandle exposed nothing to
|
|
119
|
+
// record_get and its location resolved to 0. A single instance method
|
|
120
|
+
// disqualifies omission, forcing the bridge that exposes the public
|
|
121
|
+
// __nativeHandle field — the WebGL intrinsic boundary reads the location back
|
|
122
|
+
// via record_get_literal("__nativeHandle") off the boxed handle.
|
|
123
|
+
nativeHandleValue(): number {
|
|
124
|
+
return this.__nativeHandle
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @gea-no-runtime-bridge @gea-refcount */
|
|
129
|
+
export class NativeShader extends NativeHandle {
|
|
130
|
+
readonly __nativeKind = 'shader'
|
|
131
|
+
shaderType: number
|
|
132
|
+
source = ''
|
|
133
|
+
|
|
134
|
+
constructor(handle: number, shaderType: number) {
|
|
135
|
+
super('shader', handle)
|
|
136
|
+
this.shaderType = shaderType
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** @gea-no-runtime-bridge @gea-refcount */
|
|
141
|
+
export class NativeProgram extends NativeHandle {
|
|
142
|
+
readonly __nativeKind = 'program'
|
|
143
|
+
shaders: NativeShader[] = []
|
|
144
|
+
|
|
145
|
+
constructor(handle: number) {
|
|
146
|
+
super('program', handle)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** @gea-no-runtime-bridge */
|
|
151
|
+
class NativeWebGLCanvasMetrics {
|
|
152
|
+
width: number
|
|
153
|
+
height: number
|
|
154
|
+
clientWidth: number
|
|
155
|
+
clientHeight: number
|
|
156
|
+
style = { width: '', height: '' }
|
|
157
|
+
|
|
158
|
+
constructor(width: number, height: number) {
|
|
159
|
+
this.width = width
|
|
160
|
+
this.height = height
|
|
161
|
+
this.clientWidth = width
|
|
162
|
+
this.clientHeight = height
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type BufferSourceLike =
|
|
167
|
+
| Float32Array
|
|
168
|
+
| Float64Array
|
|
169
|
+
| Int8Array
|
|
170
|
+
| Uint8Array
|
|
171
|
+
| Uint8ClampedArray
|
|
172
|
+
| Int16Array
|
|
173
|
+
| Uint16Array
|
|
174
|
+
| Int32Array
|
|
175
|
+
| Uint32Array
|
|
176
|
+
| number[]
|
|
177
|
+
| null
|
|
178
|
+
| undefined
|
|
179
|
+
|
|
180
|
+
function createHandle(kind: NativeHandleKind, handle: number): NativeHandle { return new NativeHandle(kind, handle) }
|
|
181
|
+
|
|
182
|
+
function nativeHandle(value: NativeHandle): number { return value.__nativeHandle }
|
|
183
|
+
|
|
184
|
+
function nullableNativeHandle(value: NativeHandle | null | undefined): number { return value ? value.__nativeHandle : 0 }
|
|
185
|
+
|
|
186
|
+
function typedArrayKind(value: BufferSourceLike): number {
|
|
187
|
+
// Test the original union directly. Null, undefined, and ordinary arrays
|
|
188
|
+
// fail every typed-array identity check and take the default scalar kind.
|
|
189
|
+
// A preliminary guard would narrow the binding to a new carrier that the
|
|
190
|
+
// native compiler cannot reread from this parameter's original storage.
|
|
191
|
+
if (value instanceof Uint16Array) return 2
|
|
192
|
+
if (value instanceof Uint32Array) return 3
|
|
193
|
+
if (value instanceof Uint8Array || value instanceof Uint8ClampedArray) return 4
|
|
194
|
+
if (value instanceof Int8Array) return 5
|
|
195
|
+
if (value instanceof Int16Array) return 6
|
|
196
|
+
if (value instanceof Int32Array) return 7
|
|
197
|
+
if (value instanceof Float64Array) return 8
|
|
198
|
+
return 1
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function zeroF32Array(length: number): f32[] {
|
|
202
|
+
const out: f32[] = []
|
|
203
|
+
for (let index = 0; index < length; index++) out.push(0 as f32)
|
|
204
|
+
return out
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
208
|
+
declare function threeWebGLUniform1fv(location: number, values: BufferSourceLike): void
|
|
209
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
210
|
+
declare function threeWebGLUniform2fv(location: number, values: BufferSourceLike): void
|
|
211
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
212
|
+
declare function threeWebGLUniform3fv(location: number, values: BufferSourceLike): void
|
|
213
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
214
|
+
declare function threeWebGLUniform4fv(location: number, values: BufferSourceLike): void
|
|
215
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
216
|
+
declare function threeWebGLUniform1iv(location: number, values: BufferSourceLike): void
|
|
217
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
218
|
+
declare function threeWebGLUniform2iv(location: number, values: BufferSourceLike): void
|
|
219
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
220
|
+
declare function threeWebGLUniform3iv(location: number, values: BufferSourceLike): void
|
|
221
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
222
|
+
declare function threeWebGLUniform4iv(location: number, values: BufferSourceLike): void
|
|
223
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
224
|
+
declare function threeWebGLUniform1uiv(location: number, values: BufferSourceLike): void
|
|
225
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
226
|
+
declare function threeWebGLUniform2uiv(location: number, values: BufferSourceLike): void
|
|
227
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
228
|
+
declare function threeWebGLUniform3uiv(location: number, values: BufferSourceLike): void
|
|
229
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
230
|
+
declare function threeWebGLUniform4uiv(location: number, values: BufferSourceLike): void
|
|
231
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
232
|
+
declare function threeWebGLUniformMatrix2fv(location: number, count: number, transpose: number, values: BufferSourceLike): void
|
|
233
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
234
|
+
declare function threeWebGLBufferData(target: number, usage: number, typeCode: number, values: BufferSourceLike): void
|
|
235
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
236
|
+
declare function threeWebGLBufferSubDataRange(target: number, offset: number, typeCode: number, values: BufferSourceLike, sourceOffset: number, length: number): void
|
|
237
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
238
|
+
declare function threeWebGLBufferSubData(target: number, offset: number, typeCode: number, values: BufferSourceLike): void
|
|
239
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
240
|
+
declare function threeWebGLUniformMatrix3fv(location: number, count: number, transpose: number, values: BufferSourceLike): void
|
|
241
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
242
|
+
declare function threeWebGLUniformMatrix4fv(location: number, count: number, transpose: number, values: BufferSourceLike): void
|
|
243
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
244
|
+
declare function threeWebGLTexImage2D(target: number, level: number, internalFormat: number, width: number, height: number, format: number, type: number, values: BufferSourceLike): void
|
|
245
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
246
|
+
declare function threeWebGLTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, values: BufferSourceLike): void
|
|
247
|
+
/** @gea-host-inert Reads its arguments, writes GL state only; never calls back into script. */
|
|
248
|
+
declare function threeWebGLTexStorage2D(target: number, levels: number, internalFormat: number, width: number, height: number): void
|
|
249
|
+
|
|
250
|
+
// Shader source keyed by the stable native GL handle. A NativeShader instance
|
|
251
|
+
// can be value-copied when it round-trips through a function-return / gcv
|
|
252
|
+
// boundary (the copy is reconstructed from its handle, resetting the mutable
|
|
253
|
+
// `source` field to its `''` default), so relying on `shader.source` surviving
|
|
254
|
+
// to link time is unsafe. The native handle is a ctor-set readonly field that
|
|
255
|
+
// DOES survive the copy, so we cache the source under it.
|
|
256
|
+
const shaderSourceByHandle = new Map<number, string>()
|
|
257
|
+
|
|
258
|
+
function shaderSourceFor(shader: NativeShader): string {
|
|
259
|
+
return shaderSourceByHandle.get(nativeHandle(shader)) ?? shader.source ?? ''
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Program reflection (active attributes/uniforms) comes from REAL driver
|
|
263
|
+
// reflection: ANGLE's glGetActiveUniform / glGetActiveAttrib, serialized by the
|
|
264
|
+
// native host as `name|type|size` ("" past the end). Do NOT reconstruct this by
|
|
265
|
+
// text-parsing GLSL source — three.js depends on glGetActiveUniform semantics
|
|
266
|
+
// (struct arrays expanded per member as "directionalLights[0].direction", basic
|
|
267
|
+
// arrays reported as "name[0]" with size=N) to build its uniform-upload tree. A
|
|
268
|
+
// source parser misses #define-sized arrays and struct expansion, so every
|
|
269
|
+
// struct uniform (all lights, all shadows) silently never uploads.
|
|
270
|
+
//
|
|
271
|
+
// NOTE: the return type is a plain record. Annotating it as a class makes
|
|
272
|
+
// geatsc coerce the returned value back into a value-type at the boundary,
|
|
273
|
+
// which drops its fields (name → undefined at the three.js call site). A
|
|
274
|
+
// record return type is emitted as a gcv record and its fields survive.
|
|
275
|
+
function parseActiveInfoString(serialized: string): { name: string; type: number; size: number } | null {
|
|
276
|
+
if (!serialized) return null
|
|
277
|
+
const [name, type, size] = serialized.split('|')
|
|
278
|
+
// A length test does not narrow an indexed read; the names themselves do.
|
|
279
|
+
if (name === undefined || type === undefined || size === undefined) return null
|
|
280
|
+
return { name, type: Number(type), size: Number(size) }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** @gea-refcount */
|
|
284
|
+
/**
|
|
285
|
+
* The attribute bag `getContext`'s second argument carries.
|
|
286
|
+
*
|
|
287
|
+
* Stated as a real record rather than left off, because three.js passes it --
|
|
288
|
+
* `canvas.getContext( contextName, contextAttributes )` in
|
|
289
|
+
* `WebGLRenderer.js`'s own `getContext` -- and a parameter this shim does not
|
|
290
|
+
* declare is one the call cannot be checked against. Every field is the one
|
|
291
|
+
* three fills in; none of them changes what an ANGLE context does, which is
|
|
292
|
+
* why the body ignores the bag entirely and `getContextAttributes` answers
|
|
293
|
+
* this host's own real values instead.
|
|
294
|
+
*/
|
|
295
|
+
export interface NativeWebGLContextAttributes {
|
|
296
|
+
alpha: boolean
|
|
297
|
+
depth: boolean
|
|
298
|
+
stencil: boolean
|
|
299
|
+
antialias: boolean
|
|
300
|
+
premultipliedAlpha: boolean
|
|
301
|
+
preserveDrawingBuffer: boolean
|
|
302
|
+
powerPreference: string
|
|
303
|
+
failIfMajorPerformanceCaveat: boolean
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export class NativeWebGLCanvas {
|
|
307
|
+
width: number
|
|
308
|
+
height: number
|
|
309
|
+
clientWidth: number
|
|
310
|
+
clientHeight: number
|
|
311
|
+
style = { width: '', height: '' }
|
|
312
|
+
private context: NativeWebGL2RenderingContext | null = null
|
|
313
|
+
|
|
314
|
+
constructor(width: number, height: number) {
|
|
315
|
+
this.width = width
|
|
316
|
+
this.height = height
|
|
317
|
+
this.clientWidth = width
|
|
318
|
+
this.clientHeight = height
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
getContext(name: string, _attributes?: NativeWebGLContextAttributes): NativeWebGL2RenderingContext | null {
|
|
322
|
+
if (name === 'webgl2' || name === 'webgl') return this.context
|
|
323
|
+
return null
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
setContext(context: NativeWebGL2RenderingContext): void {
|
|
327
|
+
this.context = context
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
addEventListener(_type: string, _listener: (event: unknown) => void, ..._options: unknown[]): void {}
|
|
331
|
+
removeEventListener(_type: string, _listener: (event: unknown) => void, ..._options: unknown[]): void {}
|
|
332
|
+
setAttribute(_name: string, _value: string): void {}
|
|
333
|
+
hasAttribute(_name: string): boolean { return false }
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* The object `getExtension` hands back.
|
|
338
|
+
*
|
|
339
|
+
* Declared as ONE class rather than an interface per extension, and returned
|
|
340
|
+
* as `WebGLExtension | null` rather than `object | null`, because `object`
|
|
341
|
+
* states nothing: a consumer reading `extension.COMPRESSED_RGB_S3TC_DXT1_EXT`
|
|
342
|
+
* off it has to box the whole value first. That single word cost geatsc **190
|
|
343
|
+
* boxed carriers on `WebGLUtils.js`'s `let extension`** -- the largest single
|
|
344
|
+
* declaration in the reference build -- plus 60 more on `ext_texture_norm16`
|
|
345
|
+
* and fifteen further `extensions.get(...)` sites, because the compiler was
|
|
346
|
+
* being told, accurately, that nothing is known about the members.
|
|
347
|
+
*
|
|
348
|
+
* One class, not an overload set keyed by extension name: overloads that
|
|
349
|
+
* return different object types share no calling convention, and geatsc
|
|
350
|
+
* refuses such a set outright (`no primitive joining N construct signatures
|
|
351
|
+
* into one calling convention`). Naming every constant on one type is the
|
|
352
|
+
* shape that both compiles and states the truth -- a consumer only ever reads
|
|
353
|
+
* the constants belonging to the extension it asked for, and only after
|
|
354
|
+
* testing the result for `null`.
|
|
355
|
+
*
|
|
356
|
+
* The values are the WebGL registry's own, so an instance handed out for one
|
|
357
|
+
* extension carrying another's constants is inert: three reads
|
|
358
|
+
* `COMPRESSED_*` only inside the branch that matched the extension it
|
|
359
|
+
* requested. The method stubs exist for the same reason the constants do --
|
|
360
|
+
* three's call sites are compiled whether or not this shim reports the
|
|
361
|
+
* extension as supported, and a call needs a declaration to compile against.
|
|
362
|
+
* `getSupportedExtensions` remains the authority on what is actually
|
|
363
|
+
* available, and every unsupported name still answers `null`.
|
|
364
|
+
*/
|
|
365
|
+
export class WebGLExtension {
|
|
366
|
+
readonly COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0
|
|
367
|
+
readonly COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1
|
|
368
|
+
readonly COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83f2
|
|
369
|
+
readonly COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83f3
|
|
370
|
+
readonly COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8c4c
|
|
371
|
+
readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8c4d
|
|
372
|
+
readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8c4e
|
|
373
|
+
readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8c4f
|
|
374
|
+
|
|
375
|
+
readonly COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00
|
|
376
|
+
readonly COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01
|
|
377
|
+
readonly COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02
|
|
378
|
+
readonly COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03
|
|
379
|
+
|
|
380
|
+
readonly COMPRESSED_R11_EAC = 0x9270
|
|
381
|
+
readonly COMPRESSED_SIGNED_R11_EAC = 0x9271
|
|
382
|
+
readonly COMPRESSED_RG11_EAC = 0x9272
|
|
383
|
+
readonly COMPRESSED_SIGNED_RG11_EAC = 0x9273
|
|
384
|
+
readonly COMPRESSED_RGB8_ETC2 = 0x9274
|
|
385
|
+
readonly COMPRESSED_SRGB8_ETC2 = 0x9275
|
|
386
|
+
readonly COMPRESSED_RGBA8_ETC2_EAC = 0x9278
|
|
387
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279
|
|
388
|
+
|
|
389
|
+
readonly COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0
|
|
390
|
+
readonly COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1
|
|
391
|
+
readonly COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2
|
|
392
|
+
readonly COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3
|
|
393
|
+
readonly COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4
|
|
394
|
+
readonly COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5
|
|
395
|
+
readonly COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6
|
|
396
|
+
readonly COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7
|
|
397
|
+
readonly COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8
|
|
398
|
+
readonly COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9
|
|
399
|
+
readonly COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba
|
|
400
|
+
readonly COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb
|
|
401
|
+
readonly COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc
|
|
402
|
+
readonly COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd
|
|
403
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0
|
|
404
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1
|
|
405
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2
|
|
406
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3
|
|
407
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4
|
|
408
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5
|
|
409
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6
|
|
410
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7
|
|
411
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8
|
|
412
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9
|
|
413
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da
|
|
414
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db
|
|
415
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc
|
|
416
|
+
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd
|
|
417
|
+
|
|
418
|
+
readonly COMPRESSED_RGBA_BPTC_UNORM_EXT = 0x8e8c
|
|
419
|
+
readonly COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 0x8e8d
|
|
420
|
+
readonly COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 0x8e8e
|
|
421
|
+
readonly COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 0x8e8f
|
|
422
|
+
|
|
423
|
+
readonly COMPRESSED_RED_RGTC1_EXT = 0x8dbb
|
|
424
|
+
readonly COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8dbc
|
|
425
|
+
readonly COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8dbd
|
|
426
|
+
readonly COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8dbe
|
|
427
|
+
|
|
428
|
+
readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff
|
|
429
|
+
readonly TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe
|
|
430
|
+
readonly UNMASKED_VENDOR_WEBGL = 0x9245
|
|
431
|
+
readonly UNMASKED_RENDERER_WEBGL = 0x9246
|
|
432
|
+
readonly MAX_SAMPLES_EXT = 0x8d57
|
|
433
|
+
|
|
434
|
+
loseContext(): void {}
|
|
435
|
+
restoreContext(): void {}
|
|
436
|
+
|
|
437
|
+
multiDrawArraysWEBGL(mode: number, firsts: Int32Array, firstsOffset: number, counts: Int32Array, countsOffset: number, drawCount: number): void {
|
|
438
|
+
void mode
|
|
439
|
+
void firsts
|
|
440
|
+
void firstsOffset
|
|
441
|
+
void counts
|
|
442
|
+
void countsOffset
|
|
443
|
+
void drawCount
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
multiDrawElementsWEBGL(
|
|
447
|
+
mode: number,
|
|
448
|
+
counts: Int32Array,
|
|
449
|
+
countsOffset: number,
|
|
450
|
+
type: number,
|
|
451
|
+
offsets: Int32Array,
|
|
452
|
+
offsetsOffset: number,
|
|
453
|
+
drawCount: number
|
|
454
|
+
): void {
|
|
455
|
+
void mode
|
|
456
|
+
void counts
|
|
457
|
+
void countsOffset
|
|
458
|
+
void type
|
|
459
|
+
void offsets
|
|
460
|
+
void offsetsOffset
|
|
461
|
+
void drawCount
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
renderbufferStorageMultisampleEXT(target: number, samples: number, internalformat: number, width: number, height: number): void {
|
|
465
|
+
void target
|
|
466
|
+
void samples
|
|
467
|
+
void internalformat
|
|
468
|
+
void width
|
|
469
|
+
void height
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
framebufferTexture2DMultisampleEXT(
|
|
473
|
+
target: number,
|
|
474
|
+
attachment: number,
|
|
475
|
+
textarget: number,
|
|
476
|
+
texture: NativeHandle | null,
|
|
477
|
+
level: number,
|
|
478
|
+
samples: number
|
|
479
|
+
): void {
|
|
480
|
+
void target
|
|
481
|
+
void attachment
|
|
482
|
+
void textarget
|
|
483
|
+
void texture
|
|
484
|
+
void level
|
|
485
|
+
void samples
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
framebufferTextureMultisampleMultiviewOVR(
|
|
489
|
+
target: number,
|
|
490
|
+
attachment: number,
|
|
491
|
+
texture: NativeHandle | null,
|
|
492
|
+
level: number,
|
|
493
|
+
samples: number,
|
|
494
|
+
baseViewIndex: number,
|
|
495
|
+
numViews: number
|
|
496
|
+
): void {
|
|
497
|
+
void target
|
|
498
|
+
void attachment
|
|
499
|
+
void texture
|
|
500
|
+
void level
|
|
501
|
+
void samples
|
|
502
|
+
void baseViewIndex
|
|
503
|
+
void numViews
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
blendEquationSeparateiOES(buf: number, modeRGB: number, modeAlpha: number): void {
|
|
507
|
+
void buf
|
|
508
|
+
void modeRGB
|
|
509
|
+
void modeAlpha
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
blendFuncSeparateiOES(buf: number, srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void {
|
|
513
|
+
void buf
|
|
514
|
+
void srcRGB
|
|
515
|
+
void dstRGB
|
|
516
|
+
void srcAlpha
|
|
517
|
+
void dstAlpha
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export function createNativeWebGLCanvas(width: number, height: number): NativeWebGLCanvas {
|
|
522
|
+
const canvas = new NativeWebGLCanvas(width, height)
|
|
523
|
+
canvas.setContext(new NativeWebGL2RenderingContext(
|
|
524
|
+
() => canvas.width,
|
|
525
|
+
() => canvas.height,
|
|
526
|
+
))
|
|
527
|
+
return canvas
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export class NativeWebGL2RenderingContext {
|
|
531
|
+
private readonly canvasWidth: () => number
|
|
532
|
+
private readonly canvasHeight: () => number
|
|
533
|
+
|
|
534
|
+
readonly DEPTH_BUFFER_BIT = 0x00000100
|
|
535
|
+
readonly STENCIL_BUFFER_BIT = 0x00000400
|
|
536
|
+
readonly COLOR_BUFFER_BIT = 0x00004000
|
|
537
|
+
readonly POINTS = 0x0000
|
|
538
|
+
readonly LINES = 0x0001
|
|
539
|
+
readonly LINE_LOOP = 0x0002
|
|
540
|
+
readonly LINE_STRIP = 0x0003
|
|
541
|
+
readonly TRIANGLES = 0x0004
|
|
542
|
+
readonly TRIANGLE_STRIP = 0x0005
|
|
543
|
+
readonly TRIANGLE_FAN = 0x0006
|
|
544
|
+
readonly ZERO = 0
|
|
545
|
+
readonly ONE = 1
|
|
546
|
+
readonly SRC_COLOR = 0x0300
|
|
547
|
+
readonly ONE_MINUS_SRC_COLOR = 0x0301
|
|
548
|
+
readonly SRC_ALPHA = 0x0302
|
|
549
|
+
readonly ONE_MINUS_SRC_ALPHA = 0x0303
|
|
550
|
+
readonly DST_ALPHA = 0x0304
|
|
551
|
+
readonly ONE_MINUS_DST_ALPHA = 0x0305
|
|
552
|
+
readonly DST_COLOR = 0x0306
|
|
553
|
+
readonly ONE_MINUS_DST_COLOR = 0x0307
|
|
554
|
+
readonly SRC_ALPHA_SATURATE = 0x0308
|
|
555
|
+
readonly FUNC_ADD = 0x8006
|
|
556
|
+
readonly BLEND_EQUATION = 0x8009
|
|
557
|
+
readonly BLEND_EQUATION_RGB = 0x8009
|
|
558
|
+
readonly BLEND_EQUATION_ALPHA = 0x883D
|
|
559
|
+
readonly FUNC_SUBTRACT = 0x800A
|
|
560
|
+
readonly FUNC_REVERSE_SUBTRACT = 0x800B
|
|
561
|
+
readonly BLEND_DST_RGB = 0x80C8
|
|
562
|
+
readonly BLEND_SRC_RGB = 0x80C9
|
|
563
|
+
readonly BLEND_DST_ALPHA = 0x80CA
|
|
564
|
+
readonly BLEND_SRC_ALPHA = 0x80CB
|
|
565
|
+
readonly CONSTANT_COLOR = 0x8001
|
|
566
|
+
readonly ONE_MINUS_CONSTANT_COLOR = 0x8002
|
|
567
|
+
readonly CONSTANT_ALPHA = 0x8003
|
|
568
|
+
readonly ONE_MINUS_CONSTANT_ALPHA = 0x8004
|
|
569
|
+
readonly BLEND_COLOR = 0x8005
|
|
570
|
+
readonly ARRAY_BUFFER = 0x8892
|
|
571
|
+
readonly ELEMENT_ARRAY_BUFFER = 0x8893
|
|
572
|
+
readonly ARRAY_BUFFER_BINDING = 0x8894
|
|
573
|
+
readonly ELEMENT_ARRAY_BUFFER_BINDING = 0x8895
|
|
574
|
+
readonly STREAM_DRAW = 0x88E0
|
|
575
|
+
readonly STATIC_DRAW = 0x88E4
|
|
576
|
+
readonly DYNAMIC_DRAW = 0x88E8
|
|
577
|
+
readonly BUFFER_SIZE = 0x8764
|
|
578
|
+
readonly BUFFER_USAGE = 0x8765
|
|
579
|
+
readonly CURRENT_VERTEX_ATTRIB = 0x8626
|
|
580
|
+
readonly FRONT = 0x0404
|
|
581
|
+
readonly BACK = 0x0405
|
|
582
|
+
readonly FRONT_AND_BACK = 0x0408
|
|
583
|
+
readonly CULL_FACE = 0x0B44
|
|
584
|
+
readonly BLEND = 0x0BE2
|
|
585
|
+
readonly DITHER = 0x0BD0
|
|
586
|
+
readonly STENCIL_TEST = 0x0B90
|
|
587
|
+
readonly DEPTH_TEST = 0x0B71
|
|
588
|
+
readonly SCISSOR_TEST = 0x0C11
|
|
589
|
+
readonly POLYGON_OFFSET_FILL = 0x8037
|
|
590
|
+
readonly SAMPLE_ALPHA_TO_COVERAGE = 0x809E
|
|
591
|
+
readonly SAMPLE_COVERAGE = 0x80A0
|
|
592
|
+
readonly NO_ERROR = 0
|
|
593
|
+
readonly INVALID_ENUM = 0x0500
|
|
594
|
+
readonly INVALID_VALUE = 0x0501
|
|
595
|
+
readonly INVALID_OPERATION = 0x0502
|
|
596
|
+
readonly OUT_OF_MEMORY = 0x0505
|
|
597
|
+
readonly CW = 0x0900
|
|
598
|
+
readonly CCW = 0x0901
|
|
599
|
+
readonly LINE_WIDTH = 0x0B21
|
|
600
|
+
readonly ALIASED_POINT_SIZE_RANGE = 0x846D
|
|
601
|
+
readonly ALIASED_LINE_WIDTH_RANGE = 0x846E
|
|
602
|
+
readonly CULL_FACE_MODE = 0x0B45
|
|
603
|
+
readonly FRONT_FACE = 0x0B46
|
|
604
|
+
readonly DEPTH_RANGE = 0x0B70
|
|
605
|
+
readonly DEPTH_WRITEMASK = 0x0B72
|
|
606
|
+
readonly DEPTH_CLEAR_VALUE = 0x0B73
|
|
607
|
+
readonly DEPTH_FUNC = 0x0B74
|
|
608
|
+
readonly STENCIL_CLEAR_VALUE = 0x0B91
|
|
609
|
+
readonly STENCIL_FUNC = 0x0B92
|
|
610
|
+
readonly STENCIL_FAIL = 0x0B94
|
|
611
|
+
readonly STENCIL_PASS_DEPTH_FAIL = 0x0B95
|
|
612
|
+
readonly STENCIL_PASS_DEPTH_PASS = 0x0B96
|
|
613
|
+
readonly STENCIL_REF = 0x0B97
|
|
614
|
+
readonly STENCIL_VALUE_MASK = 0x0B93
|
|
615
|
+
readonly STENCIL_WRITEMASK = 0x0B98
|
|
616
|
+
readonly VIEWPORT = 0x0BA2
|
|
617
|
+
readonly SCISSOR_BOX = 0x0C10
|
|
618
|
+
readonly COLOR_CLEAR_VALUE = 0x0C22
|
|
619
|
+
readonly COLOR_WRITEMASK = 0x0C23
|
|
620
|
+
readonly UNPACK_ALIGNMENT = 0x0CF5
|
|
621
|
+
readonly PACK_ALIGNMENT = 0x0D05
|
|
622
|
+
readonly MAX_TEXTURE_SIZE = 0x0D33
|
|
623
|
+
readonly MAX_VIEWPORT_DIMS = 0x0D3A
|
|
624
|
+
readonly SUBPIXEL_BITS = 0x0D50
|
|
625
|
+
readonly RED_BITS = 0x0D52
|
|
626
|
+
readonly GREEN_BITS = 0x0D53
|
|
627
|
+
readonly BLUE_BITS = 0x0D54
|
|
628
|
+
readonly ALPHA_BITS = 0x0D55
|
|
629
|
+
readonly DEPTH_BITS = 0x0D56
|
|
630
|
+
readonly STENCIL_BITS = 0x0D57
|
|
631
|
+
readonly POLYGON_OFFSET_UNITS = 0x2A00
|
|
632
|
+
readonly POLYGON_OFFSET_FACTOR = 0x8038
|
|
633
|
+
readonly TEXTURE_BINDING_2D = 0x8069
|
|
634
|
+
readonly SAMPLE_BUFFERS = 0x80A8
|
|
635
|
+
readonly SAMPLES = 0x80A9
|
|
636
|
+
readonly SAMPLE_COVERAGE_VALUE = 0x80AA
|
|
637
|
+
readonly SAMPLE_COVERAGE_INVERT = 0x80AB
|
|
638
|
+
readonly COMPRESSED_TEXTURE_FORMATS = 0x86A3
|
|
639
|
+
readonly DONT_CARE = 0x1100
|
|
640
|
+
readonly FASTEST = 0x1101
|
|
641
|
+
readonly NICEST = 0x1102
|
|
642
|
+
readonly GENERATE_MIPMAP_HINT = 0x8192
|
|
643
|
+
readonly BYTE = 0x1400
|
|
644
|
+
readonly UNSIGNED_BYTE = 0x1401
|
|
645
|
+
readonly SHORT = 0x1402
|
|
646
|
+
readonly UNSIGNED_SHORT = 0x1403
|
|
647
|
+
readonly INT = 0x1404
|
|
648
|
+
readonly UNSIGNED_INT = 0x1405
|
|
649
|
+
readonly FLOAT = 0x1406
|
|
650
|
+
readonly SYNC_FLUSH_COMMANDS_BIT = 0x00000001
|
|
651
|
+
readonly ALREADY_SIGNALED = 0x911A
|
|
652
|
+
readonly TIMEOUT_EXPIRED = 0x911B
|
|
653
|
+
readonly CONDITION_SATISFIED = 0x911C
|
|
654
|
+
readonly WAIT_FAILED = 0x911D
|
|
655
|
+
readonly COLOR = 0x1800
|
|
656
|
+
readonly DEPTH_COMPONENT = 0x1902
|
|
657
|
+
readonly ALPHA = 0x1906
|
|
658
|
+
readonly RGB = 0x1907
|
|
659
|
+
readonly RGBA = 0x1908
|
|
660
|
+
readonly LUMINANCE = 0x1909
|
|
661
|
+
readonly LUMINANCE_ALPHA = 0x190A
|
|
662
|
+
readonly UNSIGNED_SHORT_4_4_4_4 = 0x8033
|
|
663
|
+
readonly UNSIGNED_SHORT_5_5_5_1 = 0x8034
|
|
664
|
+
readonly UNSIGNED_SHORT_5_6_5 = 0x8363
|
|
665
|
+
readonly FRAGMENT_SHADER = 0x8B30
|
|
666
|
+
readonly VERTEX_SHADER = 0x8B31
|
|
667
|
+
readonly MAX_VERTEX_ATTRIBS = 0x8869
|
|
668
|
+
readonly MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB
|
|
669
|
+
readonly MAX_VARYING_VECTORS = 0x8DFC
|
|
670
|
+
readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D
|
|
671
|
+
readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C
|
|
672
|
+
readonly MAX_TEXTURE_IMAGE_UNITS = 0x8872
|
|
673
|
+
readonly MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD
|
|
674
|
+
readonly SHADER_TYPE = 0x8B4F
|
|
675
|
+
readonly DELETE_STATUS = 0x8B80
|
|
676
|
+
readonly COMPILE_STATUS = 0x8B81
|
|
677
|
+
readonly LINK_STATUS = 0x8B82
|
|
678
|
+
readonly VALIDATE_STATUS = 0x8B83
|
|
679
|
+
readonly ATTACHED_SHADERS = 0x8B85
|
|
680
|
+
readonly ACTIVE_UNIFORMS = 0x8B86
|
|
681
|
+
readonly ACTIVE_ATTRIBUTES = 0x8B89
|
|
682
|
+
readonly SHADING_LANGUAGE_VERSION = 0x8B8C
|
|
683
|
+
readonly CURRENT_PROGRAM = 0x8B8D
|
|
684
|
+
readonly NEVER = 0x0200
|
|
685
|
+
readonly LESS = 0x0201
|
|
686
|
+
readonly EQUAL = 0x0202
|
|
687
|
+
readonly LEQUAL = 0x0203
|
|
688
|
+
readonly GREATER = 0x0204
|
|
689
|
+
readonly NOTEQUAL = 0x0205
|
|
690
|
+
readonly GEQUAL = 0x0206
|
|
691
|
+
readonly ALWAYS = 0x0207
|
|
692
|
+
readonly KEEP = 0x1E00
|
|
693
|
+
readonly REPLACE = 0x1E01
|
|
694
|
+
readonly INCR = 0x1E02
|
|
695
|
+
readonly DECR = 0x1E03
|
|
696
|
+
readonly INVERT = 0x150A
|
|
697
|
+
readonly INCR_WRAP = 0x8507
|
|
698
|
+
readonly DECR_WRAP = 0x8508
|
|
699
|
+
readonly VENDOR = 0x1F00
|
|
700
|
+
readonly RENDERER = 0x1F01
|
|
701
|
+
readonly VERSION = 0x1F02
|
|
702
|
+
readonly NEAREST = 0x2600
|
|
703
|
+
readonly LINEAR = 0x2601
|
|
704
|
+
readonly NEAREST_MIPMAP_NEAREST = 0x2700
|
|
705
|
+
readonly LINEAR_MIPMAP_NEAREST = 0x2701
|
|
706
|
+
readonly NEAREST_MIPMAP_LINEAR = 0x2702
|
|
707
|
+
readonly LINEAR_MIPMAP_LINEAR = 0x2703
|
|
708
|
+
readonly TEXTURE_MAG_FILTER = 0x2800
|
|
709
|
+
readonly TEXTURE_MIN_FILTER = 0x2801
|
|
710
|
+
readonly TEXTURE_WRAP_S = 0x2802
|
|
711
|
+
readonly TEXTURE_WRAP_T = 0x2803
|
|
712
|
+
readonly TEXTURE_2D = 0x0DE1
|
|
713
|
+
readonly TEXTURE = 0x1702
|
|
714
|
+
readonly TEXTURE_CUBE_MAP = 0x8513
|
|
715
|
+
readonly TEXTURE_BINDING_CUBE_MAP = 0x8514
|
|
716
|
+
readonly TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515
|
|
717
|
+
readonly TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516
|
|
718
|
+
readonly TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517
|
|
719
|
+
readonly TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518
|
|
720
|
+
readonly TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519
|
|
721
|
+
readonly TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A
|
|
722
|
+
readonly MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C
|
|
723
|
+
readonly TEXTURE0 = 0x84C0
|
|
724
|
+
readonly TEXTURE1 = 0x84C1
|
|
725
|
+
readonly TEXTURE2 = 0x84C2
|
|
726
|
+
readonly TEXTURE3 = 0x84C3
|
|
727
|
+
readonly TEXTURE31 = 0x84DF
|
|
728
|
+
readonly ACTIVE_TEXTURE = 0x84E0
|
|
729
|
+
readonly MAX_RENDERBUFFER_SIZE = 0x84E8
|
|
730
|
+
readonly REPEAT = 0x2901
|
|
731
|
+
readonly CLAMP_TO_EDGE = 0x812F
|
|
732
|
+
readonly MIRRORED_REPEAT = 0x8370
|
|
733
|
+
readonly FLOAT_VEC2 = 0x8B50
|
|
734
|
+
readonly FLOAT_VEC3 = 0x8B51
|
|
735
|
+
readonly FLOAT_VEC4 = 0x8B52
|
|
736
|
+
readonly INT_VEC2 = 0x8B53
|
|
737
|
+
readonly INT_VEC3 = 0x8B54
|
|
738
|
+
readonly INT_VEC4 = 0x8B55
|
|
739
|
+
readonly BOOL = 0x8B56
|
|
740
|
+
readonly BOOL_VEC2 = 0x8B57
|
|
741
|
+
readonly BOOL_VEC3 = 0x8B58
|
|
742
|
+
readonly BOOL_VEC4 = 0x8B59
|
|
743
|
+
readonly FLOAT_MAT2 = 0x8B5A
|
|
744
|
+
readonly FLOAT_MAT3 = 0x8B5B
|
|
745
|
+
readonly FLOAT_MAT4 = 0x8B5C
|
|
746
|
+
readonly SAMPLER_2D = 0x8B5E
|
|
747
|
+
readonly SAMPLER_CUBE = 0x8B60
|
|
748
|
+
readonly LOW_FLOAT = 0x8DF0
|
|
749
|
+
readonly MEDIUM_FLOAT = 0x8DF1
|
|
750
|
+
readonly HIGH_FLOAT = 0x8DF2
|
|
751
|
+
readonly LOW_INT = 0x8DF3
|
|
752
|
+
readonly MEDIUM_INT = 0x8DF4
|
|
753
|
+
readonly HIGH_INT = 0x8DF5
|
|
754
|
+
readonly FRAMEBUFFER = 0x8D40
|
|
755
|
+
readonly RENDERBUFFER = 0x8D41
|
|
756
|
+
readonly RGBA4 = 0x8056
|
|
757
|
+
readonly RGB5_A1 = 0x8057
|
|
758
|
+
readonly RGBA8 = 0x8058
|
|
759
|
+
readonly RGB565 = 0x8D62
|
|
760
|
+
readonly DEPTH_COMPONENT16 = 0x81A5
|
|
761
|
+
readonly DEPTH_COMPONENT24 = 0x81A6
|
|
762
|
+
readonly STENCIL_INDEX8 = 0x8D48
|
|
763
|
+
readonly DEPTH_STENCIL = 0x84F9
|
|
764
|
+
readonly RENDERBUFFER_WIDTH = 0x8D42
|
|
765
|
+
readonly RENDERBUFFER_HEIGHT = 0x8D43
|
|
766
|
+
readonly RENDERBUFFER_INTERNAL_FORMAT = 0x8D44
|
|
767
|
+
readonly RENDERBUFFER_RED_SIZE = 0x8D50
|
|
768
|
+
readonly RENDERBUFFER_GREEN_SIZE = 0x8D51
|
|
769
|
+
readonly RENDERBUFFER_BLUE_SIZE = 0x8D52
|
|
770
|
+
readonly RENDERBUFFER_ALPHA_SIZE = 0x8D53
|
|
771
|
+
readonly RENDERBUFFER_DEPTH_SIZE = 0x8D54
|
|
772
|
+
readonly RENDERBUFFER_STENCIL_SIZE = 0x8D55
|
|
773
|
+
readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0
|
|
774
|
+
readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1
|
|
775
|
+
readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2
|
|
776
|
+
readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3
|
|
777
|
+
readonly COLOR_ATTACHMENT0 = 0x8CE0
|
|
778
|
+
readonly DEPTH_ATTACHMENT = 0x8D00
|
|
779
|
+
readonly STENCIL_ATTACHMENT = 0x8D20
|
|
780
|
+
readonly DEPTH_STENCIL_ATTACHMENT = 0x821A
|
|
781
|
+
readonly NONE = 0
|
|
782
|
+
readonly FRAMEBUFFER_COMPLETE = 0x8CD5
|
|
783
|
+
readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6
|
|
784
|
+
readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7
|
|
785
|
+
readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9
|
|
786
|
+
readonly FRAMEBUFFER_UNSUPPORTED = 0x8CDD
|
|
787
|
+
readonly HALF_FLOAT = 0x140B
|
|
788
|
+
readonly DEPTH24_STENCIL8 = 0x88F0
|
|
789
|
+
readonly DEPTH_COMPONENT32F = 0x8CAC
|
|
790
|
+
readonly DEPTH32F_STENCIL8 = 0x8CAD
|
|
791
|
+
readonly RGBA32F = 0x8814
|
|
792
|
+
readonly RGB32F = 0x8815
|
|
793
|
+
readonly RGBA16F = 0x881A
|
|
794
|
+
readonly RGB16F = 0x881B
|
|
795
|
+
readonly READ_FRAMEBUFFER = 0x8CA8
|
|
796
|
+
readonly DRAW_FRAMEBUFFER = 0x8CA9
|
|
797
|
+
readonly READ_FRAMEBUFFER_BINDING = 0x8CAA
|
|
798
|
+
readonly DRAW_FRAMEBUFFER_BINDING = 0x8CA6
|
|
799
|
+
readonly UNPACK_FLIP_Y_WEBGL = 0x9240
|
|
800
|
+
readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241
|
|
801
|
+
readonly UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243
|
|
802
|
+
readonly READ_BUFFER = 0x0C02
|
|
803
|
+
readonly UNPACK_ROW_LENGTH = 0x0CF2
|
|
804
|
+
readonly UNPACK_SKIP_ROWS = 0x0CF3
|
|
805
|
+
readonly UNPACK_SKIP_PIXELS = 0x0CF4
|
|
806
|
+
readonly UNPACK_IMAGE_HEIGHT = 0x806E
|
|
807
|
+
readonly UNPACK_SKIP_IMAGES = 0x806D
|
|
808
|
+
readonly MAX_SAMPLES = 0x8D57
|
|
809
|
+
readonly TEXTURE_3D = 0x806F
|
|
810
|
+
readonly TEXTURE_2D_ARRAY = 0x8C1A
|
|
811
|
+
readonly MAX_3D_TEXTURE_SIZE = 0x8073
|
|
812
|
+
readonly MAX_ARRAY_TEXTURE_LAYERS = 0x88FF
|
|
813
|
+
readonly RED = 0x1903
|
|
814
|
+
readonly RG = 0x8227
|
|
815
|
+
readonly RED_INTEGER = 0x8D94
|
|
816
|
+
readonly RG_INTEGER = 0x8228
|
|
817
|
+
readonly RGBA_INTEGER = 0x8D99
|
|
818
|
+
readonly SRGB8_ALPHA8 = 0x8C43
|
|
819
|
+
readonly IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B
|
|
820
|
+
readonly IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A
|
|
821
|
+
readonly TEXTURE_WRAP_R = 0x8072
|
|
822
|
+
readonly TEXTURE_COMPARE_MODE = 0x884C
|
|
823
|
+
readonly TEXTURE_COMPARE_FUNC = 0x884D
|
|
824
|
+
readonly COMPARE_REF_TO_TEXTURE = 0x884E
|
|
825
|
+
readonly MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F
|
|
826
|
+
readonly UNIFORM_BUFFER = 0x8A11
|
|
827
|
+
readonly DRAW_BUFFER0 = 0x8825
|
|
828
|
+
readonly BROWSER_DEFAULT_WEBGL = 0x9244
|
|
829
|
+
readonly MIN = 0x8007
|
|
830
|
+
readonly MAX = 0x8008
|
|
831
|
+
readonly UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B
|
|
832
|
+
readonly UNSIGNED_INT_5_9_9_9_REV = 0x8C3E
|
|
833
|
+
readonly UNSIGNED_INT_24_8 = 0x84FA
|
|
834
|
+
readonly R11F_G11F_B10F = 0x8C3A
|
|
835
|
+
readonly RGB9_E5 = 0x8C3D
|
|
836
|
+
readonly R8 = 0x8229
|
|
837
|
+
readonly R8I = 0x8231
|
|
838
|
+
readonly R8UI = 0x8232
|
|
839
|
+
readonly R16I = 0x8233
|
|
840
|
+
readonly R16UI = 0x8234
|
|
841
|
+
readonly R32I = 0x8235
|
|
842
|
+
readonly R32UI = 0x8236
|
|
843
|
+
readonly R16F = 0x822D
|
|
844
|
+
readonly R32F = 0x822E
|
|
845
|
+
readonly RG8 = 0x822B
|
|
846
|
+
readonly RG8I = 0x8237
|
|
847
|
+
readonly RG8UI = 0x8238
|
|
848
|
+
readonly RG16I = 0x8239
|
|
849
|
+
readonly RG16UI = 0x823A
|
|
850
|
+
readonly RG32I = 0x823B
|
|
851
|
+
readonly RG32UI = 0x823C
|
|
852
|
+
readonly RG16F = 0x822F
|
|
853
|
+
readonly RG32F = 0x8230
|
|
854
|
+
readonly RGB8I = 0x8D8F
|
|
855
|
+
readonly RGB8UI = 0x8D7D
|
|
856
|
+
readonly RGB16I = 0x8D89
|
|
857
|
+
readonly RGB16UI = 0x8D77
|
|
858
|
+
readonly RGB32I = 0x8D83
|
|
859
|
+
readonly RGB32UI = 0x8D71
|
|
860
|
+
readonly RGBA8I = 0x8D8E
|
|
861
|
+
readonly RGBA8UI = 0x8D7C
|
|
862
|
+
readonly RGBA16I = 0x8D88
|
|
863
|
+
readonly RGBA16UI = 0x8D76
|
|
864
|
+
readonly RGBA32I = 0x8D82
|
|
865
|
+
readonly RGBA32UI = 0x8D70
|
|
866
|
+
readonly RGB_INTEGER = 0x8D98
|
|
867
|
+
readonly SAMPLER_2D_SHADOW = 0x8B62
|
|
868
|
+
readonly SAMPLER_CUBE_SHADOW = 0x8DC5
|
|
869
|
+
readonly SAMPLER_2D_ARRAY_SHADOW = 0x8DCF
|
|
870
|
+
readonly PACK_ROW_LENGTH = 0x0D02
|
|
871
|
+
readonly PACK_SKIP_ROWS = 0x0D03
|
|
872
|
+
readonly PACK_SKIP_PIXELS = 0x0D04
|
|
873
|
+
|
|
874
|
+
constructor(canvasWidth: () => number, canvasHeight: () => number) {
|
|
875
|
+
this.canvasWidth = canvasWidth
|
|
876
|
+
this.canvasHeight = canvasHeight
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
get canvas(): NativeWebGLCanvasMetrics { return new NativeWebGLCanvasMetrics(this.canvasWidth(), this.canvasHeight()) }
|
|
880
|
+
get drawingBufferWidth(): number { return nativeWebGLWidth() }
|
|
881
|
+
get drawingBufferHeight(): number { return nativeWebGLHeight() }
|
|
882
|
+
|
|
883
|
+
getContextAttributes() {
|
|
884
|
+
return {
|
|
885
|
+
alpha: true,
|
|
886
|
+
antialias: false,
|
|
887
|
+
depth: true,
|
|
888
|
+
desynchronized: false,
|
|
889
|
+
failIfMajorPerformanceCaveat: false,
|
|
890
|
+
powerPreference: 'default',
|
|
891
|
+
premultipliedAlpha: true,
|
|
892
|
+
preserveDrawingBuffer: false,
|
|
893
|
+
stencil: true,
|
|
894
|
+
xrCompatible: false,
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
isContextLost(): boolean { return false }
|
|
899
|
+
getSupportedExtensions(): string[] { return ['EXT_texture_filter_anisotropic', 'OES_texture_float_linear', 'EXT_color_buffer_float'] }
|
|
900
|
+
|
|
901
|
+
getExtension(name: string): WebGLExtension | null {
|
|
902
|
+
// One shared shape for every supported name -- see `WebGLExtension`. The
|
|
903
|
+
// per-name literals this replaced carried only the two constants each
|
|
904
|
+
// caller happened to read, and typed the result `object`, which is what
|
|
905
|
+
// made every read of them dynamic.
|
|
906
|
+
if (
|
|
907
|
+
name === 'EXT_texture_filter_anisotropic' ||
|
|
908
|
+
name === 'WEBGL_debug_renderer_info' ||
|
|
909
|
+
name === 'OES_texture_float_linear' ||
|
|
910
|
+
name === 'EXT_color_buffer_float' ||
|
|
911
|
+
name === 'EXT_color_buffer_half_float'
|
|
912
|
+
) {
|
|
913
|
+
return new WebGLExtension()
|
|
914
|
+
}
|
|
915
|
+
return null
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
getParameter(name: number): number | string | Int32Array | Float32Array {
|
|
919
|
+
if (name === this.VERSION) return 'WebGL 2.0 (ANGLE Metal native shim)'
|
|
920
|
+
if (name === this.SHADING_LANGUAGE_VERSION) return 'WebGL GLSL ES 3.00'
|
|
921
|
+
if (name === this.VENDOR) return 'Gea'
|
|
922
|
+
if (name === this.RENDERER) return 'Three.js -> WebGL shim -> ANGLE/Metal'
|
|
923
|
+
if (name === this.MAX_TEXTURE_SIZE || name === this.MAX_CUBE_MAP_TEXTURE_SIZE) return 16384
|
|
924
|
+
if (name === this.MAX_RENDERBUFFER_SIZE || name === this.MAX_3D_TEXTURE_SIZE) return 16384
|
|
925
|
+
if (name === this.MAX_ARRAY_TEXTURE_LAYERS) return 2048
|
|
926
|
+
if (name === this.MAX_VERTEX_ATTRIBS) return 16
|
|
927
|
+
if (name === this.MAX_TEXTURE_IMAGE_UNITS || name === this.MAX_VERTEX_TEXTURE_IMAGE_UNITS) return 16
|
|
928
|
+
if (name === this.MAX_COMBINED_TEXTURE_IMAGE_UNITS) return 32
|
|
929
|
+
if (name === this.MAX_VERTEX_UNIFORM_VECTORS || name === this.MAX_FRAGMENT_UNIFORM_VECTORS) return 1024
|
|
930
|
+
if (name === this.MAX_VARYING_VECTORS) return 32
|
|
931
|
+
if (name === this.MAX_SAMPLES || name === this.SAMPLES) return 4
|
|
932
|
+
if (name === this.MAX_UNIFORM_BUFFER_BINDINGS) return 24
|
|
933
|
+
if (name === this.DEPTH_BITS) return 24
|
|
934
|
+
if (name === this.STENCIL_BITS) return 8
|
|
935
|
+
if (name === this.RED_BITS || name === this.GREEN_BITS || name === this.BLUE_BITS || name === this.ALPHA_BITS) return 8
|
|
936
|
+
if (name === this.IMPLEMENTATION_COLOR_READ_FORMAT) return this.RGBA
|
|
937
|
+
if (name === this.IMPLEMENTATION_COLOR_READ_TYPE) return this.UNSIGNED_BYTE
|
|
938
|
+
if (name === this.MAX_VIEWPORT_DIMS) return new Int32Array([16384, 16384])
|
|
939
|
+
if (name === this.VIEWPORT || name === this.SCISSOR_BOX) return new Int32Array([0, 0, this.canvasWidth(), this.canvasHeight()])
|
|
940
|
+
if (name === this.ALIASED_LINE_WIDTH_RANGE || name === this.ALIASED_POINT_SIZE_RANGE) return new Float32Array([1, 1])
|
|
941
|
+
if (name === this.COMPRESSED_TEXTURE_FORMATS) return new Int32Array(0)
|
|
942
|
+
if (name === 0x84FF) return 1
|
|
943
|
+
return 0
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
getShaderPrecisionFormat(_shadertype: number, _precisiontype: number): { rangeMin: number; rangeMax: number; precision: number } {
|
|
947
|
+
return { rangeMin: 127, rangeMax: 127, precision: 23 }
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
createBuffer(): NativeHandle { return createHandle('buffer', nativeWebGLCreateBuffer()) }
|
|
951
|
+
deleteBuffer(buffer: NativeHandle | null): void { nativeWebGLDeleteBuffer(nullableNativeHandle(buffer)) }
|
|
952
|
+
bindBuffer(target: number, buffer: NativeHandle | null): void { nativeWebGLBindBuffer(target, nullableNativeHandle(buffer)) }
|
|
953
|
+
bufferData(target: number, dataOrSize: BufferSourceLike | number, usage: number): void {
|
|
954
|
+
if (typeof dataOrSize === 'number') {
|
|
955
|
+
threeWebGLBufferData(target, usage, 4, zeroF32Array(dataOrSize))
|
|
956
|
+
return
|
|
957
|
+
}
|
|
958
|
+
threeWebGLBufferData(target, usage, typedArrayKind(dataOrSize), dataOrSize)
|
|
959
|
+
}
|
|
960
|
+
bufferDataWithKind(target: number, data: BufferSourceLike, usage: number, kind: number): void {
|
|
961
|
+
threeWebGLBufferData(target, usage, kind, data)
|
|
962
|
+
}
|
|
963
|
+
bufferSubData(target: number, offset: number, data: BufferSourceLike): void {
|
|
964
|
+
threeWebGLBufferSubData(target, offset, typedArrayKind(data), data)
|
|
965
|
+
}
|
|
966
|
+
bufferSubDataWithKind(
|
|
967
|
+
target: number,
|
|
968
|
+
offset: number,
|
|
969
|
+
data: BufferSourceLike,
|
|
970
|
+
kind: number,
|
|
971
|
+
sourceOffset = 0,
|
|
972
|
+
length?: number,
|
|
973
|
+
): void {
|
|
974
|
+
if (!data) return
|
|
975
|
+
const end = length === undefined ? data.length : Math.min(data.length, sourceOffset + length)
|
|
976
|
+
threeWebGLBufferSubDataRange(target, offset, kind, data, sourceOffset, Math.max(0, end - sourceOffset))
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
createShader(type: number): NativeShader | null {
|
|
980
|
+
const handle = nativeWebGLCreateShader(type)
|
|
981
|
+
return handle > 0 ? new NativeShader(handle, type) : null
|
|
982
|
+
}
|
|
983
|
+
shaderSource(shader: NativeShader, source: string): void {
|
|
984
|
+
shader.source = source
|
|
985
|
+
shaderSourceByHandle.set(nativeHandle(shader), source)
|
|
986
|
+
nativeWebGLShaderSource(nativeHandle(shader), source)
|
|
987
|
+
}
|
|
988
|
+
compileShader(shader: NativeShader): void {
|
|
989
|
+
nativeWebGLCompileShader(nativeHandle(shader))
|
|
990
|
+
}
|
|
991
|
+
getShaderParameter(shader: NativeShader, pname: number): boolean {
|
|
992
|
+
if (pname === this.DELETE_STATUS) return false
|
|
993
|
+
return nativeWebGLGetShaderParameter(nativeHandle(shader), pname) !== 0
|
|
994
|
+
}
|
|
995
|
+
getShaderInfoLog(_shader: NativeHandle | null): string { return '' }
|
|
996
|
+
getShaderSource(shader: NativeShader): string { return shaderSourceFor(shader) }
|
|
997
|
+
deleteShader(shader: NativeShader | null): void { if (shader) { shaderSourceByHandle.delete(nativeHandle(shader)); nativeWebGLDeleteShader(nativeHandle(shader)) } }
|
|
998
|
+
|
|
999
|
+
createProgram(): NativeProgram | null {
|
|
1000
|
+
const handle = nativeWebGLCreateProgram()
|
|
1001
|
+
return handle > 0 ? new NativeProgram(handle) : null
|
|
1002
|
+
}
|
|
1003
|
+
attachShader(program: NativeProgram, shader: NativeShader): void {
|
|
1004
|
+
program.shaders.push(shader)
|
|
1005
|
+
nativeWebGLAttachShader(nativeHandle(program), nativeHandle(shader))
|
|
1006
|
+
}
|
|
1007
|
+
detachShader(program: NativeProgram, shader: NativeShader): void {
|
|
1008
|
+
program.shaders = program.shaders.filter((attachedShader) => attachedShader !== shader)
|
|
1009
|
+
}
|
|
1010
|
+
bindAttribLocation(_program: NativeProgram, _index: number, _name: string): void {}
|
|
1011
|
+
linkProgram(program: NativeProgram): void {
|
|
1012
|
+
nativeWebGLLinkProgram(nativeHandle(program))
|
|
1013
|
+
}
|
|
1014
|
+
useProgram(program: NativeProgram | null): void { nativeWebGLUseProgram(nullableNativeHandle(program)) }
|
|
1015
|
+
getProgramParameter(program: NativeProgram, pname: number): number | boolean {
|
|
1016
|
+
// ACTIVE_* counts are numeric — keep them off the boolifying generic path.
|
|
1017
|
+
if (pname === this.ACTIVE_ATTRIBUTES) return nativeWebGLGetProgramParameter(nativeHandle(program), pname)
|
|
1018
|
+
if (pname === this.ACTIVE_UNIFORMS) return nativeWebGLGetProgramParameter(nativeHandle(program), pname)
|
|
1019
|
+
if (pname === this.DELETE_STATUS) return false
|
|
1020
|
+
if (pname === this.ATTACHED_SHADERS) return program.shaders.length
|
|
1021
|
+
if (pname === this.VALIDATE_STATUS) return true
|
|
1022
|
+
return nativeWebGLGetProgramParameter(nativeHandle(program), pname) !== 0
|
|
1023
|
+
}
|
|
1024
|
+
getProgramInfoLog(_program: NativeProgram | null): string { return '' }
|
|
1025
|
+
deleteProgram(program: NativeProgram | null): void { if (program) { nativeWebGLDeleteProgram(nativeHandle(program)) } }
|
|
1026
|
+
validateProgram(_program: NativeProgram): void {}
|
|
1027
|
+
getAttachedShaders(program: NativeProgram): NativeShader[] { return program.shaders }
|
|
1028
|
+
getActiveAttrib(program: NativeProgram, index: number): { name: string; type: number; size: number } | null {
|
|
1029
|
+
return parseActiveInfoString(nativeWebGLGetActiveAttribInfo(nativeHandle(program), index))
|
|
1030
|
+
}
|
|
1031
|
+
getActiveUniform(program: NativeProgram, index: number): { name: string; type: number; size: number } | null {
|
|
1032
|
+
return parseActiveInfoString(nativeWebGLGetActiveUniformInfo(nativeHandle(program), index))
|
|
1033
|
+
}
|
|
1034
|
+
getAttribLocation(program: NativeProgram, name: string): number {
|
|
1035
|
+
return nativeWebGLGetAttribLocation(nativeHandle(program), name)
|
|
1036
|
+
}
|
|
1037
|
+
getUniformLocation(program: NativeProgram, name: string): NativeHandle {
|
|
1038
|
+
return createHandle('uniform', nativeWebGLGetUniformLocation(nativeHandle(program), name))
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
enableVertexAttribArray(index: number): void { nativeWebGLEnableVertexAttribArray(index) }
|
|
1042
|
+
disableVertexAttribArray(index: number): void { nativeWebGLDisableVertexAttribArray(index) }
|
|
1043
|
+
vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void {
|
|
1044
|
+
nativeWebGLVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, offset)
|
|
1045
|
+
}
|
|
1046
|
+
vertexAttribIPointer(index: number, size: number, type: number, stride: number, offset: number): void {
|
|
1047
|
+
nativeWebGLVertexAttribPointer(index, size, type, 0, stride, offset)
|
|
1048
|
+
}
|
|
1049
|
+
vertexAttribDivisor(index: number, divisor: number): void { nativeWebGLVertexAttribDivisor(index, divisor) }
|
|
1050
|
+
vertexAttrib1fv(_index: number, _values: BufferSourceLike): void {}
|
|
1051
|
+
vertexAttrib2fv(_index: number, _values: BufferSourceLike): void {}
|
|
1052
|
+
vertexAttrib3fv(_index: number, _values: BufferSourceLike): void {}
|
|
1053
|
+
vertexAttrib4fv(_index: number, _values: BufferSourceLike): void {}
|
|
1054
|
+
|
|
1055
|
+
uniform1f(location: NativeHandle | null, x: number): void { nativeWebGLUniform1f(nullableNativeHandle(location), x) }
|
|
1056
|
+
uniform1i(location: NativeHandle | null, x: number): void { nativeWebGLUniform1i(nullableNativeHandle(location), x) }
|
|
1057
|
+
uniform2f(location: NativeHandle | null, x: number, y: number): void { nativeWebGLUniform2f(nullableNativeHandle(location), x, y) }
|
|
1058
|
+
uniform3f(location: NativeHandle | null, x: number, y: number, z: number): void { nativeWebGLUniform3f(nullableNativeHandle(location), x, y, z) }
|
|
1059
|
+
uniform4f(location: NativeHandle | null, x: number, y: number, z: number, w: number): void { nativeWebGLUniform4f(nullableNativeHandle(location), x, y, z, w) }
|
|
1060
|
+
uniformMatrix3fv(location: NativeHandle | null, transpose: boolean, value: BufferSourceLike): void {
|
|
1061
|
+
threeWebGLUniformMatrix3fv(nullableNativeHandle(location), 1, transpose ? 1 : 0, value)
|
|
1062
|
+
}
|
|
1063
|
+
uniformMatrix4fv(location: NativeHandle | null, transpose: boolean, value: BufferSourceLike): void {
|
|
1064
|
+
threeWebGLUniformMatrix4fv(nullableNativeHandle(location), 1, transpose ? 1 : 0, value)
|
|
1065
|
+
}
|
|
1066
|
+
uniform1fv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform1fv(nullableNativeHandle(location), value) }
|
|
1067
|
+
uniform2fv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform2fv(nullableNativeHandle(location), value) }
|
|
1068
|
+
uniform3fv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform3fv(nullableNativeHandle(location), value) }
|
|
1069
|
+
uniform4fv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform4fv(nullableNativeHandle(location), value) }
|
|
1070
|
+
uniform1iv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform1iv(nullableNativeHandle(location), value) }
|
|
1071
|
+
uniform2i(location: NativeHandle | null, x: number, y: number): void { this.uniform2f(location, x, y) }
|
|
1072
|
+
uniform3i(location: NativeHandle | null, x: number, y: number, z: number): void { this.uniform3f(location, x, y, z) }
|
|
1073
|
+
uniform4i(location: NativeHandle | null, x: number, y: number, z: number, w: number): void { this.uniform4f(location, x, y, z, w) }
|
|
1074
|
+
uniform2iv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform2iv(nullableNativeHandle(location), value) }
|
|
1075
|
+
uniform3iv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform3iv(nullableNativeHandle(location), value) }
|
|
1076
|
+
uniform4iv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform4iv(nullableNativeHandle(location), value) }
|
|
1077
|
+
uniform1ui(location: NativeHandle | null, x: number): void { this.uniform1i(location, x) }
|
|
1078
|
+
uniform2ui(location: NativeHandle | null, x: number, y: number): void { this.uniform2i(location, x, y) }
|
|
1079
|
+
uniform3ui(location: NativeHandle | null, x: number, y: number, z: number): void { this.uniform3i(location, x, y, z) }
|
|
1080
|
+
uniform4ui(location: NativeHandle | null, x: number, y: number, z: number, w: number): void { this.uniform4i(location, x, y, z, w) }
|
|
1081
|
+
uniform1uiv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform1uiv(nullableNativeHandle(location), value) }
|
|
1082
|
+
uniform2uiv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform2uiv(nullableNativeHandle(location), value) }
|
|
1083
|
+
uniform3uiv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform3uiv(nullableNativeHandle(location), value) }
|
|
1084
|
+
uniform4uiv(location: NativeHandle | null, value: BufferSourceLike): void { threeWebGLUniform4uiv(nullableNativeHandle(location), value) }
|
|
1085
|
+
uniformMatrix2fv(location: NativeHandle | null, transpose: boolean, value: BufferSourceLike): void { threeWebGLUniformMatrix2fv(nullableNativeHandle(location), 1, transpose ? 1 : 0, value) }
|
|
1086
|
+
|
|
1087
|
+
createTexture(): NativeHandle { return createHandle('texture', nativeWebGLCreateTexture()) }
|
|
1088
|
+
deleteTexture(texture: NativeHandle | null): void { nativeWebGLDeleteTexture(nullableNativeHandle(texture)) }
|
|
1089
|
+
bindTexture(target: number, texture: NativeHandle | null): void { nativeWebGLBindTexture(target, nullableNativeHandle(texture)) }
|
|
1090
|
+
activeTexture(texture: number): void { nativeWebGLActiveTexture(texture) }
|
|
1091
|
+
texParameteri(target: number, pname: number, param: number): void { nativeWebGLTexParameteri(target, pname, param) }
|
|
1092
|
+
texParameterf(target: number, pname: number, param: number): void { nativeWebGLTexParameteri(target, pname, param) }
|
|
1093
|
+
pixelStorei(pname: number, param: number | boolean): void { nativeWebGLPixelStorei(pname, param === true ? 1 : param === false ? 0 : param) }
|
|
1094
|
+
generateMipmap(target: number): void { nativeWebGLGenerateMipmap(target) }
|
|
1095
|
+
texImage2D(target: number, level: number, internalFormat: number, widthOrFormat: number, heightOrType: number, borderOrSource?: number | TexImageSource | null, format?: number, type?: number, pixels?: BufferSourceLike | TexImageSource | null): void {
|
|
1096
|
+
if (typeof borderOrSource === 'number' && typeof format === 'number' && typeof type === 'number') {
|
|
1097
|
+
threeWebGLTexImage2D(target, level, internalFormat, widthOrFormat, heightOrType, format, type, pixels as BufferSourceLike)
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: BufferSourceLike): void {
|
|
1101
|
+
threeWebGLTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels)
|
|
1102
|
+
}
|
|
1103
|
+
compressedTexImage2D(_target: number, _level: number, _internalFormat: number, _width: number, _height: number, _border: number, _data: BufferSourceLike): void {}
|
|
1104
|
+
compressedTexSubImage2D(_target: number, _level: number, _xoffset: number, _yoffset: number, _width: number, _height: number, _format: number, _data: BufferSourceLike): void {}
|
|
1105
|
+
compressedTexImage3D(_target: number, _level: number, _internalFormat: number, _width: number, _height: number, _depth: number, _border: number, _data: BufferSourceLike): void {}
|
|
1106
|
+
compressedTexSubImage3D(_target: number, _level: number, _xoffset: number, _yoffset: number, _zoffset: number, _width: number, _height: number, _depth: number, _format: number, _data: BufferSourceLike): void {}
|
|
1107
|
+
texStorage2D(target: number, levels: number, internalFormat: number, width: number, height: number): void {
|
|
1108
|
+
threeWebGLTexStorage2D(target, levels, internalFormat, width, height)
|
|
1109
|
+
}
|
|
1110
|
+
// Three uploads 3D and array textures only from typed `image.data` /
|
|
1111
|
+
// `mipmap.data` (or `null` to allocate), the same carrier the 2D uploads
|
|
1112
|
+
// take; no TexImageSource ever reaches these entry points.
|
|
1113
|
+
texImage3D(_target: number, _level: number, _internalFormat: number, _width: number, _height: number, _depth: number, _border: number, _format: number, _type: number, _source: BufferSourceLike | null): void {}
|
|
1114
|
+
texSubImage3D(_target: number, _level: number, _xoffset: number, _yoffset: number, _zoffset: number, _width: number, _height: number, _depth: number, _format: number, _type: number, _source: BufferSourceLike): void {}
|
|
1115
|
+
texStorage3D(_target: number, _levels: number, _internalFormat: number, _width: number, _height: number, _depth: number): void {}
|
|
1116
|
+
|
|
1117
|
+
createVertexArray(): NativeHandle { return createHandle('vertexArray', nativeWebGLCreateVertexArray()) }
|
|
1118
|
+
bindVertexArray(vertexArray: NativeHandle | null): void { nativeWebGLBindVertexArray(nullableNativeHandle(vertexArray)) }
|
|
1119
|
+
deleteVertexArray(vertexArray: NativeHandle | null): void { nativeWebGLDeleteVertexArray(nullableNativeHandle(vertexArray)) }
|
|
1120
|
+
|
|
1121
|
+
createFramebuffer(): NativeHandle { return createHandle('framebuffer', nativeWebGLCreateFramebuffer()) }
|
|
1122
|
+
bindFramebuffer(target: number, framebuffer: NativeHandle | null): void { nativeWebGLBindFramebuffer(target, nullableNativeHandle(framebuffer)) }
|
|
1123
|
+
deleteFramebuffer(framebuffer: NativeHandle | null): void { nativeWebGLDeleteFramebuffer(nullableNativeHandle(framebuffer)) }
|
|
1124
|
+
framebufferTexture2D(target: number, attachment: number, textarget: number, texture: NativeHandle | null, level: number): void {
|
|
1125
|
+
nativeWebGLFramebufferTexture2D(target, attachment, textarget, nullableNativeHandle(texture), level)
|
|
1126
|
+
}
|
|
1127
|
+
checkFramebufferStatus(target: number): number { return nativeWebGLCheckFramebufferStatus(target) }
|
|
1128
|
+
createRenderbuffer(): NativeHandle { return createHandle('renderbuffer', nativeWebGLCreateRenderbuffer()) }
|
|
1129
|
+
bindRenderbuffer(target: number, renderbuffer: NativeHandle | null): void { nativeWebGLBindRenderbuffer(target, nullableNativeHandle(renderbuffer)) }
|
|
1130
|
+
deleteRenderbuffer(renderbuffer: NativeHandle | null): void { nativeWebGLDeleteRenderbuffer(nullableNativeHandle(renderbuffer)) }
|
|
1131
|
+
renderbufferStorage(target: number, internalFormat: number, width: number, height: number): void { nativeWebGLRenderbufferStorage(target, internalFormat, width, height) }
|
|
1132
|
+
renderbufferStorageMultisample(target: number, samples: number, internalFormat: number, width: number, height: number): void {
|
|
1133
|
+
this.renderbufferStorage(target, internalFormat, width, height)
|
|
1134
|
+
}
|
|
1135
|
+
framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: NativeHandle | null): void {
|
|
1136
|
+
nativeWebGLFramebufferRenderbuffer(target, attachment, renderbuffertarget, nullableNativeHandle(renderbuffer))
|
|
1137
|
+
}
|
|
1138
|
+
framebufferTextureLayer(_target: number, _attachment: number, _texture: NativeHandle | null, _level: number, _layer: number): void {}
|
|
1139
|
+
drawBuffers(buffers: number[]): void { nativeWebGLDrawBuffers(buffers[0] ?? this.COLOR_ATTACHMENT0) }
|
|
1140
|
+
|
|
1141
|
+
clearColor(r: number, g: number, b: number, a: number): void { nativeWebGLClearColor(r, g, b, a) }
|
|
1142
|
+
clear(mask: number): void { nativeWebGLClear(mask) }
|
|
1143
|
+
clearDepth(depth: number): void { nativeWebGLClearDepth(depth) }
|
|
1144
|
+
clearStencil(stencil: number): void { nativeWebGLClearStencil(stencil) }
|
|
1145
|
+
colorMask(r: boolean, g: boolean, b: boolean, a: boolean): void { nativeWebGLColorMask(r ? 1 : 0, g ? 1 : 0, b ? 1 : 0, a ? 1 : 0) }
|
|
1146
|
+
depthMask(flag: boolean): void { nativeWebGLDepthMask(flag ? 1 : 0) }
|
|
1147
|
+
depthFunc(func: number): void { nativeWebGLDepthFunc(func) }
|
|
1148
|
+
enable(cap: number): void { nativeWebGLEnable(cap) }
|
|
1149
|
+
disable(cap: number): void { nativeWebGLDisable(cap) }
|
|
1150
|
+
isEnabled(_cap: number): boolean { return false }
|
|
1151
|
+
blendFunc(sfactor: number, dfactor: number): void { nativeWebGLBlendFunc(sfactor, dfactor) }
|
|
1152
|
+
blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void { nativeWebGLBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) }
|
|
1153
|
+
blendEquation(mode: number): void { nativeWebGLBlendEquation(mode) }
|
|
1154
|
+
blendEquationSeparate(modeRGB: number, modeAlpha: number): void { nativeWebGLBlendEquationSeparate(modeRGB, modeAlpha) }
|
|
1155
|
+
blendColor(_red: number, _green: number, _blue: number, _alpha: number): void {}
|
|
1156
|
+
cullFace(mode: number): void { nativeWebGLCullFace(mode) }
|
|
1157
|
+
frontFace(mode: number): void { nativeWebGLFrontFace(mode) }
|
|
1158
|
+
viewport(x: number, y: number, width: number, height: number): void { nativeWebGLViewport(x, y, width, height) }
|
|
1159
|
+
scissor(x: number, y: number, width: number, height: number): void { nativeWebGLScissor(x, y, width, height) }
|
|
1160
|
+
lineWidth(width: number): void { nativeWebGLLineWidth(width) }
|
|
1161
|
+
polygonOffset(factor: number, units: number): void { nativeWebGLPolygonOffset(factor, units) }
|
|
1162
|
+
stencilMask(mask: number): void { nativeWebGLStencilMask(mask) }
|
|
1163
|
+
stencilMaskSeparate(face: number, mask: number): void { nativeWebGLStencilMaskSeparate(face, mask) }
|
|
1164
|
+
stencilFunc(func: number, ref: number, mask: number): void { nativeWebGLStencilFunc(func, ref, mask) }
|
|
1165
|
+
stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void { nativeWebGLStencilFuncSeparate(face, func, ref, mask) }
|
|
1166
|
+
stencilOp(fail: number, zfail: number, zpass: number): void { nativeWebGLStencilOp(fail, zfail, zpass) }
|
|
1167
|
+
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void { nativeWebGLStencilOpSeparate(face, fail, zfail, zpass) }
|
|
1168
|
+
|
|
1169
|
+
drawElements(mode: number, count: number, type: number, offset: number): void { nativeWebGLDrawElements(mode, count, type, offset) }
|
|
1170
|
+
drawArrays(mode: number, first: number, count: number): void { nativeWebGLDrawArrays(mode, first, count) }
|
|
1171
|
+
drawElementsInstanced(mode: number, count: number, type: number, offset: number, instanceCount: number): void { nativeWebGLDrawElementsInstanced(mode, count, type, offset, instanceCount) }
|
|
1172
|
+
drawArraysInstanced(mode: number, first: number, count: number, instanceCount: number): void { nativeWebGLDrawArraysInstanced(mode, first, count, instanceCount) }
|
|
1173
|
+
|
|
1174
|
+
getError(): number { return nativeWebGLGetError() }
|
|
1175
|
+
finish(): void {}
|
|
1176
|
+
flush(): void {}
|
|
1177
|
+
hint(_target: number, _mode: number): void {}
|
|
1178
|
+
invalidateFramebuffer(_target: number, _attachments: BufferSourceLike): void {}
|
|
1179
|
+
blitFramebuffer(_srcX0: number, _srcY0: number, _srcX1: number, _srcY1: number, _dstX0: number, _dstY0: number, _dstX1: number, _dstY1: number, _mask: number, _filter: number): void {}
|
|
1180
|
+
readBuffer(_src: number): void {}
|
|
1181
|
+
readPixels(_x: number, _y: number, _width: number, _height: number, _format: number, _type: number, _destination: unknown): void {}
|
|
1182
|
+
copyTexImage2D(_target: number, _level: number, _internalFormat: number, _x: number, _y: number, _width: number, _height: number, _border: number): void {}
|
|
1183
|
+
copyTexSubImage2D(_target: number, _level: number, _xoffset: number, _yoffset: number, _x: number, _y: number, _width: number, _height: number): void {}
|
|
1184
|
+
copyTexSubImage3D(_target: number, _level: number, _xoffset: number, _yoffset: number, _zoffset: number, _x: number, _y: number, _width: number, _height: number): void {}
|
|
1185
|
+
clearBufferiv(_buffer: number, _drawbuffer: number, _values: BufferSourceLike): void {}
|
|
1186
|
+
clearBufferuiv(_buffer: number, _drawbuffer: number, _values: BufferSourceLike): void {}
|
|
1187
|
+
getBufferParameter(_target: number, _pname: number): number { return 0 }
|
|
1188
|
+
getBufferSubData(_target: number, _srcByteOffset: number, _destination: unknown): void {}
|
|
1189
|
+
getFramebufferAttachmentParameter(_target: number, _attachment: number, _pname: number): number { return 0 }
|
|
1190
|
+
getRenderbufferParameter(_target: number, _pname: number): number { return 0 }
|
|
1191
|
+
getTexParameter(_target: number, _pname: number): number { return 0 }
|
|
1192
|
+
getVertexAttrib(_index: number, _pname: number): number { return 0 }
|
|
1193
|
+
getVertexAttribOffset(_index: number, _pname: number): number { return 0 }
|
|
1194
|
+
getUniform(_program: NativeProgram | null, _location: NativeHandle | null): number { return 0 }
|
|
1195
|
+
getUniformBlockIndex(_program: NativeProgram | null, _uniformBlockName: string): number { return 0 }
|
|
1196
|
+
uniformBlockBinding(_program: NativeProgram | null, _uniformBlockIndex: number, _uniformBlockBinding: number): void {}
|
|
1197
|
+
bindBufferBase(_target: number, _index: number, _buffer: NativeHandle | null): void {}
|
|
1198
|
+
bindBufferRange(_target: number, _index: number, _buffer: NativeHandle | null, _offset: number, _size: number): void {}
|
|
1199
|
+
fenceSync(_condition: number, _flags: number): null { return null }
|
|
1200
|
+
clientWaitSync(_sync: NativeHandle | null, _flags: number, _timeout: number): number { return 0 }
|
|
1201
|
+
deleteSync(_sync: NativeHandle | null): void {}
|
|
1202
|
+
isBuffer(_buffer: NativeHandle | null): boolean { return true }
|
|
1203
|
+
isFramebuffer(_framebuffer: NativeHandle | null): boolean { return true }
|
|
1204
|
+
isProgram(_program: NativeProgram | null): boolean { return true }
|
|
1205
|
+
isRenderbuffer(_renderbuffer: NativeHandle | null): boolean { return true }
|
|
1206
|
+
isShader(_shader: NativeHandle | null): boolean { return true }
|
|
1207
|
+
isTexture(_texture: NativeHandle | null): boolean { return true }
|
|
1208
|
+
isVertexArray(_vertexArray: NativeHandle | null): boolean { return true }
|
|
1209
|
+
swapNativeBuffers(): void { nativeWebGLSwap() }
|
|
1210
|
+
logMissing(method: string): void { logNativeWebGL('missing WebGL method: ' + method) }
|
|
1211
|
+
}
|