@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7

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.
Files changed (192) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +128 -71
  3. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/sampler-parameters.js +20 -19
  5. package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/shader-formats.js +40 -20
  7. package/dist/adapter/converters/texture-formats.d.ts +16 -11
  8. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  9. package/dist/adapter/converters/texture-formats.js +224 -205
  10. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/vertex-formats.js +22 -21
  12. package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
  13. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  14. package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
  15. package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
  16. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
  17. package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
  18. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
  19. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
  20. package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
  21. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
  22. package/dist/adapter/helpers/decode-webgl-types.js +47 -46
  23. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  24. package/dist/adapter/helpers/get-shader-layout.js +35 -34
  25. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  26. package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
  27. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  28. package/dist/adapter/helpers/set-uniform.js +42 -41
  29. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  30. package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
  31. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  32. package/dist/adapter/objects/constants-to-keys.js +2 -1
  33. package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
  34. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  35. package/dist/adapter/objects/webgl-renderbuffer.js +30 -17
  36. package/dist/adapter/objects/webgl-resource.d.ts +2 -24
  37. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  38. package/dist/adapter/objects/webgl-resource.js +6 -101
  39. package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
  40. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-buffer.js +16 -15
  42. package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
  43. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgl-command-buffer.js +32 -31
  45. package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
  46. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  47. package/dist/adapter/resources/webgl-command-encoder.js +4 -2
  48. package/dist/adapter/resources/webgl-external-texture.js +6 -5
  49. package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
  50. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.js +60 -53
  52. package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
  53. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
  54. package/dist/adapter/resources/webgl-query-set.js +136 -0
  55. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
  56. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pass.js +20 -12
  58. package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
  59. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
  61. package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
  62. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-sampler.js +5 -4
  64. package/dist/adapter/resources/webgl-shader.d.ts +3 -2
  65. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  66. package/dist/adapter/resources/webgl-shader.js +15 -9
  67. package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
  68. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
  69. package/dist/adapter/resources/webgl-texture-view.js +18 -0
  70. package/dist/adapter/resources/webgl-texture.d.ts +6 -4
  71. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgl-texture.js +39 -32
  73. package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
  74. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  75. package/dist/adapter/resources/webgl-transform-feedback.js +10 -10
  76. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
  77. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  78. package/dist/adapter/resources/webgl-vertex-array.js +10 -9
  79. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  80. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  81. package/dist/adapter/webgl-canvas-context.js +3 -2
  82. package/dist/adapter/webgl-device.d.ts +35 -30
  83. package/dist/adapter/webgl-device.d.ts.map +1 -1
  84. package/dist/adapter/webgl-device.js +110 -109
  85. package/dist/classic/accessor.d.ts.map +1 -1
  86. package/dist/classic/accessor.js +8 -7
  87. package/dist/classic/clear.d.ts.map +1 -1
  88. package/dist/classic/clear.js +5 -4
  89. package/dist/classic/copy-and-blit.d.ts +1 -1
  90. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  91. package/dist/classic/copy-and-blit.js +19 -19
  92. package/dist/classic/format-utils.d.ts.map +1 -1
  93. package/dist/classic/format-utils.js +16 -15
  94. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  95. package/dist/classic/typed-array-utils.js +20 -19
  96. package/dist/context/debug/spector.d.ts.map +1 -1
  97. package/dist/context/debug/spector.js +2 -1
  98. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  99. package/dist/context/debug/webgl-developer-tools.js +7 -6
  100. package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
  101. package/dist/context/{context → helpers}/create-browser-context.js +2 -1
  102. package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
  103. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  104. package/dist/context/helpers/webgl-context-data.js +21 -0
  105. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  106. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  107. package/dist/context/helpers/webgl-extensions.js +10 -0
  108. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  109. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  110. package/dist/context/parameters/unified-parameter-api.js +7 -11
  111. package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  113. package/dist/context/parameters/webgl-parameter-tables.js +302 -295
  114. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  115. package/dist/context/state-tracker/deep-array-equal.js +2 -1
  116. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  117. package/dist/context/state-tracker/track-context-state.js +5 -4
  118. package/dist/context/state-tracker/with-parameters.d.ts +2 -3
  119. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  120. package/dist/context/state-tracker/with-parameters.js +6 -8
  121. package/dist/dist.dev.js +1635 -1387
  122. package/dist/index.cjs +1766 -1534
  123. package/dist/index.cjs.map +4 -4
  124. package/dist/index.d.ts +25 -25
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +24 -23
  127. package/dist/types.d.ts.map +1 -1
  128. package/dist/types.js +2 -1
  129. package/dist.min.js +6 -6
  130. package/package.json +4 -4
  131. package/src/adapter/converters/device-parameters.ts +114 -27
  132. package/src/adapter/converters/sampler-parameters.ts +12 -3
  133. package/src/adapter/converters/shader-formats.ts +47 -22
  134. package/src/adapter/converters/texture-formats.ts +138 -114
  135. package/src/adapter/converters/vertex-formats.ts +3 -3
  136. package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
  137. package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
  138. package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
  139. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  140. package/src/adapter/helpers/get-shader-layout.ts +4 -3
  141. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  142. package/src/adapter/helpers/set-uniform.ts +2 -1
  143. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  144. package/src/adapter/objects/constants-to-keys.ts +2 -1
  145. package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
  146. package/src/adapter/objects/webgl-resource.ts +7 -125
  147. package/src/adapter/resources/webgl-buffer.ts +4 -3
  148. package/src/adapter/resources/webgl-command-buffer.ts +5 -5
  149. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  150. package/src/adapter/resources/webgl-external-texture.ts +6 -5
  151. package/src/adapter/resources/webgl-framebuffer.ts +61 -53
  152. package/src/adapter/resources/webgl-query-set.ts +171 -0
  153. package/src/adapter/resources/webgl-render-pass.ts +20 -11
  154. package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
  155. package/src/adapter/resources/webgl-sampler.ts +2 -1
  156. package/src/adapter/resources/webgl-shader.ts +12 -5
  157. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  158. package/src/adapter/resources/webgl-texture.ts +14 -3
  159. package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
  160. package/src/adapter/resources/webgl-vertex-array.ts +4 -3
  161. package/src/adapter/webgl-canvas-context.ts +6 -4
  162. package/src/adapter/webgl-device.ts +116 -107
  163. package/src/classic/accessor.ts +5 -4
  164. package/src/classic/clear.ts +14 -8
  165. package/src/classic/copy-and-blit.ts +11 -4
  166. package/src/classic/format-utils.ts +2 -1
  167. package/src/classic/typed-array-utils.ts +3 -7
  168. package/src/context/debug/spector.ts +9 -6
  169. package/src/context/debug/webgl-developer-tools.ts +27 -14
  170. package/src/context/{context → helpers}/create-browser-context.ts +3 -2
  171. package/src/context/helpers/webgl-context-data.ts +31 -0
  172. package/src/context/helpers/webgl-extensions.ts +17 -0
  173. package/src/context/parameters/unified-parameter-api.ts +6 -17
  174. package/src/context/parameters/webgl-parameter-tables.ts +69 -32
  175. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  176. package/src/context/state-tracker/track-context-state.ts +11 -6
  177. package/src/context/state-tracker/with-parameters.ts +8 -8
  178. package/src/index.ts +7 -6
  179. package/src/types.ts +2 -1
  180. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  181. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  182. package/dist/adapter/device-helpers/device-features.js +0 -65
  183. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  184. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  185. package/dist/adapter/device-helpers/device-limits.js +0 -92
  186. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  187. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  188. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  189. package/dist/context/context/context-data.d.ts.map +0 -1
  190. package/dist/context/context/context-data.js +0 -33
  191. package/src/context/context/context-data.ts +0 -44
  192. /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
