@luma.gl/webgl 9.0.0-beta.4 → 9.0.0-beta.5
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.js +240 -158
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -68
- package/dist/adapter/converters/shader-formats.js +33 -46
- package/dist/adapter/converters/texture-formats.d.ts +9 -18
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +454 -871
- package/dist/adapter/converters/vertex-formats.js +52 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +6 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +52 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +4 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +87 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +50 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +92 -0
- package/dist/adapter/helpers/decode-webgl-types.js +87 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -226
- package/dist/adapter/helpers/parse-shader-compiler-log.js +46 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +67 -82
- package/dist/adapter/helpers/webgl-topology-utils.js +77 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +18 -12
- package/dist/adapter/objects/webgl-renderbuffer.js +76 -80
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +204 -154
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +160 -119
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +268 -171
- package/dist/adapter/resources/webgl-command-encoder.js +32 -40
- package/dist/adapter/resources/webgl-external-texture.js +92 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -139
- package/dist/adapter/resources/webgl-render-pass.js +121 -95
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +11 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +378 -228
- package/dist/adapter/resources/webgl-sampler.d.ts +0 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -34
- package/dist/adapter/resources/webgl-shader.d.ts +10 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +106 -45
- package/dist/adapter/resources/webgl-texture.d.ts +2 -6
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +614 -699
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +143 -145
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +229 -158
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +58 -37
- package/dist/adapter/webgl-device.d.ts +7 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +440 -381
- package/dist/classic/accessor.js +132 -102
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -73
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +176 -177
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +38 -32
- package/dist/classic/typed-array-utils.js +95 -81
- package/dist/context/{polyfill → context}/context-data.d.ts +2 -1
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.js +54 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +102 -76
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +95 -46
- package/dist/context/parameters/webgl-parameter-tables.d.ts +110 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +456 -404
- package/dist/context/state-tracker/deep-array-equal.js +18 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +190 -126
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +45 -29
- package/dist/dist.dev.js +2568 -3786
- package/dist/index.cjs +1346 -2464
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -26
- package/dist/types.js +2 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +0 -1
- package/src/adapter/converters/sampler-parameters.ts +0 -17
- package/src/adapter/converters/texture-formats.ts +86 -154
- package/src/adapter/device-helpers/webgl-device-features.ts +69 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +3 -4
- package/src/adapter/device-helpers/{device-limits.ts → webgl-device-limits.ts} +25 -23
- package/src/adapter/helpers/get-shader-layout.ts +17 -28
- package/src/adapter/helpers/set-uniform.ts +1 -3
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +4 -4
- package/src/adapter/objects/webgl-resource.ts +3 -18
- package/src/adapter/resources/webgl-buffer.ts +6 -11
- package/src/adapter/resources/webgl-command-buffer.ts +20 -30
- package/src/adapter/resources/webgl-external-texture.ts +2 -3
- package/src/adapter/resources/webgl-framebuffer.ts +4 -5
- package/src/adapter/resources/webgl-render-pass.ts +7 -7
- package/src/adapter/resources/webgl-render-pipeline.ts +106 -31
- package/src/adapter/resources/webgl-sampler.ts +5 -9
- package/src/adapter/resources/webgl-shader.ts +57 -10
- package/src/adapter/resources/webgl-texture.ts +29 -103
- package/src/adapter/resources/webgl-transform-feedback.ts +14 -15
- package/src/adapter/resources/webgl-vertex-array.ts +16 -18
- package/src/adapter/webgl-canvas-context.ts +1 -7
- package/src/adapter/webgl-device.ts +18 -67
- package/src/classic/clear.ts +13 -14
- package/src/classic/copy-and-blit.ts +1 -2
- package/src/context/context/context-data.ts +44 -0
- package/src/context/context/create-browser-context.ts +7 -32
- package/src/context/debug/webgl-developer-tools.ts +6 -8
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +66 -75
- package/src/context/state-tracker/track-context-state.ts +18 -17
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +2 -17
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/context-data.ts +0 -30
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
// luma.gl, MIT license
|
|
2
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
-
|
|
4
|
-
import {assert} from '@luma.gl/core';
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
6
|
-
import {isWebGL2} from '../context/webgl-checks';
|
|
7
|
-
|
|
8
|
-
import {getParameterPolyfill} from './get-parameter-polyfill';
|
|
9
|
-
import {getContextData} from './context-data';
|
|
10
|
-
|
|
11
|
-
/* eslint-disable camelcase */
|
|
12
|
-
const OES_vertex_array_object = 'OES_vertex_array_object';
|
|
13
|
-
const ANGLE_instanced_arrays = 'ANGLE_instanced_arrays';
|
|
14
|
-
const WEBGL_draw_buffers = 'WEBGL_draw_buffers';
|
|
15
|
-
const EXT_disjoint_timer_query = 'EXT_disjoint_timer_query';
|
|
16
|
-
const EXT_texture_filter_anisotropic = 'EXT_texture_filter_anisotropic';
|
|
17
|
-
|
|
18
|
-
const ERR_VAO_NOT_SUPPORTED = 'VertexArray requires WebGL2 or OES_vertex_array_object extension';
|
|
19
|
-
|
|
20
|
-
// Return object with webgl2 flag and an extension
|
|
21
|
-
function getExtensionData(gl: WebGLRenderingContext, extension: string) {
|
|
22
|
-
return {
|
|
23
|
-
webgl2: isWebGL2(gl),
|
|
24
|
-
ext: gl.getExtension(extension)
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// function mapExtensionConstant(gl: WebGLRenderingContext, constant) {
|
|
29
|
-
// switch (constant) {
|
|
30
|
-
// case ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES: return GL.FRAGMENT_SHADER_DERIVATIVE_HINT;
|
|
31
|
-
// }
|
|
32
|
-
// }
|
|
33
|
-
|
|
34
|
-
export const WEBGL2_CONTEXT_POLYFILLS = {
|
|
35
|
-
// POLYFILL TABLE
|
|
36
|
-
[OES_vertex_array_object]: {
|
|
37
|
-
meta: {suffix: 'OES'},
|
|
38
|
-
// NEW METHODS
|
|
39
|
-
createVertexArray: () => {
|
|
40
|
-
assert(false, ERR_VAO_NOT_SUPPORTED);
|
|
41
|
-
},
|
|
42
|
-
deleteVertexArray: () => {},
|
|
43
|
-
bindVertexArray: () => {},
|
|
44
|
-
isVertexArray: () => false
|
|
45
|
-
},
|
|
46
|
-
[ANGLE_instanced_arrays]: {
|
|
47
|
-
meta: {
|
|
48
|
-
suffix: 'ANGLE'
|
|
49
|
-
// constants: {
|
|
50
|
-
// VERTEX_ATTRIB_ARRAY_DIVISOR: 'VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE'
|
|
51
|
-
// }
|
|
52
|
-
},
|
|
53
|
-
vertexAttribDivisor(location: number, divisor: number) {
|
|
54
|
-
// Accept divisor 0 even if instancing is not supported (0 = no instancing)
|
|
55
|
-
assert(divisor === 0, 'WebGL instanced rendering not supported');
|
|
56
|
-
},
|
|
57
|
-
drawElementsInstanced: () => {},
|
|
58
|
-
drawArraysInstanced: () => {}
|
|
59
|
-
},
|
|
60
|
-
[WEBGL_draw_buffers]: {
|
|
61
|
-
meta: {
|
|
62
|
-
suffix: 'WEBGL'
|
|
63
|
-
},
|
|
64
|
-
drawBuffers: () => {
|
|
65
|
-
assert(false);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
[EXT_disjoint_timer_query]: {
|
|
69
|
-
meta: {suffix: 'EXT'},
|
|
70
|
-
// WebGL1: Polyfills the WebGL2 Query API
|
|
71
|
-
createQuery: () => {
|
|
72
|
-
assert(false);
|
|
73
|
-
},
|
|
74
|
-
deleteQuery: () => {
|
|
75
|
-
assert(false);
|
|
76
|
-
},
|
|
77
|
-
beginQuery: () => {
|
|
78
|
-
assert(false);
|
|
79
|
-
},
|
|
80
|
-
endQuery: () => {},
|
|
81
|
-
getQuery(handle, pname: string) {
|
|
82
|
-
return this.getQueryObject(handle, pname);
|
|
83
|
-
},
|
|
84
|
-
// The WebGL1 extension uses getQueryObject rather then getQueryParameter
|
|
85
|
-
getQueryParameter(handle, pname: string) {
|
|
86
|
-
return this.getQueryObject(handle, pname);
|
|
87
|
-
},
|
|
88
|
-
getQueryObject: (handle: unknown, pname: unknown) => {}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const WEBGL2_CONTEXT_OVERRIDES = {
|
|
93
|
-
// Ensure readBuffer is a no-op
|
|
94
|
-
readBuffer: (gl: WebGLRenderingContext, originalFunc, attachment) => {
|
|
95
|
-
if (isWebGL2(gl)) {
|
|
96
|
-
originalFunc(attachment);
|
|
97
|
-
} else {
|
|
98
|
-
// assert(attachment !== GL_COLOR_ATTACHMENT0 && attachment !== GL_FRONT);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
// Override for getVertexAttrib that returns sane values for non-WebGL1 constants
|
|
102
|
-
getVertexAttrib: (gl: WebGLRenderingContext, originalFunc, location, pname) => {
|
|
103
|
-
// const gl = this; // eslint-disable-line
|
|
104
|
-
const {webgl2, ext} = getExtensionData(gl, ANGLE_instanced_arrays);
|
|
105
|
-
|
|
106
|
-
let result;
|
|
107
|
-
switch (pname) {
|
|
108
|
-
// WebGL1 attributes will never be integer
|
|
109
|
-
case GL.VERTEX_ATTRIB_ARRAY_INTEGER:
|
|
110
|
-
result = !webgl2 ? false : undefined;
|
|
111
|
-
break;
|
|
112
|
-
// if instancing is not available, return 0 meaning divisor has not been set
|
|
113
|
-
case GL.VERTEX_ATTRIB_ARRAY_DIVISOR:
|
|
114
|
-
result = !webgl2 && !ext ? 0 : undefined;
|
|
115
|
-
break;
|
|
116
|
-
default:
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return result !== undefined ? result : originalFunc(location, pname);
|
|
120
|
-
},
|
|
121
|
-
// Handle transform feedback and uniform block queries in WebGL1
|
|
122
|
-
getProgramParameter: (gl: WebGLRenderingContext, originalFunc, program, pname) => {
|
|
123
|
-
if (!isWebGL2(gl)) {
|
|
124
|
-
switch (pname) {
|
|
125
|
-
case GL.TRANSFORM_FEEDBACK_BUFFER_MODE:
|
|
126
|
-
return GL.SEPARATE_ATTRIBS;
|
|
127
|
-
case GL.TRANSFORM_FEEDBACK_VARYINGS:
|
|
128
|
-
return 0;
|
|
129
|
-
case GL.ACTIVE_UNIFORM_BLOCKS:
|
|
130
|
-
return 0;
|
|
131
|
-
default:
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return originalFunc(program, pname);
|
|
135
|
-
},
|
|
136
|
-
getInternalformatParameter: (gl: WebGLRenderingContext, originalFunc, target, format, pname) => {
|
|
137
|
-
if (!isWebGL2(gl)) {
|
|
138
|
-
switch (pname) {
|
|
139
|
-
case GL.SAMPLES:
|
|
140
|
-
return new Int32Array([0]);
|
|
141
|
-
default:
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const gl2 = gl as WebGL2RenderingContext;
|
|
145
|
-
return gl2.getInternalformatParameter(target, format, pname);
|
|
146
|
-
},
|
|
147
|
-
getTexParameter(gl, originalFunc, target, pname) {
|
|
148
|
-
switch (pname) {
|
|
149
|
-
case GL.TEXTURE_MAX_ANISOTROPY_EXT:
|
|
150
|
-
const contextData = getContextData(gl);
|
|
151
|
-
const {_extensions} = contextData;
|
|
152
|
-
const ext = _extensions[EXT_texture_filter_anisotropic];
|
|
153
|
-
pname = (ext && ext.TEXTURE_MAX_ANISOTROPY_EXT) || GL.TEXTURE_MAX_ANISOTROPY_EXT;
|
|
154
|
-
break;
|
|
155
|
-
default:
|
|
156
|
-
}
|
|
157
|
-
return originalFunc(target, pname);
|
|
158
|
-
},
|
|
159
|
-
getParameter: getParameterPolyfill,
|
|
160
|
-
hint(gl, originalFunc, pname, value) {
|
|
161
|
-
// TODO - handle GL.FRAGMENT_SHADER_DERIVATIVE_HINT:
|
|
162
|
-
// switch (pname) {
|
|
163
|
-
// case GL.FRAGMENT_SHADER_DERIVATIVE_HINT:
|
|
164
|
-
// }
|
|
165
|
-
return originalFunc(pname, value);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
// luma.gl, MIT license
|
|
2
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
** Copyright (c) 2015 The Khronos Group Inc.
|
|
6
|
-
**
|
|
7
|
-
** Permission is hereby granted, free of charge, to any person obtaining a
|
|
8
|
-
** copy of this software and/or associated documentation files (the
|
|
9
|
-
** "Materials"), to deal in the Materials without restriction, including
|
|
10
|
-
** without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
-
** distribute, sublicense, and/or sell copies of the Materials, and to
|
|
12
|
-
** permit persons to whom the Materials are furnished to do so, subject to
|
|
13
|
-
** the following conditions:
|
|
14
|
-
**
|
|
15
|
-
** The above copyright notice and this permission notice shall be included
|
|
16
|
-
** in all copies or substantial portions of the Materials.
|
|
17
|
-
**
|
|
18
|
-
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
-
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
-
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
-
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
-
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
-
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
-
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
// Modified to use ES6 and polyfill a provided context rather than
|
|
28
|
-
// the global class.
|
|
29
|
-
|
|
30
|
-
// @ts-nocheck external code
|
|
31
|
-
/* eslint-disable */
|
|
32
|
-
|
|
33
|
-
const glErrorShadow = {};
|
|
34
|
-
|
|
35
|
-
function error(msg) {
|
|
36
|
-
if (globalThis.console && globalThis.console.error) {
|
|
37
|
-
globalThis.console.error(msg);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function log(msg) {
|
|
42
|
-
if (globalThis.console && globalThis.console.log) {
|
|
43
|
-
globalThis.console.log(msg);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function synthesizeGLError(err, opt_msg) {
|
|
48
|
-
glErrorShadow[err] = true;
|
|
49
|
-
if (opt_msg !== undefined) {
|
|
50
|
-
error(opt_msg);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function wrapGLError(gl) {
|
|
55
|
-
const f = gl.getError;
|
|
56
|
-
gl.getError = function getError() {
|
|
57
|
-
let err;
|
|
58
|
-
do {
|
|
59
|
-
err = f.apply(gl);
|
|
60
|
-
if (err !== gl.NO_ERROR) {
|
|
61
|
-
glErrorShadow[err] = true;
|
|
62
|
-
}
|
|
63
|
-
} while (err !== gl.NO_ERROR);
|
|
64
|
-
|
|
65
|
-
for (err in glErrorShadow) {
|
|
66
|
-
if (glErrorShadow[err]) {
|
|
67
|
-
delete glErrorShadow[err];
|
|
68
|
-
return parseInt(err, 10);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return gl.NO_ERROR;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const WebGLVertexArrayObjectOES = function WebGLVertexArrayObjectOES(ext) {
|
|
77
|
-
const gl = ext.gl;
|
|
78
|
-
|
|
79
|
-
this.ext = ext;
|
|
80
|
-
this.isAlive = true;
|
|
81
|
-
this.hasBeenBound = false;
|
|
82
|
-
|
|
83
|
-
this.elementArrayBuffer = null;
|
|
84
|
-
this.attribs = new Array(ext.maxVertexAttribs);
|
|
85
|
-
for (let n = 0; n < this.attribs.length; n++) {
|
|
86
|
-
const attrib = new WebGLVertexArrayObjectOES.VertexAttrib(gl);
|
|
87
|
-
this.attribs[n] = attrib;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
this.maxAttrib = 0;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl) {
|
|
94
|
-
this.enabled = false;
|
|
95
|
-
this.buffer = null;
|
|
96
|
-
this.size = 4;
|
|
97
|
-
this.type = gl.FLOAT;
|
|
98
|
-
this.normalized = false;
|
|
99
|
-
this.stride = 16;
|
|
100
|
-
this.offset = 0;
|
|
101
|
-
|
|
102
|
-
this.cached = '';
|
|
103
|
-
this.recache();
|
|
104
|
-
};
|
|
105
|
-
WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache = function recache() {
|
|
106
|
-
this.cached = [this.size, this.type, this.normalized, this.stride, this.offset].join(':');
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const OESVertexArrayObject = function OESVertexArrayObject(gl) {
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
111
|
-
const self = this;
|
|
112
|
-
this.gl = gl;
|
|
113
|
-
|
|
114
|
-
wrapGLError(gl);
|
|
115
|
-
|
|
116
|
-
const original = (this.original = {
|
|
117
|
-
getParameter: gl.getParameter,
|
|
118
|
-
enableVertexAttribArray: gl.enableVertexAttribArray,
|
|
119
|
-
disableVertexAttribArray: gl.disableVertexAttribArray,
|
|
120
|
-
bindBuffer: gl.bindBuffer,
|
|
121
|
-
getVertexAttrib: gl.getVertexAttrib,
|
|
122
|
-
vertexAttribPointer: gl.vertexAttribPointer
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
gl.getParameter = function getParameter(pname) {
|
|
126
|
-
if (pname === self.VERTEX_ARRAY_BINDING_OES) {
|
|
127
|
-
if (self.currentVertexArrayObject === self.defaultVertexArrayObject) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
return self.currentVertexArrayObject;
|
|
131
|
-
}
|
|
132
|
-
return original.getParameter.apply(this, arguments);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
gl.enableVertexAttribArray = function enableVertexAttribArray(index) {
|
|
136
|
-
const vao = self.currentVertexArrayObject;
|
|
137
|
-
vao.maxAttrib = Math.max(vao.maxAttrib, index);
|
|
138
|
-
const attrib = vao.attribs[index];
|
|
139
|
-
attrib.enabled = true;
|
|
140
|
-
return original.enableVertexAttribArray.apply(this, arguments);
|
|
141
|
-
};
|
|
142
|
-
gl.disableVertexAttribArray = function disableVertexAttribArray(index) {
|
|
143
|
-
const vao = self.currentVertexArrayObject;
|
|
144
|
-
vao.maxAttrib = Math.max(vao.maxAttrib, index);
|
|
145
|
-
const attrib = vao.attribs[index];
|
|
146
|
-
attrib.enabled = false;
|
|
147
|
-
return original.disableVertexAttribArray.apply(this, arguments);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
gl.bindBuffer = function bindBuffer(target, buffer) {
|
|
151
|
-
switch (target) {
|
|
152
|
-
case gl.ARRAY_BUFFER:
|
|
153
|
-
self.currentArrayBuffer = buffer;
|
|
154
|
-
break;
|
|
155
|
-
case gl.ELEMENT_ARRAY_BUFFER:
|
|
156
|
-
self.currentVertexArrayObject.elementArrayBuffer = buffer;
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
}
|
|
160
|
-
return original.bindBuffer.apply(this, arguments);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
gl.getVertexAttrib = function getVertexAttrib(index, pname) {
|
|
164
|
-
const vao = self.currentVertexArrayObject;
|
|
165
|
-
const attrib = vao.attribs[index];
|
|
166
|
-
switch (pname) {
|
|
167
|
-
case gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
|
168
|
-
return attrib.buffer;
|
|
169
|
-
case gl.VERTEX_ATTRIB_ARRAY_ENABLED:
|
|
170
|
-
return attrib.enabled;
|
|
171
|
-
case gl.VERTEX_ATTRIB_ARRAY_SIZE:
|
|
172
|
-
return attrib.size;
|
|
173
|
-
case gl.VERTEX_ATTRIB_ARRAY_STRIDE:
|
|
174
|
-
return attrib.stride;
|
|
175
|
-
case gl.VERTEX_ATTRIB_ARRAY_TYPE:
|
|
176
|
-
return attrib.type;
|
|
177
|
-
case gl.VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
|
178
|
-
return attrib.normalized;
|
|
179
|
-
default:
|
|
180
|
-
return original.getVertexAttrib.apply(this, arguments);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// eslint-disable-next-line max-params
|
|
185
|
-
gl.vertexAttribPointer = function vertexAttribPointer(
|
|
186
|
-
indx,
|
|
187
|
-
size,
|
|
188
|
-
type,
|
|
189
|
-
normalized,
|
|
190
|
-
stride,
|
|
191
|
-
offset
|
|
192
|
-
) {
|
|
193
|
-
const vao = self.currentVertexArrayObject;
|
|
194
|
-
vao.maxAttrib = Math.max(vao.maxAttrib, indx);
|
|
195
|
-
const attrib = vao.attribs[indx];
|
|
196
|
-
attrib.buffer = self.currentArrayBuffer;
|
|
197
|
-
attrib.size = size;
|
|
198
|
-
attrib.type = type;
|
|
199
|
-
attrib.normalized = normalized;
|
|
200
|
-
attrib.stride = stride;
|
|
201
|
-
attrib.offset = offset;
|
|
202
|
-
attrib.recache();
|
|
203
|
-
return original.vertexAttribPointer.apply(this, arguments);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
if (gl.instrumentExtension) {
|
|
207
|
-
gl.instrumentExtension(this, 'OES_vertex_array_object');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// undefined for headless gl
|
|
211
|
-
if (gl.canvas) {
|
|
212
|
-
gl.canvas.addEventListener(
|
|
213
|
-
'webglcontextrestored',
|
|
214
|
-
() => {
|
|
215
|
-
log('OESVertexArrayObject emulation library context restored');
|
|
216
|
-
self.reset_();
|
|
217
|
-
},
|
|
218
|
-
true
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
this.reset_();
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
OESVertexArrayObject.prototype.VERTEX_ARRAY_BINDING_OES = 0x85b5;
|
|
226
|
-
|
|
227
|
-
OESVertexArrayObject.prototype.reset_ = function reset_() {
|
|
228
|
-
const contextWasLost = this.vertexArrayObjects !== undefined;
|
|
229
|
-
if (contextWasLost) {
|
|
230
|
-
for (let ii = 0; ii < this.vertexArrayObjects.length; ++ii) {
|
|
231
|
-
this.vertexArrayObjects.isAlive = false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
const gl = this.gl;
|
|
235
|
-
this.maxVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
|
|
236
|
-
|
|
237
|
-
this.defaultVertexArrayObject = new WebGLVertexArrayObjectOES(this);
|
|
238
|
-
this.currentVertexArrayObject = null;
|
|
239
|
-
this.currentArrayBuffer = null;
|
|
240
|
-
this.vertexArrayObjects = [this.defaultVertexArrayObject];
|
|
241
|
-
|
|
242
|
-
this.bindVertexArrayOES(null);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
OESVertexArrayObject.prototype.createVertexArrayOES = function createVertexArrayOES() {
|
|
246
|
-
const arrayObject = new WebGLVertexArrayObjectOES(this);
|
|
247
|
-
this.vertexArrayObjects.push(arrayObject);
|
|
248
|
-
return arrayObject;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
OESVertexArrayObject.prototype.deleteVertexArrayOES = function deleteVertexArrayOES(arrayObject) {
|
|
252
|
-
arrayObject.isAlive = false;
|
|
253
|
-
this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(arrayObject), 1);
|
|
254
|
-
if (this.currentVertexArrayObject === arrayObject) {
|
|
255
|
-
this.bindVertexArrayOES(null);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
OESVertexArrayObject.prototype.isVertexArrayOES = function isVertexArrayOES(arrayObject) {
|
|
260
|
-
if (arrayObject && arrayObject instanceof WebGLVertexArrayObjectOES) {
|
|
261
|
-
if (arrayObject.hasBeenBound && arrayObject.ext === this) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return false;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(arrayObject) {
|
|
269
|
-
const gl = this.gl;
|
|
270
|
-
if (arrayObject && !arrayObject.isAlive) {
|
|
271
|
-
synthesizeGLError(
|
|
272
|
-
gl.INVALID_OPERATION,
|
|
273
|
-
'bindVertexArrayOES: attempt to bind deleted arrayObject'
|
|
274
|
-
);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const original = this.original;
|
|
278
|
-
|
|
279
|
-
const oldVAO = this.currentVertexArrayObject;
|
|
280
|
-
this.currentVertexArrayObject = arrayObject || this.defaultVertexArrayObject;
|
|
281
|
-
this.currentVertexArrayObject.hasBeenBound = true;
|
|
282
|
-
const newVAO = this.currentVertexArrayObject;
|
|
283
|
-
|
|
284
|
-
if (oldVAO === newVAO) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (!oldVAO || newVAO.elementArrayBuffer !== oldVAO.elementArrayBuffer) {
|
|
289
|
-
original.bindBuffer.call(gl, gl.ELEMENT_ARRAY_BUFFER, newVAO.elementArrayBuffer);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
let currentBinding = this.currentArrayBuffer;
|
|
293
|
-
const maxAttrib = Math.max(oldVAO ? oldVAO.maxAttrib : 0, newVAO.maxAttrib);
|
|
294
|
-
for (let n = 0; n <= maxAttrib; n++) {
|
|
295
|
-
const attrib = newVAO.attribs[n];
|
|
296
|
-
const oldAttrib = oldVAO ? oldVAO.attribs[n] : null;
|
|
297
|
-
|
|
298
|
-
if (!oldVAO || attrib.enabled !== oldAttrib.enabled) {
|
|
299
|
-
if (attrib.enabled) {
|
|
300
|
-
original.enableVertexAttribArray.call(gl, n);
|
|
301
|
-
} else {
|
|
302
|
-
original.disableVertexAttribArray.call(gl, n);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (attrib.enabled) {
|
|
307
|
-
let bufferChanged = false;
|
|
308
|
-
if (!oldVAO || attrib.buffer !== oldAttrib.buffer) {
|
|
309
|
-
if (currentBinding !== attrib.buffer) {
|
|
310
|
-
original.bindBuffer.call(gl, gl.ARRAY_BUFFER, attrib.buffer);
|
|
311
|
-
currentBinding = attrib.buffer;
|
|
312
|
-
}
|
|
313
|
-
bufferChanged = true;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (bufferChanged || attrib.cached !== oldAttrib.cached) {
|
|
317
|
-
original.vertexAttribPointer.call(
|
|
318
|
-
gl,
|
|
319
|
-
n,
|
|
320
|
-
attrib.size,
|
|
321
|
-
attrib.type,
|
|
322
|
-
attrib.normalized,
|
|
323
|
-
attrib.stride,
|
|
324
|
-
attrib.offset
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (this.currentArrayBuffer !== currentBinding) {
|
|
331
|
-
original.bindBuffer.call(gl, gl.ARRAY_BUFFER, this.currentArrayBuffer);
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
export function polyfillVertexArrayObject(gl) {
|
|
336
|
-
if (typeof gl.createVertexArray === 'function') {
|
|
337
|
-
// VAOs directly supported on object (i.e. WebGL 2 context)
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const original_getSupportedExtensions = gl.getSupportedExtensions;
|
|
342
|
-
gl.getSupportedExtensions = function getSupportedExtensions() {
|
|
343
|
-
const list = original_getSupportedExtensions.call(this) || [];
|
|
344
|
-
if (list.indexOf('OES_vertex_array_object') < 0) {
|
|
345
|
-
list.push('OES_vertex_array_object');
|
|
346
|
-
}
|
|
347
|
-
return list;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const original_getExtension = gl.getExtension;
|
|
351
|
-
gl.getExtension = function getExtension(name) {
|
|
352
|
-
const ext = original_getExtension.call(this, name);
|
|
353
|
-
if (ext) {
|
|
354
|
-
return ext;
|
|
355
|
-
}
|
|
356
|
-
if (name !== 'OES_vertex_array_object') {
|
|
357
|
-
return null;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (!gl.__OESVertexArrayObject) {
|
|
361
|
-
this.__OESVertexArrayObject = new OESVertexArrayObject(this);
|
|
362
|
-
}
|
|
363
|
-
return this.__OESVertexArrayObject;
|
|
364
|
-
};
|
|
365
|
-
}
|