@luma.gl/webgl 9.0.0-alpha.4 → 9.0.0-alpha.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/dist/adapter/converters/device-parameters.d.ts +11 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +15 -2
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +4 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +22 -3
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.js +3 -3
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +12 -2
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +40 -16
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +1 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -2
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +5 -3
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +2 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +40 -24
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +2 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +4 -3
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +22 -22
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +21 -18
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/classic/buffer.js +14 -6
- package/dist/classic/buffer.js.map +1 -1
- package/dist/context/context/create-context.d.ts.map +1 -1
- package/dist/context/context/create-context.js +8 -2
- package/dist/context/context/create-context.js.map +1 -1
- package/dist/context/context/device-pixels.d.ts.map +1 -1
- package/dist/context/context/device-pixels.js +13 -8
- package/dist/context/context/device-pixels.js.map +1 -1
- package/dist/context/debug/spector.js +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +5 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +1 -3
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/adapter/converters/device-parameters.js +17 -2
- package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/sampler-parameters.js +22 -3
- package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/texture-formats.js +3 -3
- package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-features.js +15 -4
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/es5/adapter/helpers/get-shader-layout.js +48 -28
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/es5/adapter/helpers/uniforms.js +4 -4
- package/dist/es5/adapter/helpers/uniforms.js.map +1 -1
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +2 -2
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +4 -3
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pass.js +1 -0
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +43 -30
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-shader.js +4 -3
- package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-texture.js +54 -54
- package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/es5/adapter/webgl-canvas-context.js +1 -1
- package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/es5/classic/buffer.js +14 -6
- package/dist/es5/classic/buffer.js.map +1 -1
- package/dist/es5/context/context/create-context.js +8 -2
- package/dist/es5/context/context/create-context.js.map +1 -1
- package/dist/es5/context/context/device-pixels.js +14 -8
- package/dist/es5/context/context/device-pixels.js.map +1 -1
- package/dist/es5/context/debug/spector.js +1 -1
- package/dist/es5/context/debug/spector.js.map +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/es5/context/parameters/unified-parameter-api.js +2 -2
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js +13 -13
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/index.js +22 -16
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/types/webgl.js.map +1 -1
- package/dist/esm/adapter/converters/device-parameters.js +15 -2
- package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
- package/dist/esm/adapter/converters/sampler-parameters.js +22 -3
- package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/esm/adapter/converters/texture-formats.js +3 -3
- package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-features.js +12 -2
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/esm/adapter/helpers/get-shader-layout.js +40 -16
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/esm/adapter/helpers/uniforms.js +4 -4
- package/dist/esm/adapter/helpers/uniforms.js.map +1 -1
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +2 -2
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +5 -3
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pass.js +2 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +40 -24
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-shader.js +4 -3
- package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-texture.js +21 -18
- package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/esm/adapter/webgl-canvas-context.js +1 -1
- package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/esm/classic/buffer.js +14 -6
- package/dist/esm/classic/buffer.js.map +1 -1
- package/dist/esm/context/context/create-context.js +8 -2
- package/dist/esm/context/context/create-context.js.map +1 -1
- package/dist/esm/context/context/device-pixels.js +13 -8
- package/dist/esm/context/context/device-pixels.js.map +1 -1
- package/dist/esm/context/debug/spector.js +1 -1
- package/dist/esm/context/debug/spector.js.map +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/esm/context/parameters/unified-parameter-api.js +1 -3
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/webgl.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/webgl.d.ts +3 -2
- package/dist/types/webgl.d.ts.map +1 -1
- package/dist/types/webgl.js.map +1 -1
- package/package.json +7 -4
- package/src/adapter/converters/device-parameters.ts +30 -4
- package/src/adapter/converters/sampler-parameters.ts +17 -8
- package/src/adapter/converters/texture-formats.ts +3 -3
- package/src/adapter/device-helpers/device-features.ts +9 -1
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/helpers/get-shader-layout.ts +40 -21
- package/src/adapter/helpers/uniforms.ts +21 -10
- package/src/adapter/objects/webgl-vertex-array-object.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +6 -3
- package/src/adapter/resources/webgl-render-pass.ts +1 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +43 -35
- package/src/adapter/resources/webgl-sampler.ts +5 -3
- package/src/adapter/resources/webgl-shader.ts +5 -4
- package/src/adapter/resources/webgl-texture.ts +39 -26
- package/src/adapter/webgl-canvas-context.ts +1 -1
- package/src/classic/buffer.ts +7 -7
- package/src/context/context/create-context.ts +9 -5
- package/src/context/context/device-pixels.ts +15 -9
- package/src/context/debug/spector.ts +1 -1
- package/src/context/debug/webgl-developer-tools.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +12 -9
- package/src/context/polyfill/polyfill-context.ts +1 -1
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/context/state-tracker/track-context-state.ts +8 -7
- package/src/index.ts +11 -5
- package/src/types/webgl.ts +3 -2
|
@@ -15,7 +15,7 @@ export default class WEBGLBuffer extends Buffer {
|
|
|
15
15
|
|
|
16
16
|
byteLength: number;
|
|
17
17
|
bytesUsed: number;
|
|
18
|
-
debugData: ArrayBuffer;
|
|
18
|
+
debugData: ArrayBuffer | null = null;
|
|
19
19
|
|
|
20
20
|
webglUsage: number;
|
|
21
21
|
|
|
@@ -106,8 +106,8 @@ export default class WEBGLBuffer extends Buffer {
|
|
|
106
106
|
this.removeStats();
|
|
107
107
|
this.trackDeallocatedMemory();
|
|
108
108
|
this.gl.deleteBuffer(this.handle);
|
|
109
|
-
//
|
|
110
|
-
this.
|
|
109
|
+
// this.handle = null;
|
|
110
|
+
this.destroyed = true;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import type {FramebufferProps, DepthStencilTextureFormat, ColorTextureFormat} from '@luma.gl/api';
|
|
2
4
|
import {Framebuffer, Texture, log, assert} from '@luma.gl/api';
|
|
3
5
|
import GL from '@luma.gl/constants';
|
|
@@ -17,7 +19,7 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
17
19
|
|
|
18
20
|
get texture() { return this.colorAttachments[0]; }
|
|
19
21
|
readonly colorAttachments: WebGLTexture[] = [];
|
|
20
|
-
readonly depthStencilAttachment: WebGLTexture |
|
|
22
|
+
readonly depthStencilAttachment: WebGLTexture | null = null; d
|
|
21
23
|
protected _ownResources: (WebGLTexture | Renderbuffer)[] = [];
|
|
22
24
|
|
|
23
25
|
constructor(device: WebGLDevice, props: FramebufferProps) {
|
|
@@ -66,7 +68,8 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
66
68
|
resource.destroy();
|
|
67
69
|
}
|
|
68
70
|
this.gl.deleteFramebuffer(this.handle);
|
|
69
|
-
this.handle = null;
|
|
71
|
+
// this.handle = null;
|
|
72
|
+
this.destroyed = true;
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -224,7 +227,7 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
224
227
|
case GL.TEXTURE_2D_ARRAY:
|
|
225
228
|
case GL.TEXTURE_3D:
|
|
226
229
|
this.device.assertWebGL2();
|
|
227
|
-
gl2
|
|
230
|
+
gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
228
231
|
break;
|
|
229
232
|
|
|
230
233
|
case GL.TEXTURE_CUBE_MAP:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
RenderPipelineProps,
|
|
3
|
-
RenderPipelineParameters,
|
|
4
3
|
RenderPass,
|
|
5
4
|
Buffer,
|
|
6
5
|
Binding,
|
|
@@ -11,9 +10,11 @@ import type {
|
|
|
11
10
|
} from '@luma.gl/api';
|
|
12
11
|
import {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';
|
|
13
12
|
import GL from '@luma.gl/constants';
|
|
13
|
+
|
|
14
|
+
import type {GLParameters} from '../../types/webgl';
|
|
14
15
|
import {getWebGLDataType} from '../converters/texture-formats';
|
|
15
16
|
import {getShaderLayout} from '../helpers/get-shader-layout';
|
|
16
|
-
import {withDeviceParameters} from '../converters/device-parameters';
|
|
17
|
+
import {withDeviceParameters, withGLParameters} from '../converters/device-parameters';
|
|
17
18
|
import {setUniform} from '../helpers/set-uniform';
|
|
18
19
|
// import {copyUniform, checkUniformValues} from '../../classes/uniforms';
|
|
19
20
|
|
|
@@ -35,7 +36,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
35
36
|
|
|
36
37
|
// configuration: ProgramConfiguration;
|
|
37
38
|
// Experimental flag to avoid deleting Program object while it is cached
|
|
38
|
-
varyings: string[];
|
|
39
|
+
varyings: string[] | null = null;
|
|
39
40
|
vertexArrayObject: WEBGLVertexArrayObject;
|
|
40
41
|
_indexBuffer?: Buffer;
|
|
41
42
|
uniforms: Record<string, any> = {};
|
|
@@ -43,7 +44,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
43
44
|
_textureUniforms: Record<string, any> = {};
|
|
44
45
|
_textureIndexCounter: number = 0;
|
|
45
46
|
_uniformCount: number = 0;
|
|
46
|
-
_uniformSetters: Record<string, Function
|
|
47
|
+
_uniformSetters: Record<string, Function> = {}; // TODO are these used?
|
|
47
48
|
|
|
48
49
|
constructor(device: WebGLDevice, props: RenderPipelineProps) {
|
|
49
50
|
super(device, props);
|
|
@@ -64,7 +65,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
64
65
|
if (varyings && varyings.length > 0) {
|
|
65
66
|
this.device.assertWebGL2();
|
|
66
67
|
this.varyings = varyings;
|
|
67
|
-
this.device.gl2
|
|
68
|
+
this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
this._compileAndLink();
|
|
@@ -76,7 +77,8 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
76
77
|
destroy(): void {
|
|
77
78
|
if (this.handle) {
|
|
78
79
|
this.device.gl.deleteProgram(this.handle);
|
|
79
|
-
this.handle = null;
|
|
80
|
+
// this.handle = null;
|
|
81
|
+
this.destroyed = true;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -121,6 +123,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
121
123
|
const binding = this.layout.bindings.find((binding) => binding.name === name);
|
|
122
124
|
if (!binding) {
|
|
123
125
|
log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();
|
|
126
|
+
continue;
|
|
124
127
|
}
|
|
125
128
|
if (!value) {
|
|
126
129
|
log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();
|
|
@@ -181,7 +184,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
181
184
|
const drawMode = getDrawMode(this.props.topology);
|
|
182
185
|
const isIndexed: boolean = Boolean(this._indexBuffer);
|
|
183
186
|
const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;
|
|
184
|
-
const isInstanced: boolean = options.instanceCount > 0;
|
|
187
|
+
const isInstanced: boolean = Number(options.instanceCount) > 0;
|
|
185
188
|
|
|
186
189
|
// Avoid WebGL draw call when not rendering any data or values are incomplete
|
|
187
190
|
// Note: async textures set as uniforms might still be loading.
|
|
@@ -195,8 +198,6 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
195
198
|
this.device.gl.useProgram(this.handle);
|
|
196
199
|
|
|
197
200
|
this.vertexArrayObject.bind(() => {
|
|
198
|
-
const parameters = {...this.props.parameters, framebuffer: renderPass.props.framebuffer};
|
|
199
|
-
|
|
200
201
|
const primitiveMode = getGLPrimitive(this.props.topology);
|
|
201
202
|
const transformFeedback: any = null;
|
|
202
203
|
if (transformFeedback) {
|
|
@@ -208,31 +209,33 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
208
209
|
this._applyUniforms();
|
|
209
210
|
|
|
210
211
|
// TODO - double context push/pop
|
|
211
|
-
withDeviceParameters(this.device, parameters, () => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
212
|
+
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
213
|
+
withGLParameters(this.device, {framebuffer: renderPass.props.framebuffer}, () => {
|
|
214
|
+
// TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension
|
|
215
|
+
if (isIndexed && isInstanced) {
|
|
216
|
+
// ANGLE_instanced_arrays extension
|
|
217
|
+
this.device.gl2?.drawElementsInstanced(
|
|
218
|
+
drawMode,
|
|
219
|
+
vertexCount || 0, // indexCount?
|
|
220
|
+
indexType,
|
|
221
|
+
firstVertex,
|
|
222
|
+
instanceCount || 0
|
|
223
|
+
);
|
|
224
|
+
// } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
|
|
225
|
+
// this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);
|
|
226
|
+
} else if (isIndexed) {
|
|
227
|
+
this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?
|
|
228
|
+
} else if (isInstanced) {
|
|
229
|
+
this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);
|
|
230
|
+
} else {
|
|
231
|
+
this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (transformFeedback) {
|
|
236
|
+
transformFeedback.end();
|
|
230
237
|
}
|
|
231
238
|
});
|
|
232
|
-
|
|
233
|
-
if (transformFeedback) {
|
|
234
|
-
transformFeedback.end();
|
|
235
|
-
}
|
|
236
239
|
});
|
|
237
240
|
|
|
238
241
|
return true;
|
|
@@ -295,6 +298,9 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
295
298
|
this.device.gl.useProgram(this.handle);
|
|
296
299
|
|
|
297
300
|
const {gl2} = this.device;
|
|
301
|
+
if (!gl2) {
|
|
302
|
+
throw new Error('bindings');
|
|
303
|
+
}
|
|
298
304
|
|
|
299
305
|
let textureUnit = 0;
|
|
300
306
|
let uniformBufferIndex = 0;
|
|
@@ -395,13 +401,15 @@ function getAttributesByLocation(
|
|
|
395
401
|
const byLocation: Record<number, Buffer> = {};
|
|
396
402
|
for (const [name, buffer] of Object.entries(attributes)) {
|
|
397
403
|
const attribute = getAttributeLayout(layout, name);
|
|
398
|
-
|
|
404
|
+
if (attribute) {
|
|
405
|
+
byLocation[attribute.location] = buffer;
|
|
406
|
+
}
|
|
399
407
|
}
|
|
400
408
|
return byLocation;
|
|
401
409
|
}
|
|
402
410
|
|
|
403
|
-
function getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout |
|
|
404
|
-
return layout.attributes.find((binding) => binding.name === name);
|
|
411
|
+
function getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {
|
|
412
|
+
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
405
413
|
}
|
|
406
414
|
|
|
407
415
|
function getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import {Sampler, SamplerProps} from '@luma.gl/api';
|
|
2
4
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import type {
|
|
5
|
+
import type {GLSamplerParameters} from '../../types/webgl';
|
|
4
6
|
import {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';
|
|
5
7
|
import type WebGLDevice from '../webgl-device';
|
|
6
8
|
|
|
@@ -14,7 +16,7 @@ import type WebGLDevice from '../webgl-device';
|
|
|
14
16
|
export default class WEBGLSampler extends Sampler {
|
|
15
17
|
readonly device: WebGLDevice;
|
|
16
18
|
readonly handle: WebGLSampler;
|
|
17
|
-
readonly parameters:
|
|
19
|
+
readonly parameters: GLSamplerParameters;
|
|
18
20
|
|
|
19
21
|
constructor(device: WebGLDevice, props: SamplerProps) {
|
|
20
22
|
super(device, props);
|
|
@@ -35,7 +37,7 @@ export default class WEBGLSampler extends Sampler {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** Set sampler parameters on the sampler */
|
|
38
|
-
private _setSamplerParameters(parameters:
|
|
40
|
+
private _setSamplerParameters(parameters: GLSamplerParameters): void {
|
|
39
41
|
for (const [pname, value] of Object.entries(parameters)) {
|
|
40
42
|
// Apparently there are integer/float conversion issues requires two parameter setting functions in JavaScript.
|
|
41
43
|
// For now, pick the float version for parameters specified as GLfloat.
|
|
@@ -32,14 +32,14 @@ import WebGLDevice from '../webgl-device';
|
|
|
32
32
|
if (this.handle) {
|
|
33
33
|
this.removeStats();
|
|
34
34
|
this.device.gl.deleteShader(this.handle);
|
|
35
|
-
//
|
|
36
|
-
this.
|
|
35
|
+
// this.handle = null;
|
|
36
|
+
this.destroyed = true;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async compilationInfo(): Promise<readonly CompilerMessage[]> {
|
|
41
41
|
const log = this.device.gl.getShaderInfoLog(this.handle);
|
|
42
|
-
return parseShaderCompilerLog(log);
|
|
42
|
+
return log ? parseShaderCompilerLog(log) : [];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// PRIVATE METHODS
|
|
@@ -58,7 +58,8 @@ import WebGLDevice from '../webgl-device';
|
|
|
58
58
|
const compileStatus = gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
|
|
59
59
|
if (!compileStatus) {
|
|
60
60
|
const shaderLog = gl.getShaderInfoLog(this.handle);
|
|
61
|
-
const
|
|
61
|
+
const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
62
|
+
const messages = parsedLog.filter(message => message.type === 'error');
|
|
62
63
|
const formattedLog = formatCompilerLog(messages, source);
|
|
63
64
|
const shaderName: string = getShaderInfo(source).name;
|
|
64
65
|
const shaderDescription = `${this.stage} shader ${shaderName}`;
|
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
Sampler,
|
|
11
11
|
SamplerProps,
|
|
12
12
|
SamplerParameters,
|
|
13
|
+
TypedArray,
|
|
13
14
|
isObjectEmpty
|
|
14
15
|
} from '@luma.gl/api';
|
|
15
16
|
import {Texture, cast, log, assert, isPowerOfTwo, loadImage} from '@luma.gl/api';
|
|
16
17
|
import GL from '@luma.gl/constants';
|
|
17
|
-
import type {
|
|
18
|
+
import type {GLSamplerParameters} from '../../types/webgl';
|
|
18
19
|
import {withParameters} from '../../context/state-tracker/with-parameters';
|
|
19
20
|
import {
|
|
20
21
|
getWebGLTextureFormat,
|
|
@@ -31,22 +32,31 @@ import WEBGLSampler from './webgl-sampler';
|
|
|
31
32
|
|
|
32
33
|
export type {TextureProps};
|
|
33
34
|
|
|
35
|
+
export type TextureSourceData =
|
|
36
|
+
TypedArray |
|
|
37
|
+
ImageData |
|
|
38
|
+
HTMLImageElement |
|
|
39
|
+
HTMLCanvasElement |
|
|
40
|
+
ImageBitmap |
|
|
41
|
+
HTMLVideoElement
|
|
42
|
+
;
|
|
43
|
+
|
|
34
44
|
type SetImageDataOptions = {
|
|
35
45
|
target?: number;
|
|
36
46
|
level?: number;
|
|
37
47
|
dataFormat?: any;
|
|
38
|
-
width
|
|
39
|
-
height
|
|
48
|
+
width?: number;
|
|
49
|
+
height?: number;
|
|
40
50
|
depth?: number;
|
|
41
|
-
format
|
|
51
|
+
format?: any;
|
|
42
52
|
type?: any;
|
|
43
53
|
offset?: number;
|
|
44
|
-
data: any;
|
|
54
|
+
data: any; // TextureSourceData;
|
|
45
55
|
compressed?: boolean;
|
|
46
56
|
parameters?: Record<GL, any>;
|
|
47
57
|
/** @deprecated */
|
|
48
58
|
pixels?: any;
|
|
49
|
-
}
|
|
59
|
+
}
|
|
50
60
|
|
|
51
61
|
/**
|
|
52
62
|
* @param {*} pixels, data -
|
|
@@ -92,10 +102,10 @@ type SetSubImageDataOptions = {
|
|
|
92
102
|
type SetImageData3DOptions = {
|
|
93
103
|
level?: number;
|
|
94
104
|
dataFormat?: any;
|
|
95
|
-
width
|
|
96
|
-
height
|
|
105
|
+
width?: number;
|
|
106
|
+
height?: number;
|
|
97
107
|
depth?: number;
|
|
98
|
-
format
|
|
108
|
+
format?: any;
|
|
99
109
|
type?: any;
|
|
100
110
|
offset?: number;
|
|
101
111
|
data: any;
|
|
@@ -189,8 +199,8 @@ export default class WEBGLTexture extends Texture {
|
|
|
189
199
|
this.gl.deleteTexture(this.handle);
|
|
190
200
|
this.removeStats();
|
|
191
201
|
this.trackDeallocatedMemory('Texture');
|
|
192
|
-
//
|
|
193
|
-
this.
|
|
202
|
+
// this.handle = null;
|
|
203
|
+
this.destroyed = true;
|
|
194
204
|
}
|
|
195
205
|
}
|
|
196
206
|
|
|
@@ -357,7 +367,8 @@ export default class WEBGLTexture extends Texture {
|
|
|
357
367
|
* If size has changed, reinitializes with current format
|
|
358
368
|
* @note note clears image and mipmaps
|
|
359
369
|
*/
|
|
360
|
-
resize({height, width, mipmaps
|
|
370
|
+
resize(options: {height: number, width: number, mipmaps?: boolean}): this {
|
|
371
|
+
const {height, width, mipmaps = false} = options;
|
|
361
372
|
if (width !== this.width || height !== this.height) {
|
|
362
373
|
return this.initialize({
|
|
363
374
|
width,
|
|
@@ -713,7 +724,7 @@ export default class WEBGLTexture extends Texture {
|
|
|
713
724
|
|
|
714
725
|
// HELPER METHODS
|
|
715
726
|
|
|
716
|
-
_deduceParameters(opts) {
|
|
727
|
+
_deduceParameters(opts: TextureProps) {
|
|
717
728
|
const {format, data} = opts;
|
|
718
729
|
let {width, height, dataFormat, type, compressed} = opts;
|
|
719
730
|
|
|
@@ -856,18 +867,20 @@ export default class WEBGLTexture extends Texture {
|
|
|
856
867
|
}
|
|
857
868
|
|
|
858
869
|
/** Image 3D copies from Typed Array or WebGLBuffer */
|
|
859
|
-
setImageData3D({
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
870
|
+
setImageData3D(options: SetImageData3DOptions) {
|
|
871
|
+
const {
|
|
872
|
+
level = 0,
|
|
873
|
+
dataFormat,
|
|
874
|
+
format,
|
|
875
|
+
type, // = GL.UNSIGNED_BYTE,
|
|
876
|
+
width,
|
|
877
|
+
height,
|
|
878
|
+
depth = 1,
|
|
879
|
+
offset = 0,
|
|
880
|
+
data,
|
|
881
|
+
parameters = {}
|
|
882
|
+
} = options;
|
|
883
|
+
|
|
871
884
|
this.trackDeallocatedMemory('Texture');
|
|
872
885
|
|
|
873
886
|
this.gl.bindTexture(this.target, this.handle);
|
|
@@ -927,7 +940,7 @@ export default class WEBGLTexture extends Texture {
|
|
|
927
940
|
* Sets sampler parameters on texture
|
|
928
941
|
* @note: Applies NPOT workaround if appropriate
|
|
929
942
|
*/
|
|
930
|
-
_setSamplerParameters(parameters:
|
|
943
|
+
_setSamplerParameters(parameters: GLSamplerParameters) {
|
|
931
944
|
// Work around WebGL1 sampling restrictions on NPOT textures
|
|
932
945
|
if (this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
933
946
|
parameters = updateSamplerParametersForNPOT(parameters);
|
|
@@ -12,7 +12,7 @@ import WEBGLFramebuffer from './resources/webgl-framebuffer';
|
|
|
12
12
|
export default class WebGLCanvasContext extends CanvasContext {
|
|
13
13
|
readonly device: WebGLDevice;
|
|
14
14
|
presentationSize: [number, number];
|
|
15
|
-
private _framebuffer: WEBGLFramebuffer;
|
|
15
|
+
private _framebuffer: WEBGLFramebuffer | null = null;
|
|
16
16
|
|
|
17
17
|
constructor(device: WebGLDevice, props: CanvasContextProps) {
|
|
18
18
|
// Note: Base class creates / looks up the canvas (unless under Node.js)
|
package/src/classic/buffer.ts
CHANGED
|
@@ -111,8 +111,8 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
111
111
|
this.removeStats();
|
|
112
112
|
this.trackDeallocatedMemory();
|
|
113
113
|
this.gl.deleteBuffer(this.handle);
|
|
114
|
-
//
|
|
115
|
-
this.
|
|
114
|
+
// this.handle = null;
|
|
115
|
+
this.destroyed = true;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -264,7 +264,7 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
264
264
|
// Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
|
|
265
265
|
gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);
|
|
266
266
|
gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);
|
|
267
|
-
gl2
|
|
267
|
+
gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
|
|
268
268
|
gl.bindBuffer(GL.COPY_READ_BUFFER, null);
|
|
269
269
|
gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);
|
|
270
270
|
|
|
@@ -314,7 +314,7 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
314
314
|
|
|
315
315
|
// Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type
|
|
316
316
|
this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);
|
|
317
|
-
this.gl2
|
|
317
|
+
this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
|
|
318
318
|
this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
|
|
319
319
|
|
|
320
320
|
// TODO - update local `data` if offsets are 0
|
|
@@ -340,10 +340,10 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
340
340
|
// uniform buffer state. Instead indexed bindings need to be made.
|
|
341
341
|
if (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {
|
|
342
342
|
if (size !== undefined) {
|
|
343
|
-
this.gl2
|
|
343
|
+
this.gl2?.bindBufferRange(target, index, this.handle, offset, size);
|
|
344
344
|
} else {
|
|
345
345
|
assert(offset === 0); // Make sure offset wasn't supplied
|
|
346
|
-
this.gl2
|
|
346
|
+
this.gl2?.bindBufferBase(target, index, this.handle);
|
|
347
347
|
}
|
|
348
348
|
} else {
|
|
349
349
|
this.gl.bindBuffer(target, this.handle);
|
|
@@ -356,7 +356,7 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
356
356
|
const {target = this.target, index = this.accessor && this.accessor.index} = options || {};
|
|
357
357
|
const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;
|
|
358
358
|
if (isIndexedBuffer) {
|
|
359
|
-
this.gl2
|
|
359
|
+
this.gl2?.bindBufferBase(target, index, null);
|
|
360
360
|
} else {
|
|
361
361
|
this.gl.bindBuffer(target, null);
|
|
362
362
|
}
|
|
@@ -55,7 +55,7 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
55
55
|
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
56
56
|
|
|
57
57
|
// Create the desired context
|
|
58
|
-
let gl = null;
|
|
58
|
+
let gl: WebGLRenderingContext | null = null;
|
|
59
59
|
|
|
60
60
|
if (props.type === 'webgl2') {
|
|
61
61
|
props = {...props, webgl1: false};
|
|
@@ -66,10 +66,10 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
66
66
|
|
|
67
67
|
// Prefer webgl2 over webgl1 if both are acceptable
|
|
68
68
|
if (props.webgl2) {
|
|
69
|
-
gl = gl || canvas.getContext('webgl2', props);
|
|
69
|
+
gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;
|
|
70
70
|
}
|
|
71
71
|
if (props.webgl1) {
|
|
72
|
-
gl = gl || canvas.getContext('webgl', props);
|
|
72
|
+
gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// TODO are we removing this listener before giving it a chance to fire?
|
|
@@ -83,8 +83,12 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
if (props.onContextLost) {
|
|
87
|
+
canvas.addEventListener('webglcontextlost', props.onContextLost, false);
|
|
88
|
+
}
|
|
89
|
+
if (props.onContextRestored) {
|
|
90
|
+
canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);
|
|
91
|
+
}
|
|
88
92
|
|
|
89
93
|
return gl;
|
|
90
94
|
}
|
|
@@ -53,16 +53,22 @@ export function cssToDeviceRatio(gl: WebGLRenderingContext): number {
|
|
|
53
53
|
|
|
54
54
|
// use devicePixelRatio to set canvas width and height
|
|
55
55
|
export function setDevicePixelRatio(gl: WebGLRenderingContext, devicePixelRatio: number, options: {width?: number, height?: number} = {}) {
|
|
56
|
+
if (!(gl.canvas instanceof HTMLCanvasElement)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const canvas: HTMLCanvasElement = gl.canvas;
|
|
61
|
+
|
|
56
62
|
// NOTE: if options.width and options.height not used remove in v8
|
|
57
|
-
let clientWidth = 'width' in options ? options.width :
|
|
58
|
-
let clientHeight = 'height' in options ? options.height :
|
|
63
|
+
let clientWidth = 'width' in options ? options.width : canvas.clientWidth;
|
|
64
|
+
let clientHeight = 'height' in options ? options.height : canvas.clientHeight;
|
|
59
65
|
|
|
60
66
|
if (!clientWidth || !clientHeight) {
|
|
61
67
|
log.log(1, 'Canvas clientWidth/clientHeight is 0')();
|
|
62
|
-
// by forcing devicePixel ratio to 1, we do not scale
|
|
68
|
+
// by forcing devicePixel ratio to 1, we do not scale canvas.width and height in each frame.
|
|
63
69
|
devicePixelRatio = 1;
|
|
64
|
-
clientWidth =
|
|
65
|
-
clientHeight =
|
|
70
|
+
clientWidth = canvas.width || 1;
|
|
71
|
+
clientHeight = canvas.height || 1;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
const contextState = getContextState(gl);
|
|
@@ -77,8 +83,8 @@ export function setDevicePixelRatio(gl: WebGLRenderingContext, devicePixelRatio:
|
|
|
77
83
|
|
|
78
84
|
const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
|
|
79
85
|
const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
canvas.width = canvasWidth;
|
|
87
|
+
canvas.height = canvasHeight;
|
|
82
88
|
|
|
83
89
|
// Note: when devicePixelRatio is too high, it is possible we might hit system limit for
|
|
84
90
|
// drawing buffer width and hight, in those cases they get clamped and resulting aspect ration may not be maintained
|
|
@@ -90,8 +96,8 @@ export function setDevicePixelRatio(gl: WebGLRenderingContext, devicePixelRatio:
|
|
|
90
96
|
gl.drawingBufferHeight / clientHeight
|
|
91
97
|
);
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
canvas.width = Math.floor(clientWidth * clampedPixelRatio);
|
|
100
|
+
canvas.height = Math.floor(clientHeight * clampedPixelRatio);
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
Object.assign(contextState._canvasSizeInfo, {clientWidth, clientHeight, devicePixelRatio});
|
|
@@ -21,7 +21,10 @@ export type {GLParameters};
|
|
|
21
21
|
* @note requires a `cache` object to be set on the context (gl.state.cache)
|
|
22
22
|
* This object is used to fill in any missing values for composite setter functions
|
|
23
23
|
*/
|
|
24
|
-
export function setParameters(
|
|
24
|
+
export function setParameters(
|
|
25
|
+
device: Device | WebGLRenderingContext,
|
|
26
|
+
parameters: GLParameters
|
|
27
|
+
): void {
|
|
25
28
|
const webglDevice = WebGLDevice.attach(device);
|
|
26
29
|
const gl = webglDevice.gl;
|
|
27
30
|
|
|
@@ -74,7 +77,10 @@ export function setParameters(device: Device | WebGLRenderingContext, parameters
|
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* Reads the entire WebGL state from a context
|
|
77
|
-
|
|
80
|
+
|
|
81
|
+
// default to querying all parameters
|
|
82
|
+
|
|
83
|
+
* @returns - a newly created map, with values keyed by GL parameters
|
|
78
84
|
*
|
|
79
85
|
* @note Copies the state from a context (gl.getParameter should not be overriden)
|
|
80
86
|
* Reads the entire WebGL state from a context
|
|
@@ -83,13 +89,10 @@ export function setParameters(device: Device | WebGLRenderingContext, parameters
|
|
|
83
89
|
* considered a very slow operation, to be used only if/when a context already manipulated
|
|
84
90
|
* by external code needs to be synchronized for the first time
|
|
85
91
|
*/
|
|
86
|
-
export function getParameters(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export function getParameters(gl, parameters) {
|
|
91
|
-
// default to querying all parameters
|
|
92
|
-
parameters = parameters || GL_PARAMETER_DEFAULTS;
|
|
92
|
+
export function getParameters(
|
|
93
|
+
gl: WebGLRenderingContext,
|
|
94
|
+
parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS
|
|
95
|
+
): GLParameters {
|
|
93
96
|
// support both arrays of parameters and objects (keys represent parameters)
|
|
94
97
|
|
|
95
98
|
if (typeof parameters === 'number') {
|
|
@@ -65,7 +65,7 @@ function polyfillExtension(gl: WebGLRenderingContext, {extension, target, target
|
|
|
65
65
|
for (const key of Object.keys(defaults)) {
|
|
66
66
|
const extKey = `${key}${suffix}`;
|
|
67
67
|
|
|
68
|
-
let polyfill = null;
|
|
68
|
+
let polyfill: Function | null = null;
|
|
69
69
|
if (key === 'meta') {
|
|
70
70
|
// ignore
|
|
71
71
|
} else if (typeof gl[key] === 'function') {
|