@@ -1,58 +1,57 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { Device, CanvasContext, log, uid, assert } from '@luma.gl/core';
4
- import { isBrowser } from '@probe.gl/env';
5
- import { popContextState, pushContextState, trackContextState } from '../context/state-tracker/track-context-state';
6
- import { createBrowserContext } from '../context/context/create-browser-context';
7
- import { getDeviceInfo } from './device-helpers/webgl-device-info';
8
- import { getDeviceFeatures } from './device-helpers/webgl-device-features';
9
- import { getDeviceLimits, getWebGLLimits } from './device-helpers/webgl-device-limits';
10
- import { WebGLCanvasContext } from './webgl-canvas-context';
11
- import { loadSpectorJS, initializeSpectorJS } from '../context/debug/spector';
12
- import { loadWebGLDeveloperTools, makeDebugContext } from '../context/debug/webgl-developer-tools';
13
- import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from './converters/texture-formats';
14
- import { WEBGLBuffer } from './resources/webgl-buffer';
15
- import { WEBGLShader } from './resources/webgl-shader';
16
- import { WEBGLSampler } from './resources/webgl-sampler';
17
- import { WEBGLTexture } from './resources/webgl-texture';
18
- import { WEBGLFramebuffer } from './resources/webgl-framebuffer';
19
- import { WEBGLRenderPass } from './resources/webgl-render-pass';
20
- import { WEBGLRenderPipeline } from './resources/webgl-render-pipeline';
21
- import { WEBGLCommandEncoder } from './resources/webgl-command-encoder';
22
- import { WEBGLVertexArray } from './resources/webgl-vertex-array';
23
- import { WEBGLTransformFeedback } from './resources/webgl-transform-feedback';
24
- import { readPixelsToArray, readPixelsToBuffer } from '../classic/copy-and-blit';
25
- import { setGLParameters, getGLParameters } from '../context/parameters/unified-parameter-api';
26
- import { withGLParameters } from '../context/state-tracker/with-parameters';
27
- import { clear } from '../classic/clear';
5
+ import { popContextState, pushContextState, trackContextState } from "../context/state-tracker/track-context-state.js";
6
+ import { createBrowserContext } from "../context/helpers/create-browser-context.js";
7
+ import { getDeviceInfo } from "./device-helpers/webgl-device-info.js";
8
+ import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
9
+ import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
10
+ import { WebGLCanvasContext } from "./webgl-canvas-context.js";
11
+ import { loadSpectorJS, initializeSpectorJS } from "../context/debug/spector.js";
12
+ import { loadWebGLDeveloperTools, makeDebugContext } from "../context/debug/webgl-developer-tools.js";
13
+ import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from "./converters/texture-formats.js";
14
+ import { WEBGLBuffer } from "./resources/webgl-buffer.js";
15
+ import { WEBGLShader } from "./resources/webgl-shader.js";
16
+ import { WEBGLSampler } from "./resources/webgl-sampler.js";
17
+ import { WEBGLTexture } from "./resources/webgl-texture.js";
18
+ import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
19
+ import { WEBGLRenderPass } from "./resources/webgl-render-pass.js";
20
+ import { WEBGLRenderPipeline } from "./resources/webgl-render-pipeline.js";
21
+ import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
22
+ import { WEBGLVertexArray } from "./resources/webgl-vertex-array.js";
23
+ import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
24
+ import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
25
+ import { readPixelsToArray, readPixelsToBuffer } from "../classic/copy-and-blit.js";
26
+ import { setGLParameters, getGLParameters } from "../context/parameters/unified-parameter-api.js";
27
+ import { withGLParameters } from "../context/state-tracker/with-parameters.js";
28
+ import { clear } from "../classic/clear.js";
29
+ import { getWebGLExtension } from "../context/helpers/webgl-extensions.js";
28
30
  const LOG_LEVEL = 1;
29
31
  /** WebGPU style Device API for a WebGL context */
30
32
  export class WebGLDevice extends Device {
31
33
  //
32
34
  // Public `Device` API
33
35
  //
36
+ /** type of this device */
34
37
  static type = 'webgl';
35
- static isSupported() {
36
- return typeof WebGL2RenderingContext !== 'undefined';
37
- }
38
+ /** type of this device */
39
+ type = 'webgl';
40
+ /** The underlying WebGL context */
41
+ handle;
42
+ features;
43
+ limits;
38
44
  info;
39
45
  canvasContext;
40
- handle;
41
- get features() {
42
- this._features = this._features || getDeviceFeatures(this.gl);
43
- return this._features;
44
- }
45
- get limits() {
46
- this._limits = this._limits || getDeviceLimits(this.gl);
47
- return this._limits;
48
- }
49
46
  lost;
50
47
  _resolveContextLost;
51
- _features;
52
- _limits;
53
48
  //
54
49
  // Static methods, expected to be present by `luma.createDevice()`
55
50
  //
51
+ /** Check if WebGL 2 is available */
52
+ static isSupported() {
53
+ return typeof WebGL2RenderingContext !== 'undefined';
54
+ }
56
55
  /**
57
56
  * Get a device instance from a GL context
58
57
  * Creates and instruments the device if not already created
@@ -75,29 +74,37 @@ export class WebGLDevice extends Device {
75
74
  }
76
75
  static async create(props = {}) {
77
76
  log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
78
- // Wait for page to load. Only wait when props. canvas is string
79
- // to avoid setting page onload callback unless necessary
80
- if (typeof props.canvas === 'string') {
81
- await CanvasContext.pageLoaded;
82
- }
77
+ const promises = [];
83
78
  // Load webgl and spector debug scripts from CDN if requested
84
- if (log.get('debug') || props.debug) {
85
- await loadWebGLDeveloperTools();
79
+ if (props.debug) {
80
+ promises.push(loadWebGLDeveloperTools());
81
+ }
82
+ if (props.spector) {
83
+ promises.push(loadSpectorJS());
84
+ }
85
+ // Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
86
+ // We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
87
+ if (typeof props.canvas === 'string') {
88
+ promises.push(CanvasContext.pageLoaded);
86
89
  }
87
- // @ts-expect-error spector not on props
88
- const { spector } = props;
89
- if (log.get('spector') || spector) {
90
- await loadSpectorJS();
90
+ // Wait for all the loads to settle before creating the context.
91
+ // The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
92
+ const results = await Promise.allSettled(promises);
93
+ for (const result of results) {
94
+ if (result.status === 'rejected') {
95
+ log.error(`Failed to initialize debug libraries ${result.reason}`)();
96
+ }
91
97
  }
92
98
  log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
93
99
  // @ts-expect-error
94
- if (props.gl && props.gl.device) {
100
+ if (props.gl?.device) {
101
+ log.warn('reattaching existing device')();
95
102
  return WebGLDevice.attach(props.gl);
96
103
  }
97
104
  const device = new WebGLDevice(props);
98
105
  // Log some debug info about the newly created context
99
106
  const message = `\
100
- Created ${device.info.type}${device.debug ? ' debug' : ''} context: \
107
+ Created ${device.type}${device.debug ? ' debug' : ''} context: \
101
108
  ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
102
109
  log.probe(LOG_LEVEL, message)();
103
110
  log.table(LOG_LEVEL, device.info)();
@@ -116,33 +123,34 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
116
123
  throw new Error(`WebGL context already attached to device ${device.id}`);
117
124
  }
118
125
  // Create and instrument context
119
- const canvas = props.canvas || props.gl?.canvas;
126
+ const canvas = props.gl?.canvas || props.canvas;
120
127
  this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
121
128
  this.lost = new Promise(resolve => {
122
129
  this._resolveContextLost = resolve;
123
130
  });
124
- const onContextLost = (event) => this._resolveContextLost?.({
125
- reason: 'destroyed',
126
- message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
127
- });
128
131
  let gl = props.gl || null;
129
- gl =
130
- gl ||
131
- (isBrowser()
132
- ? createBrowserContext(this.canvasContext.canvas, { ...props, onContextLost })
133
- : null);
132
+ gl ||= createBrowserContext(this.canvasContext.canvas, {
133
+ ...props,
134
+ onContextLost: (event) => this._resolveContextLost?.({
135
+ reason: 'destroyed',
136
+ message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
137
+ })
138
+ });
134
139
  if (!gl) {
135
140
  throw new Error('WebGL context creation failed');
136
141
  }
137
142
  this.handle = gl;
138
- this.gl = this.handle;
139
- this.canvasContext.resize();
143
+ this.gl = gl;
144
+ this.gl.device = this; // Update GL context: Link webgl context back to device
145
+ this.gl._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
140
146
  // luma Device fields
141
- this.info = getDeviceInfo(this.gl);
142
- // @ts-expect-error Link webgl context back to device
143
- this.gl.device = this;
144
- // @ts-expect-error Annotate webgl context to handle
145
- this.gl._version = this.isWebGL2 ? 2 : 1;
147
+ this.info = getDeviceInfo(this.gl, this._extensions);
148
+ this.limits = new WebGLDeviceLimits(this.gl);
149
+ this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props.disabledFeatures);
150
+ if (this.props.initalizeFeatures) {
151
+ this.features.initializeFeatures();
152
+ }
153
+ this.canvasContext.resize();
146
154
  // Install context state tracking
147
155
  // @ts-expect-error - hidden parameters
148
156
  const { enable = true, copyState = false } = props;
@@ -152,24 +160,21 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
152
160
  log: (...args) => log.log(1, ...args)()
153
161
  });
154
162
  // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
155
- if (isBrowser() && props.debug) {
163
+ if (props.debug) {
156
164
  this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
157
165
  this.debug = true;
158
166
  log.level = Math.max(log.level, 1);
159
167
  log.warn('WebGL debug mode activated. Performance reduced.')();
160
168
  }
161
- // @ts-expect-error spector not on props
162
- if (isBrowser() && props.spector) {
163
- const canvas = this.handle.canvas || props.canvas;
164
- this.spector = initializeSpectorJS({ ...this.props, canvas });
169
+ if (props.spector) {
170
+ this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
165
171
  }
166
172
  }
167
173
  /**
168
174
  * Destroys the context
169
- * @note Has no effect for browser contexts, there is no browser API for destroying contexts
175
+ * @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
170
176
  */
171
- destroy() {
172
- }
177
+ destroy() { }
173
178
  get isLost() {
174
179
  return this.gl.isContextLost();
175
180
  }
@@ -177,13 +182,13 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
177
182
  return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
178
183
  }
179
184
  isTextureFormatSupported(format) {
180
- return isTextureFormatSupported(this.gl, format);
185
+ return isTextureFormatSupported(this.gl, format, this._extensions);
181
186
  }
182
187
  isTextureFormatFilterable(format) {
183
- return isTextureFormatFilterable(this.gl, format);
188
+ return isTextureFormatFilterable(this.gl, format, this._extensions);
184
189
  }
185
190
  isTextureFormatRenderable(format) {
186
- return isTextureFormatRenderable(this.gl, format);
191
+ return isTextureFormatRenderable(this.gl, format, this._extensions);
187
192
  }
188
193
  // IMPLEMENTATION OF ABSTRACT DEVICE
189
194
  createCanvasContext(props) {
@@ -208,12 +213,18 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
208
213
  createFramebuffer(props) {
209
214
  return new WEBGLFramebuffer(this, props);
210
215
  }
211
- createRenderPipeline(props) {
212
- return new WEBGLRenderPipeline(this, props);
213
- }
214
216
  createVertexArray(props) {
215
217
  return new WEBGLVertexArray(this, props);
216
218
  }
219
+ createTransformFeedback(props) {
220
+ return new WEBGLTransformFeedback(this, props);
221
+ }
222
+ createQuerySet(props) {
223
+ return new WEBGLQuerySet(this, props);
224
+ }
225
+ createRenderPipeline(props) {
226
+ return new WEBGLRenderPipeline(this, props);
227
+ }
217
228
  beginRenderPass(props) {
218
229
  return new WEBGLRenderPass(this, props);
219
230
  }
@@ -223,18 +234,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
223
234
  beginComputePass(props) {
224
235
  throw new Error('ComputePass not supported in WebGL');
225
236
  }
226
- createTransformFeedback(props) {
227
- return new WEBGLTransformFeedback(this, props);
228
- }
229
237
  renderPass = null;
230
- getDefaultRenderPass() {
231
- this.renderPass =
232
- this.renderPass ||
233
- this.beginRenderPass({
234
- framebuffer: this.canvasContext.getCurrentFramebuffer()
235
- });
236
- return this.renderPass;
237
- }
238
238
  createCommandEncoder(props) {
239
239
  return new WEBGLCommandEncoder(this, props);
240
240
  }
@@ -250,7 +250,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
250
250
  }
251
251
  //
252
252
  // TEMPORARY HACKS - will be removed in v9.1
253
- //
253
+ //
254
254
  /** @deprecated - should use command encoder */
255
255
  readPixelsToArrayWebGL(source, options) {
256
256
  return readPixelsToArray(source, options);
@@ -260,13 +260,13 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
260
260
  return readPixelsToBuffer(source, options);
261
261
  }
262
262
  setParametersWebGL(parameters) {
263
- setGLParameters(this, parameters);
263
+ setGLParameters(this.gl, parameters);
264
264
  }
265
265
  getParametersWebGL(parameters) {
266
- return getGLParameters(this, parameters);
266
+ return getGLParameters(this.gl, parameters);
267
267
  }
268
268
  withParametersWebGL(parameters, func) {
269
- withGLParameters(this, parameters, func);
269
+ withGLParameters(this.gl, parameters, func);
270
270
  }
271
271
  clearWebGL(options) {
272
272
  clear(this, options);
@@ -283,20 +283,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
283
283
  _extensions = {};
284
284
  _polyfilled = false;
285
285
  /** Instance of Spector.js (if initialized) */
286
- spector;
287
- _webglLimits;
288
- /** Return WebGL specific limits */
289
- get webglLimits() {
290
- this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
291
- return this._webglLimits;
292
- }
286
+ spectorJS;
293
287
  /**
294
288
  * Triggers device (or WebGL context) loss.
295
289
  * @note primarily intended for testing how application reacts to device loss
296
290
  */
297
291
  loseDevice() {
298
292
  let deviceLossTriggered = false;
299
- const ext = this.gl.getExtension('WEBGL_lose_context');
293
+ const extensions = this.getExtension('WEBGL_lose_context');
294
+ const ext = extensions.WEBGL_lose_context;
300
295
  if (ext) {
301
296
  deviceLossTriggered = true;
302
297
  ext.loseContext();
@@ -351,11 +346,12 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
351
346
  * so they need to be updated before every render
352
347
  * @todo - remember/cache values to avoid setting them unnecessarily?
353
348
  */
354
- setConstantAttribute(location, constant) {
355
- this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
349
+ setConstantAttributeWebGL(location, constant) {
350
+ const maxVertexAttributes = this.limits.maxVertexAttributes;
351
+ this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
356
352
  const currentConstant = this._constants[location];
357
353
  if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
358
- log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
354
+ log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
359
355
  }
360
356
  this._constants[location] = constant;
361
357
  switch (constant.constructor) {
@@ -372,6 +368,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
372
368
  assert(false);
373
369
  }
374
370
  }
371
+ /** Ensure extensions are only requested once */
372
+ getExtension(name) {
373
+ getWebGLExtension(this.gl, name, this._extensions);
374
+ return this._extensions;
375
+ }
375
376
  }
376
377
  /** Check if supplied parameter is a WebGL2RenderingContext */
377
378
  function isWebGL(gl) {
@@ -1 +1 @@
1
- {"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,qBAAa,QAAS,YAAW,cAAc;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB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lB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
@@ -1,12 +1,13 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { assert, checkProps } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
- import { getTypedArrayFromGLType } from './typed-array-utils';
6
+ import { getTypedArrayFromGLType } from "./typed-array-utils.js";
6
7
  const DEFAULT_ACCESSOR_VALUES = {
7
8
  offset: 0,
8
9
  stride: 0,
9
- type: GL.FLOAT,
10
+ type: 5126,
10
11
  size: 1,
11
12
  divisor: 0,
12
13
  normalized: false,
@@ -31,14 +32,14 @@ export class Accessor {
31
32
  static getBytesPerElement(accessor) {
32
33
  // TODO: using `FLOAT` when type is not specified,
33
34
  // ensure this assumption is valid or force API to specify type.
34
- const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);
35
+ const ArrayType = getTypedArrayFromGLType(accessor.type || 5126);
35
36
  return ArrayType.BYTES_PER_ELEMENT;
36
37
  }
37
38
  static getBytesPerVertex(accessor) {
38
39
  assert(accessor.size);
39
40
  // TODO: using `FLOAT` when type is not specified,
40
41
  // ensure this assumption is valid or force API to specify type.
41
- const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);
42
+ const ArrayType = getTypedArrayFromGLType(accessor.type || 5126);
42
43
  return ArrayType.BYTES_PER_ELEMENT * accessor.size;
43
44
  }
44
45
  // Combines (merges) a list of accessors. On top of default values
@@ -49,7 +50,7 @@ export class Accessor {
49
50
  return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values
50
51
  }
51
52
  constructor(...accessors) {
52
- accessors.forEach((accessor) => this._assign(accessor)); // Merge in sequence
53
+ accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence
53
54
  Object.freeze(this);
54
55
  }
55
56
  toString() {
@@ -70,7 +71,7 @@ export class Accessor {
70
71
  if (props.type !== undefined) {
71
72
  this.type = props.type;
72
73
  // Auto-deduce integer type?
73
- if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {
74
+ if (props.type === 5124 || props.type === 5125) {
74
75
  this.integer = true;
75
76
  }
76
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/classic/clear.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,eAAe,CAAC;AAiB1D;;;GAGG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAC,GAC7E,IAAI,CAsCN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,QAsCnF"}
1
+ {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/classic/clear.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,eAAe,CAAC;AAiB1D;;;GAGG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAC,GAC7E,IAAI,CAsCN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,QA2CnF"}
@@ -1,7 +1,8 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { assert } from '@luma.gl/core';
4
- import { withGLParameters } from '../context/state-tracker/with-parameters';
5
+ import { withGLParameters } from "../context/state-tracker/with-parameters.js";
5
6
  // Should collapse during minification
6
7
  const GL_DEPTH_BUFFER_BIT = 0x00000100;
7
8
  const GL_STENCIL_BUFFER_BIT = 0x00000400;
@@ -43,8 +44,8 @@ export function clear(device, options) {
43
44
  }
44
45
  assert(clearFlags !== 0, ERR_ARGUMENTS);
45
46
  // Temporarily set any clear "colors" and call clear
46
- withGLParameters(device, parameters, () => {
47
- const gl = device.gl;
47
+ const gl = device.gl;
48
+ withGLParameters(gl, parameters, () => {
48
49
  gl.clear(clearFlags);
49
50
  });
50
51
  }
@@ -1,6 +1,6 @@
1
1
  import { Buffer, Texture, Framebuffer, FramebufferProps } from '@luma.gl/core';
2
2
  import { GL } from '@luma.gl/constants';
3
- import { WEBGLBuffer } from '../adapter/resources/webgl-buffer';
3
+ import { WEBGLBuffer } from "../adapter/resources/webgl-buffer.js";
4
4
  /**
5
5
  * Copies data from a type or a Texture object into ArrayBuffer object.
6
6
  * App can provide targetPixelArray or have it auto allocated by this method
@@ -1 +1 @@
1
- {"version":3,"file":"copy-and-blit.d.ts","sourceRoot":"","sources":["../../src/classic/copy-and-blit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,MAAM,EAAE,OAAO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,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,WAAW,CA+Cb;AAED;;;GAGG;AAEH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,GAAG,OAAO,EAC7B,MAAM,EAAE,OAAO,GAAG,EAAE,EACpB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CA+FT;AAYD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAUrF"}
@@ -1,9 +1,10 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { assert, Texture, Framebuffer } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
- import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from './typed-array-utils';
6
- import { glFormatToComponents, glTypeToBytes } from './format-utils';
6
+ import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
7
+ import { glFormatToComponents, glTypeToBytes } from "./format-utils.js";
7
8
  /**
8
9
  * Copies data from a type or a Texture object into ArrayBuffer object.
9
10
  * App can provide targetPixelArray or have it auto allocated by this method
@@ -16,7 +17,7 @@ import { glFormatToComponents, glTypeToBytes } from './format-utils';
16
17
  * @returns pixel array,
17
18
  */
18
19
  export function readPixelsToArray(source, options) {
19
- const { sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, sourceAttachment = GL.COLOR_ATTACHMENT0 // TODO - support gl.readBuffer
20
+ const { sourceX = 0, sourceY = 0, sourceFormat = 6408, sourceAttachment = 36064 // TODO - support gl.readBuffer
20
21
  } = options || {};
21
22
  let { target = null,
22
23
  // following parameters are auto deduced if not provided
@@ -30,21 +31,20 @@ export function readPixelsToArray(source, options) {
30
31
  // if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {
31
32
  // sourceAttachment = GL.FRONT;
32
33
  // }
33
- const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;
34
+ const attachment = sourceAttachment - 36064;
34
35
  // assert(attachments[sourceAttachment]);
35
36
  // Deduce the type from color attachment if not provided.
36
37
  sourceType =
37
38
  sourceType ||
38
- framebuffer.colorAttachments[attachment]?.type ||
39
- GL.UNSIGNED_BYTE;
39
+ framebuffer.colorAttachments[attachment]?.texture?.type || 5121;
40
40
  // Deduce type and allocated pixelArray if needed
41
41
  target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
42
42
  // Pixel array available, if necessary, deduce type from it.
43
43
  sourceType = sourceType || getGLTypeFromTypedArray(target);
44
- const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
44
+ const prevHandle = gl.bindFramebuffer(36160, handle);
45
45
  gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
46
46
  // @ts-expect-error
47
- gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
47
+ gl.bindFramebuffer(36160, prevHandle || null);
48
48
  if (deleteFramebuffer) {
49
49
  framebuffer.destroy();
50
50
  }
@@ -58,7 +58,7 @@ export function readPixelsToArray(source, options) {
58
58
  * @param options
59
59
  */
60
60
  export function readPixelsToBuffer(source, options) {
61
- const { target, sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0 } = options || {};
61
+ const { target, sourceX = 0, sourceY = 0, sourceFormat = 6408, targetByteOffset = 0 } = options || {};
62
62
  // following parameters are auto deduced if not provided
63
63
  let { sourceWidth, sourceHeight, sourceType } = options || {};
64
64
  const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
@@ -68,7 +68,7 @@ export function readPixelsToBuffer(source, options) {
68
68
  // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
69
69
  const webglFramebuffer = framebuffer;
70
70
  // deduce type if not available.
71
- sourceType = sourceType || GL.UNSIGNED_BYTE;
71
+ sourceType = sourceType || 5121;
72
72
  let webglBufferTarget = target;
73
73
  if (!webglBufferTarget) {
74
74
  // Create new buffer with enough size
@@ -101,7 +101,7 @@ export function readPixelsToBuffer(source, options) {
101
101
  export function copyToTexture(source, target, options) {
102
102
  const { sourceX = 0, sourceY = 0,
103
103
  // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
104
- targetMipmaplevel = 0, targetInternalFormat = GL.RGBA } = options || {};
104
+ targetMipmaplevel = 0, targetInternalFormat = 6408 } = options || {};
105
105
  let { targetX, targetY, targetZ, width, // defaults to target width
106
106
  height // defaults to target height
107
107
  } = options || {};
@@ -115,7 +115,7 @@ export function copyToTexture(source, target, options) {
115
115
  targetX = targetX || 0;
116
116
  targetY = targetY || 0;
117
117
  targetZ = targetZ || 0;
118
- const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
118
+ const prevHandle = device.gl.bindFramebuffer(36160, handle);
119
119
  // TODO - support gl.readBuffer (WebGL2 only)
120
120
  // const prevBuffer = gl.readBuffer(attachment);
121
121
  assert(target);
@@ -136,12 +136,12 @@ export function copyToTexture(source, target, options) {
136
136
  }
137
137
  else {
138
138
  switch (textureTarget) {
139
- case GL.TEXTURE_2D:
140
- case GL.TEXTURE_CUBE_MAP:
139
+ case 3553:
140
+ case 34067:
141
141
  device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);
142
142
  break;
143
- case GL.TEXTURE_2D_ARRAY:
144
- case GL.TEXTURE_3D:
143
+ case 35866:
144
+ case 32879:
145
145
  device.gl.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);
146
146
  break;
147
147
  default:
@@ -151,7 +151,7 @@ export function copyToTexture(source, target, options) {
151
151
  texture.unbind();
152
152
  }
153
153
  // @ts-expect-error
154
- device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
154
+ device.gl.bindFramebuffer(36160, prevHandle || null);
155
155
  if (deleteFramebuffer) {
156
156
  framebuffer.destroy();
157
157
  }
@@ -183,7 +183,7 @@ function getPixelArray(pixelArray, type, format, width, height) {
183
183
  return pixelArray;
184
184
  }
185
185
  // Allocate pixel array if not already available, using supplied type
186
- type = type || GL.UNSIGNED_BYTE;
186
+ type = type || 5121;
187
187
  const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
188
188
  const components = glFormatToComponents(format);
189
189
  // TODO - check for composite type (components = 1).
@@ -1 +1 @@
1
- {"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../src/classic/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAoB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAejC"}
1
+ {"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../src/classic/format-utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAoB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAejC"}
@@ -1,22 +1,23 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { assert } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
6
  // Returns number of components in a specific readPixels WebGL format
6
7
  export function glFormatToComponents(format) {
7
8
  switch (format) {
8
- case GL.ALPHA:
9
- case GL.R32F:
10
- case GL.RED:
9
+ case 6406:
10
+ case 33326:
11
+ case 6403:
11
12
  return 1;
12
- case GL.RG32F:
13
- case GL.RG:
13
+ case 33328:
14
+ case 33319:
14
15
  return 2;
15
- case GL.RGB:
16
- case GL.RGB32F:
16
+ case 6407:
17
+ case 34837:
17
18
  return 3;
18
- case GL.RGBA:
19
- case GL.RGBA32F:
19
+ case 6408:
20
+ case 34836:
20
21
  return 4;
21
22
  // TODO: Add support for additional WebGL2 formats
22
23
  default:
@@ -27,13 +28,13 @@ export function glFormatToComponents(format) {
27
28
  // Return byte count for given readPixels WebGL type
28
29
  export function glTypeToBytes(type) {
29
30
  switch (type) {
30
- case GL.UNSIGNED_BYTE:
31
+ case 5121:
31
32
  return 1;
32
- case GL.UNSIGNED_SHORT_5_6_5:
33
- case GL.UNSIGNED_SHORT_4_4_4_4:
34
- case GL.UNSIGNED_SHORT_5_5_5_1:
33
+ case 33635:
34
+ case 32819:
35
+ case 32820:
35
36
  return 2;
36
- case GL.FLOAT:
37
+ case 5126:
37
38
  return 4;
38
39
  // TODO: Add support for additional WebGL2 types
39
40
  default: