@luma.gl/webgl 9.0.0-alpha.25 → 9.0.0-alpha.26

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/index.cjs CHANGED
@@ -78,6 +78,7 @@ __export(src_exports, {
78
78
  assertWebGLContext: () => assertWebGLContext,
79
79
  clear: () => clear,
80
80
  convertGLToTextureFormat: () => convertGLToTextureFormat,
81
+ copyToTexture: () => copyToTexture,
81
82
  getParameters: () => getParameters,
82
83
  getProgramBindings: () => getProgramBindings,
83
84
  getShaderLayout: () => getShaderLayout,
@@ -124,11 +125,11 @@ function createHeadlessContext(options) {
124
125
  if (!headlessGL) {
125
126
  throw new Error(ERR_HEADLESSGL_LOAD);
126
127
  }
127
- const gl = headlessGL(width, height, options);
128
- if (!gl) {
128
+ const gl2 = headlessGL(width, height, options);
129
+ if (!gl2) {
129
130
  throw new Error(ERR_HEADLESSGL_FAILED);
130
131
  }
131
- return gl;
132
+ return gl2;
132
133
  }
133
134
 
134
135
  // src/adapter/webgl-device.ts
@@ -156,43 +157,43 @@ function synthesizeGLError(err, opt_msg) {
156
157
  error(opt_msg);
157
158
  }
158
159
  }
159
- function wrapGLError(gl) {
160
- const f = gl.getError;
161
- gl.getError = function getError() {
160
+ function wrapGLError(gl2) {
161
+ const f = gl2.getError;
162
+ gl2.getError = function getError() {
162
163
  let err;
163
164
  do {
164
- err = f.apply(gl);
165
- if (err !== gl.NO_ERROR) {
165
+ err = f.apply(gl2);
166
+ if (err !== gl2.NO_ERROR) {
166
167
  glErrorShadow[err] = true;
167
168
  }
168
- } while (err !== gl.NO_ERROR);
169
+ } while (err !== gl2.NO_ERROR);
169
170
  for (err in glErrorShadow) {
170
171
  if (glErrorShadow[err]) {
171
172
  delete glErrorShadow[err];
172
173
  return parseInt(err, 10);
173
174
  }
174
175
  }
175
- return gl.NO_ERROR;
176
+ return gl2.NO_ERROR;
176
177
  };
177
178
  }
178
179
  var WebGLVertexArrayObjectOES = function WebGLVertexArrayObjectOES2(ext) {
179
- const gl = ext.gl;
180
+ const gl2 = ext.gl;
180
181
  this.ext = ext;
181
182
  this.isAlive = true;
182
183
  this.hasBeenBound = false;
183
184
  this.elementArrayBuffer = null;
184
185
  this.attribs = new Array(ext.maxVertexAttribs);
185
186
  for (let n = 0; n < this.attribs.length; n++) {
186
- const attrib = new WebGLVertexArrayObjectOES2.VertexAttrib(gl);
187
+ const attrib = new WebGLVertexArrayObjectOES2.VertexAttrib(gl2);
187
188
  this.attribs[n] = attrib;
188
189
  }
189
190
  this.maxAttrib = 0;
190
191
  };
191
- WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl) {
192
+ WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl2) {
192
193
  this.enabled = false;
193
194
  this.buffer = null;
194
195
  this.size = 4;
195
- this.type = gl.FLOAT;
196
+ this.type = gl2.FLOAT;
196
197
  this.normalized = false;
197
198
  this.stride = 16;
198
199
  this.offset = 0;
@@ -202,19 +203,19 @@ WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl) {
202
203
  WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache = function recache() {
203
204
  this.cached = [this.size, this.type, this.normalized, this.stride, this.offset].join(":");
204
205
  };
205
- var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
206
+ var OESVertexArrayObject = function OESVertexArrayObject2(gl2) {
206
207
  const self = this;
207
- this.gl = gl;
208
- wrapGLError(gl);
208
+ this.gl = gl2;
209
+ wrapGLError(gl2);
209
210
  const original = this.original = {
210
- getParameter: gl.getParameter,
211
- enableVertexAttribArray: gl.enableVertexAttribArray,
212
- disableVertexAttribArray: gl.disableVertexAttribArray,
213
- bindBuffer: gl.bindBuffer,
214
- getVertexAttrib: gl.getVertexAttrib,
215
- vertexAttribPointer: gl.vertexAttribPointer
211
+ getParameter: gl2.getParameter,
212
+ enableVertexAttribArray: gl2.enableVertexAttribArray,
213
+ disableVertexAttribArray: gl2.disableVertexAttribArray,
214
+ bindBuffer: gl2.bindBuffer,
215
+ getVertexAttrib: gl2.getVertexAttrib,
216
+ vertexAttribPointer: gl2.vertexAttribPointer
216
217
  };
217
- gl.getParameter = function getParameter(pname) {
218
+ gl2.getParameter = function getParameter(pname) {
218
219
  if (pname === self.VERTEX_ARRAY_BINDING_OES) {
219
220
  if (self.currentVertexArrayObject === self.defaultVertexArrayObject) {
220
221
  return null;
@@ -223,53 +224,53 @@ var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
223
224
  }
224
225
  return original.getParameter.apply(this, arguments);
225
226
  };
226
- gl.enableVertexAttribArray = function enableVertexAttribArray(index) {
227
+ gl2.enableVertexAttribArray = function enableVertexAttribArray(index) {
227
228
  const vao = self.currentVertexArrayObject;
228
229
  vao.maxAttrib = Math.max(vao.maxAttrib, index);
229
230
  const attrib = vao.attribs[index];
230
231
  attrib.enabled = true;
231
232
  return original.enableVertexAttribArray.apply(this, arguments);
232
233
  };
233
- gl.disableVertexAttribArray = function disableVertexAttribArray(index) {
234
+ gl2.disableVertexAttribArray = function disableVertexAttribArray(index) {
234
235
  const vao = self.currentVertexArrayObject;
235
236
  vao.maxAttrib = Math.max(vao.maxAttrib, index);
236
237
  const attrib = vao.attribs[index];
237
238
  attrib.enabled = false;
238
239
  return original.disableVertexAttribArray.apply(this, arguments);
239
240
  };
240
- gl.bindBuffer = function bindBuffer2(target, buffer) {
241
+ gl2.bindBuffer = function bindBuffer2(target, buffer) {
241
242
  switch (target) {
242
- case gl.ARRAY_BUFFER:
243
+ case gl2.ARRAY_BUFFER:
243
244
  self.currentArrayBuffer = buffer;
244
245
  break;
245
- case gl.ELEMENT_ARRAY_BUFFER:
246
+ case gl2.ELEMENT_ARRAY_BUFFER:
246
247
  self.currentVertexArrayObject.elementArrayBuffer = buffer;
247
248
  break;
248
249
  default:
249
250
  }
250
251
  return original.bindBuffer.apply(this, arguments);
251
252
  };
252
- gl.getVertexAttrib = function getVertexAttrib(index, pname) {
253
+ gl2.getVertexAttrib = function getVertexAttrib(index, pname) {
253
254
  const vao = self.currentVertexArrayObject;
254
255
  const attrib = vao.attribs[index];
255
256
  switch (pname) {
256
- case gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
257
+ case gl2.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
257
258
  return attrib.buffer;
258
- case gl.VERTEX_ATTRIB_ARRAY_ENABLED:
259
+ case gl2.VERTEX_ATTRIB_ARRAY_ENABLED:
259
260
  return attrib.enabled;
260
- case gl.VERTEX_ATTRIB_ARRAY_SIZE:
261
+ case gl2.VERTEX_ATTRIB_ARRAY_SIZE:
261
262
  return attrib.size;
262
- case gl.VERTEX_ATTRIB_ARRAY_STRIDE:
263
+ case gl2.VERTEX_ATTRIB_ARRAY_STRIDE:
263
264
  return attrib.stride;
264
- case gl.VERTEX_ATTRIB_ARRAY_TYPE:
265
+ case gl2.VERTEX_ATTRIB_ARRAY_TYPE:
265
266
  return attrib.type;
266
- case gl.VERTEX_ATTRIB_ARRAY_NORMALIZED:
267
+ case gl2.VERTEX_ATTRIB_ARRAY_NORMALIZED:
267
268
  return attrib.normalized;
268
269
  default:
269
270
  return original.getVertexAttrib.apply(this, arguments);
270
271
  }
271
272
  };
272
- gl.vertexAttribPointer = function vertexAttribPointer(indx, size, type, normalized, stride, offset) {
273
+ gl2.vertexAttribPointer = function vertexAttribPointer(indx, size, type, normalized, stride, offset) {
273
274
  const vao = self.currentVertexArrayObject;
274
275
  vao.maxAttrib = Math.max(vao.maxAttrib, indx);
275
276
  const attrib = vao.attribs[indx];
@@ -282,11 +283,11 @@ var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
282
283
  attrib.recache();
283
284
  return original.vertexAttribPointer.apply(this, arguments);
284
285
  };
285
- if (gl.instrumentExtension) {
286
- gl.instrumentExtension(this, "OES_vertex_array_object");
286
+ if (gl2.instrumentExtension) {
287
+ gl2.instrumentExtension(this, "OES_vertex_array_object");
287
288
  }
288
- if (gl.canvas) {
289
- gl.canvas.addEventListener(
289
+ if (gl2.canvas) {
290
+ gl2.canvas.addEventListener(
290
291
  "webglcontextrestored",
291
292
  () => {
292
293
  log("OESVertexArrayObject emulation library context restored");
@@ -305,8 +306,8 @@ OESVertexArrayObject.prototype.reset_ = function reset_() {
305
306
  this.vertexArrayObjects.isAlive = false;
306
307
  }
307
308
  }
308
- const gl = this.gl;
309
- this.maxVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
309
+ const gl2 = this.gl;
310
+ this.maxVertexAttribs = gl2.getParameter(gl2.MAX_VERTEX_ATTRIBS);
310
311
  this.defaultVertexArrayObject = new WebGLVertexArrayObjectOES(this);
311
312
  this.currentVertexArrayObject = null;
312
313
  this.currentArrayBuffer = null;
@@ -334,10 +335,10 @@ OESVertexArrayObject.prototype.isVertexArrayOES = function isVertexArrayOES(arra
334
335
  return false;
335
336
  };
336
337
  OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(arrayObject) {
337
- const gl = this.gl;
338
+ const gl2 = this.gl;
338
339
  if (arrayObject && !arrayObject.isAlive) {
339
340
  synthesizeGLError(
340
- gl.INVALID_OPERATION,
341
+ gl2.INVALID_OPERATION,
341
342
  "bindVertexArrayOES: attempt to bind deleted arrayObject"
342
343
  );
343
344
  return;
@@ -351,7 +352,7 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
351
352
  return;
352
353
  }
353
354
  if (!oldVAO || newVAO.elementArrayBuffer !== oldVAO.elementArrayBuffer) {
354
- original.bindBuffer.call(gl, gl.ELEMENT_ARRAY_BUFFER, newVAO.elementArrayBuffer);
355
+ original.bindBuffer.call(gl2, gl2.ELEMENT_ARRAY_BUFFER, newVAO.elementArrayBuffer);
355
356
  }
356
357
  let currentBinding = this.currentArrayBuffer;
357
358
  const maxAttrib = Math.max(oldVAO ? oldVAO.maxAttrib : 0, newVAO.maxAttrib);
@@ -360,23 +361,23 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
360
361
  const oldAttrib = oldVAO ? oldVAO.attribs[n] : null;
361
362
  if (!oldVAO || attrib.enabled !== oldAttrib.enabled) {
362
363
  if (attrib.enabled) {
363
- original.enableVertexAttribArray.call(gl, n);
364
+ original.enableVertexAttribArray.call(gl2, n);
364
365
  } else {
365
- original.disableVertexAttribArray.call(gl, n);
366
+ original.disableVertexAttribArray.call(gl2, n);
366
367
  }
367
368
  }
368
369
  if (attrib.enabled) {
369
370
  let bufferChanged = false;
370
371
  if (!oldVAO || attrib.buffer !== oldAttrib.buffer) {
371
372
  if (currentBinding !== attrib.buffer) {
372
- original.bindBuffer.call(gl, gl.ARRAY_BUFFER, attrib.buffer);
373
+ original.bindBuffer.call(gl2, gl2.ARRAY_BUFFER, attrib.buffer);
373
374
  currentBinding = attrib.buffer;
374
375
  }
375
376
  bufferChanged = true;
376
377
  }
377
378
  if (bufferChanged || attrib.cached !== oldAttrib.cached) {
378
379
  original.vertexAttribPointer.call(
379
- gl,
380
+ gl2,
380
381
  n,
381
382
  attrib.size,
382
383
  attrib.type,
@@ -388,23 +389,23 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
388
389
  }
389
390
  }
390
391
  if (this.currentArrayBuffer !== currentBinding) {
391
- original.bindBuffer.call(gl, gl.ARRAY_BUFFER, this.currentArrayBuffer);
392
+ original.bindBuffer.call(gl2, gl2.ARRAY_BUFFER, this.currentArrayBuffer);
392
393
  }
393
394
  };
394
- function polyfillVertexArrayObject(gl) {
395
- if (typeof gl.createVertexArray === "function") {
395
+ function polyfillVertexArrayObject(gl2) {
396
+ if (typeof gl2.createVertexArray === "function") {
396
397
  return;
397
398
  }
398
- const original_getSupportedExtensions = gl.getSupportedExtensions;
399
- gl.getSupportedExtensions = function getSupportedExtensions() {
399
+ const original_getSupportedExtensions = gl2.getSupportedExtensions;
400
+ gl2.getSupportedExtensions = function getSupportedExtensions() {
400
401
  const list = original_getSupportedExtensions.call(this) || [];
401
402
  if (list.indexOf("OES_vertex_array_object") < 0) {
402
403
  list.push("OES_vertex_array_object");
403
404
  }
404
405
  return list;
405
406
  };
406
- const original_getExtension = gl.getExtension;
407
- gl.getExtension = function getExtension(name) {
407
+ const original_getExtension = gl2.getExtension;
408
+ gl2.getExtension = function getExtension(name) {
408
409
  const ext = original_getExtension.call(this, name);
409
410
  if (ext) {
410
411
  return ext;
@@ -412,7 +413,7 @@ function polyfillVertexArrayObject(gl) {
412
413
  if (name !== "OES_vertex_array_object") {
413
414
  return null;
414
415
  }
415
- if (!gl.__OESVertexArrayObject) {
416
+ if (!gl2.__OESVertexArrayObject) {
416
417
  this.__OESVertexArrayObject = new OESVertexArrayObject(this);
417
418
  }
418
419
  return this.__OESVertexArrayObject;
@@ -427,31 +428,31 @@ var import_constants2 = require("@luma.gl/constants");
427
428
  var import_api = require("@luma.gl/api");
428
429
  var ERR_CONTEXT = "Invalid WebGLRenderingContext";
429
430
  var ERR_WEBGL2 = "Requires WebGL2";
430
- function isWebGL(gl) {
431
- if (typeof WebGLRenderingContext !== "undefined" && gl instanceof WebGLRenderingContext) {
431
+ function isWebGL(gl2) {
432
+ if (typeof WebGLRenderingContext !== "undefined" && gl2 instanceof WebGLRenderingContext) {
432
433
  return true;
433
434
  }
434
- if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
435
+ if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
435
436
  return true;
436
437
  }
437
- return Boolean(gl && Number.isFinite(gl._version));
438
+ return Boolean(gl2 && Number.isFinite(gl2._version));
438
439
  }
439
- function isWebGL2(gl) {
440
- if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
440
+ function isWebGL2(gl2) {
441
+ if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
441
442
  return true;
442
443
  }
443
- return Boolean(gl && gl._version === 2);
444
+ return Boolean(gl2 && gl2._version === 2);
444
445
  }
445
- function getWebGL2Context(gl) {
446
- return isWebGL2(gl) ? gl : null;
446
+ function getWebGL2Context(gl2) {
447
+ return isWebGL2(gl2) ? gl2 : null;
447
448
  }
448
- function assertWebGLContext(gl) {
449
- (0, import_api.assert)(isWebGL(gl), ERR_CONTEXT);
450
- return gl;
449
+ function assertWebGLContext(gl2) {
450
+ (0, import_api.assert)(isWebGL(gl2), ERR_CONTEXT);
451
+ return gl2;
451
452
  }
452
- function assertWebGL2Context(gl) {
453
- (0, import_api.assert)(isWebGL2(gl), ERR_WEBGL2);
454
- return gl;
453
+ function assertWebGL2Context(gl2) {
454
+ (0, import_api.assert)(isWebGL2(gl2), ERR_WEBGL2);
455
+ return gl2;
455
456
  }
456
457
 
457
458
  // src/context/polyfill/get-parameter-polyfill.ts
@@ -468,40 +469,40 @@ var GL_GPU_DISJOINT_EXT = 36795;
468
469
  var GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 34047;
469
470
  var GL_UNMASKED_VENDOR_WEBGL = 37445;
470
471
  var GL_UNMASKED_RENDERER_WEBGL = 37446;
471
- var getWebGL2ValueOrZero = (gl) => !isWebGL2(gl) ? 0 : void 0;
472
+ var getWebGL2ValueOrZero = (gl2) => !isWebGL2(gl2) ? 0 : void 0;
472
473
  var WEBGL_PARAMETERS = {
473
- [import_constants.GL.READ_BUFFER]: (gl) => !isWebGL2(gl) ? import_constants.GL.COLOR_ATTACHMENT0 : void 0,
474
+ [import_constants.GL.READ_BUFFER]: (gl2) => !isWebGL2(gl2) ? import_constants.GL.COLOR_ATTACHMENT0 : void 0,
474
475
  // WebGL2 context parameters
475
- [GL_FRAGMENT_SHADER_DERIVATIVE_HINT]: (gl) => !isWebGL2(gl) ? GL_DONT_CARE : void 0,
476
+ [GL_FRAGMENT_SHADER_DERIVATIVE_HINT]: (gl2) => !isWebGL2(gl2) ? GL_DONT_CARE : void 0,
476
477
  [import_constants.GL.RASTERIZER_DISCARD]: getWebGL2ValueOrZero,
477
478
  [import_constants.GL.SAMPLES]: getWebGL2ValueOrZero,
478
479
  // WebGL2 extension context parameters
479
- [GL_GPU_DISJOINT_EXT]: (gl, getParameter) => {
480
- const ext = isWebGL2(gl) ? gl.getExtension(EXT_disjoint_timer_query_webgl2) : gl.getExtension(EXT_disjoint_timer_query);
480
+ [GL_GPU_DISJOINT_EXT]: (gl2, getParameter) => {
481
+ const ext = isWebGL2(gl2) ? gl2.getExtension(EXT_disjoint_timer_query_webgl2) : gl2.getExtension(EXT_disjoint_timer_query);
481
482
  return ext && ext.GPU_DISJOINT_EXT ? getParameter(ext.GPU_DISJOINT_EXT) : 0;
482
483
  },
483
484
  // Extension fixed values
484
- [GL_UNMASKED_VENDOR_WEBGL]: (gl, getParameter) => {
485
- const ext = gl.getExtension(WEBGL_debug_renderer_info);
485
+ [GL_UNMASKED_VENDOR_WEBGL]: (gl2, getParameter) => {
486
+ const ext = gl2.getExtension(WEBGL_debug_renderer_info);
486
487
  return getParameter(ext && ext.UNMASKED_VENDOR_WEBGL || import_constants.GL.VENDOR);
487
488
  },
488
- [GL_UNMASKED_RENDERER_WEBGL]: (gl, getParameter) => {
489
- const ext = gl.getExtension(WEBGL_debug_renderer_info);
489
+ [GL_UNMASKED_RENDERER_WEBGL]: (gl2, getParameter) => {
490
+ const ext = gl2.getExtension(WEBGL_debug_renderer_info);
490
491
  return getParameter(ext && ext.UNMASKED_RENDERER_WEBGL || import_constants.GL.RENDERER);
491
492
  },
492
493
  // Extension LIMITS
493
- [GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]: (gl, getParameter) => {
494
+ [GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]: (gl2, getParameter) => {
494
495
  var _a, _b;
495
- const ext = ((_b = (_a = gl.luma) == null ? void 0 : _a.extensions) == null ? void 0 : _b[EXT_texture_filter_anisotropic]) || gl.getExtension("EXT_texture_filter_anisotropic");
496
+ const ext = ((_b = (_a = gl2.luma) == null ? void 0 : _a.extensions) == null ? void 0 : _b[EXT_texture_filter_anisotropic]) || gl2.getExtension("EXT_texture_filter_anisotropic");
496
497
  return ext ? getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 1;
497
498
  },
498
499
  // WebGL2 Limits
499
500
  [import_constants.GL.MAX_3D_TEXTURE_SIZE]: getWebGL2ValueOrZero,
500
501
  [import_constants.GL.MAX_ARRAY_TEXTURE_LAYERS]: getWebGL2ValueOrZero,
501
502
  [import_constants.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: getWebGL2ValueOrZero,
502
- [import_constants.GL.MAX_COLOR_ATTACHMENTS]: (gl, getParameter) => {
503
- if (!isWebGL2(gl)) {
504
- const ext = gl.getExtension(WEBGL_draw_buffers);
503
+ [import_constants.GL.MAX_COLOR_ATTACHMENTS]: (gl2, getParameter) => {
504
+ if (!isWebGL2(gl2)) {
505
+ const ext = gl2.getExtension(WEBGL_draw_buffers);
505
506
  return ext ? getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) : 0;
506
507
  }
507
508
  return void 0;
@@ -509,24 +510,24 @@ var WEBGL_PARAMETERS = {
509
510
  [import_constants.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
510
511
  [import_constants.GL.MAX_COMBINED_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
511
512
  [import_constants.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
512
- [import_constants.GL.MAX_DRAW_BUFFERS]: (gl) => {
513
- if (!isWebGL2(gl)) {
514
- const ext = gl.getExtension(WEBGL_draw_buffers);
513
+ [import_constants.GL.MAX_DRAW_BUFFERS]: (gl2) => {
514
+ if (!isWebGL2(gl2)) {
515
+ const ext = gl2.getExtension(WEBGL_draw_buffers);
515
516
  return ext ? ext.MAX_DRAW_BUFFERS_WEBGL : 0;
516
517
  }
517
518
  return void 0;
518
519
  },
519
520
  [import_constants.GL.MAX_ELEMENT_INDEX]: (
520
521
  // Guess: per webglstats.com 99.6% of webgl2 supports 2147483647
521
- (gl) => gl.getExtension(OES_element_index) ? 2147483647 : 65535
522
+ (gl2) => gl2.getExtension(OES_element_index) ? 2147483647 : 65535
522
523
  ),
523
524
  [import_constants.GL.MAX_ELEMENTS_INDICES]: (
524
525
  // Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
525
- (gl) => gl.getExtension(OES_element_index) ? 16777216 : 65535
526
+ (gl2) => gl2.getExtension(OES_element_index) ? 16777216 : 65535
526
527
  ),
527
528
  [import_constants.GL.MAX_ELEMENTS_VERTICES]: (
528
529
  // Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
529
- (gl) => 16777216
530
+ (gl2) => 16777216
530
531
  ),
531
532
  [import_constants.GL.MAX_FRAGMENT_INPUT_COMPONENTS]: getWebGL2ValueOrZero,
532
533
  [import_constants.GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
@@ -547,24 +548,24 @@ var WEBGL_PARAMETERS = {
547
548
  [import_constants.GL.MAX_PROGRAM_TEXEL_OFFSET]: getWebGL2ValueOrZero,
548
549
  [import_constants.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: getWebGL2ValueOrZero
549
550
  };
550
- function getParameterPolyfill(gl, originalGetParameter, pname) {
551
+ function getParameterPolyfill(gl2, originalGetParameter, pname) {
551
552
  const limit = WEBGL_PARAMETERS[pname];
552
- const value = typeof limit === "function" ? limit(gl, originalGetParameter, pname) : limit;
553
+ const value = typeof limit === "function" ? limit(gl2, originalGetParameter, pname) : limit;
553
554
  const result = value !== void 0 ? value : originalGetParameter(pname);
554
555
  return result;
555
556
  }
556
557
 
557
558
  // src/context/polyfill/context-data.ts
558
- function getContextData(gl) {
559
- const luma = gl.luma;
559
+ function getContextData(gl2) {
560
+ const luma = gl2.luma;
560
561
  if (!luma) {
561
562
  const contextState = {
562
563
  _polyfilled: false,
563
564
  _extensions: {}
564
565
  };
565
- gl.luma = contextState;
566
+ gl2.luma = contextState;
566
567
  }
567
- return gl.luma;
568
+ return gl2.luma;
568
569
  }
569
570
 
570
571
  // src/context/polyfill/polyfill-table.ts
@@ -574,10 +575,10 @@ var WEBGL_draw_buffers2 = "WEBGL_draw_buffers";
574
575
  var EXT_disjoint_timer_query2 = "EXT_disjoint_timer_query";
575
576
  var EXT_texture_filter_anisotropic2 = "EXT_texture_filter_anisotropic";
576
577
  var ERR_VAO_NOT_SUPPORTED = "VertexArray requires WebGL2 or OES_vertex_array_object extension";
577
- function getExtensionData(gl, extension) {
578
+ function getExtensionData(gl2, extension) {
578
579
  return {
579
- webgl2: isWebGL2(gl),
580
- ext: gl.getExtension(extension)
580
+ webgl2: isWebGL2(gl2),
581
+ ext: gl2.getExtension(extension)
581
582
  };
582
583
  }
583
584
  var WEBGL2_CONTEXT_POLYFILLS = {
@@ -644,15 +645,15 @@ var WEBGL2_CONTEXT_POLYFILLS = {
644
645
  };
645
646
  var WEBGL2_CONTEXT_OVERRIDES = {
646
647
  // Ensure readBuffer is a no-op
647
- readBuffer: (gl, originalFunc, attachment) => {
648
- if (isWebGL2(gl)) {
648
+ readBuffer: (gl2, originalFunc, attachment) => {
649
+ if (isWebGL2(gl2)) {
649
650
  originalFunc(attachment);
650
651
  } else {
651
652
  }
652
653
  },
653
654
  // Override for getVertexAttrib that returns sane values for non-WebGL1 constants
654
- getVertexAttrib: (gl, originalFunc, location, pname) => {
655
- const { webgl2, ext } = getExtensionData(gl, ANGLE_instanced_arrays);
655
+ getVertexAttrib: (gl2, originalFunc, location, pname) => {
656
+ const { webgl2, ext } = getExtensionData(gl2, ANGLE_instanced_arrays);
656
657
  let result;
657
658
  switch (pname) {
658
659
  case import_constants2.GL.VERTEX_ATTRIB_ARRAY_INTEGER:
@@ -666,8 +667,8 @@ var WEBGL2_CONTEXT_OVERRIDES = {
666
667
  return result !== void 0 ? result : originalFunc(location, pname);
667
668
  },
668
669
  // Handle transform feedback and uniform block queries in WebGL1
669
- getProgramParameter: (gl, originalFunc, program, pname) => {
670
- if (!isWebGL2(gl)) {
670
+ getProgramParameter: (gl2, originalFunc, program, pname) => {
671
+ if (!isWebGL2(gl2)) {
671
672
  switch (pname) {
672
673
  case import_constants2.GL.TRANSFORM_FEEDBACK_BUFFER_MODE:
673
674
  return import_constants2.GL.SEPARATE_ATTRIBS;
@@ -680,21 +681,21 @@ var WEBGL2_CONTEXT_OVERRIDES = {
680
681
  }
681
682
  return originalFunc(program, pname);
682
683
  },
683
- getInternalformatParameter: (gl, originalFunc, target, format, pname) => {
684
- if (!isWebGL2(gl)) {
684
+ getInternalformatParameter: (gl2, originalFunc, target, format, pname) => {
685
+ if (!isWebGL2(gl2)) {
685
686
  switch (pname) {
686
687
  case import_constants2.GL.SAMPLES:
687
688
  return new Int32Array([0]);
688
689
  default:
689
690
  }
690
691
  }
691
- const gl2 = gl;
692
- return gl2.getInternalformatParameter(target, format, pname);
692
+ const gl22 = gl2;
693
+ return gl22.getInternalformatParameter(target, format, pname);
693
694
  },
694
- getTexParameter(gl, originalFunc, target, pname) {
695
+ getTexParameter(gl2, originalFunc, target, pname) {
695
696
  switch (pname) {
696
697
  case import_constants2.GL.TEXTURE_MAX_ANISOTROPY_EXT:
697
- const contextData = getContextData(gl);
698
+ const contextData = getContextData(gl2);
698
699
  const { _extensions } = contextData;
699
700
  const ext = _extensions[EXT_texture_filter_anisotropic2];
700
701
  pname = ext && ext.TEXTURE_MAX_ANISOTROPY_EXT || import_constants2.GL.TEXTURE_MAX_ANISOTROPY_EXT;
@@ -704,50 +705,50 @@ var WEBGL2_CONTEXT_OVERRIDES = {
704
705
  return originalFunc(target, pname);
705
706
  },
706
707
  getParameter: getParameterPolyfill,
707
- hint(gl, originalFunc, pname, value) {
708
+ hint(gl2, originalFunc, pname, value) {
708
709
  return originalFunc(pname, value);
709
710
  }
710
711
  };
711
712
 
712
713
  // src/context/polyfill/polyfill-context.ts
713
- function polyfillContext(gl) {
714
- const contextState = getContextData(gl);
714
+ function polyfillContext(gl2) {
715
+ const contextState = getContextData(gl2);
715
716
  if (!contextState._polyfilled) {
716
- polyfillVertexArrayObject(gl);
717
- initializeExtensions(gl);
718
- installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);
719
- installOverrides(gl, { target: contextState, target2: gl });
717
+ polyfillVertexArrayObject(gl2);
718
+ initializeExtensions(gl2);
719
+ installPolyfills(gl2, WEBGL2_CONTEXT_POLYFILLS);
720
+ installOverrides(gl2, { target: contextState, target2: gl2 });
720
721
  contextState._polyfilled = true;
721
722
  }
722
- return gl;
723
+ return gl2;
723
724
  }
724
- function initializeExtensions(gl) {
725
- const contextState = getContextData(gl);
726
- const EXTENSIONS = gl.getSupportedExtensions() || [];
725
+ function initializeExtensions(gl2) {
726
+ const contextState = getContextData(gl2);
727
+ const EXTENSIONS = gl2.getSupportedExtensions() || [];
727
728
  for (const extensionName of EXTENSIONS) {
728
- const extension = gl.getExtension(extensionName);
729
+ const extension = gl2.getExtension(extensionName);
729
730
  contextState._extensions[extensionName] = extension;
730
731
  }
731
732
  }
732
- function installPolyfills(gl, polyfills) {
733
- const contextState = getContextData(gl);
733
+ function installPolyfills(gl2, polyfills) {
734
+ const contextState = getContextData(gl2);
734
735
  for (const extension of Object.getOwnPropertyNames(polyfills)) {
735
736
  if (extension !== "overrides") {
736
- polyfillExtension(gl, { extension, target: contextState, target2: gl });
737
+ polyfillExtension(gl2, { extension, target: contextState, target2: gl2 });
737
738
  }
738
739
  }
739
740
  }
740
- function polyfillExtension(gl, { extension, target, target2 }) {
741
+ function polyfillExtension(gl2, { extension, target, target2 }) {
741
742
  const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];
742
743
  (0, import_api3.assert)(defaults);
743
744
  const { meta = {} } = defaults;
744
745
  const { suffix = "" } = meta;
745
- const ext = gl.getExtension(extension);
746
+ const ext = gl2.getExtension(extension);
746
747
  for (const key of Object.keys(defaults)) {
747
748
  const extKey = `${key}${suffix}`;
748
749
  let polyfill = null;
749
750
  if (key === "meta") {
750
- } else if (typeof gl[key] === "function") {
751
+ } else if (typeof gl2[key] === "function") {
751
752
  } else if (ext && typeof ext[extKey] === "function") {
752
753
  polyfill = (...args) => ext[extKey](...args);
753
754
  } else if (typeof defaults[key] === "function") {
@@ -759,12 +760,12 @@ function polyfillExtension(gl, { extension, target, target2 }) {
759
760
  }
760
761
  }
761
762
  }
762
- function installOverrides(gl, { target, target2 }) {
763
+ function installOverrides(gl2, { target, target2 }) {
763
764
  Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {
764
765
  if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === "function") {
765
- const originalFunc = gl[key] ? gl[key].bind(gl) : () => {
766
+ const originalFunc = gl2[key] ? gl2[key].bind(gl2) : () => {
766
767
  };
767
- const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl, originalFunc);
768
+ const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl2, originalFunc);
768
769
  target[key] = polyfill;
769
770
  target2[key] = polyfill;
770
771
  }
@@ -859,19 +860,19 @@ var GL_PARAMETER_DEFAULTS = {
859
860
  [import_constants3.GL.UNPACK_SKIP_ROWS]: 0,
860
861
  [import_constants3.GL.UNPACK_SKIP_IMAGES]: 0
861
862
  };
862
- var enable = (gl, value, key) => value ? gl.enable(key) : gl.disable(key);
863
- var hint = (gl, value, key) => gl.hint(key, value);
864
- var pixelStorei = (gl, value, key) => gl.pixelStorei(key, value);
865
- var bindFramebuffer = (gl, value, key) => {
863
+ var enable = (gl2, value, key) => value ? gl2.enable(key) : gl2.disable(key);
864
+ var hint = (gl2, value, key) => gl2.hint(key, value);
865
+ var pixelStorei = (gl2, value, key) => gl2.pixelStorei(key, value);
866
+ var bindFramebuffer = (gl2, value, key) => {
866
867
  let target;
867
868
  if (key === import_constants3.GL.FRAMEBUFFER_BINDING) {
868
- target = isWebGL2(gl) ? import_constants3.GL.DRAW_FRAMEBUFFER : import_constants3.GL.FRAMEBUFFER;
869
+ target = isWebGL2(gl2) ? import_constants3.GL.DRAW_FRAMEBUFFER : import_constants3.GL.FRAMEBUFFER;
869
870
  } else {
870
871
  target = import_constants3.GL.READ_FRAMEBUFFER;
871
872
  }
872
- return gl.bindFramebuffer(target, value);
873
+ return gl2.bindFramebuffer(target, value);
873
874
  };
874
- var bindBuffer = (gl, value, key) => {
875
+ var bindBuffer = (gl2, value, key) => {
875
876
  const bindingMap = {
876
877
  [import_constants3.GL.ARRAY_BUFFER_BINDING]: import_constants3.GL.ARRAY_BUFFER,
877
878
  [import_constants3.GL.COPY_READ_BUFFER_BINDING]: import_constants3.GL.COPY_READ_BUFFER,
@@ -880,38 +881,38 @@ var bindBuffer = (gl, value, key) => {
880
881
  [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_UNPACK_BUFFER
881
882
  };
882
883
  const target = bindingMap[key];
883
- gl.bindBuffer(target, value);
884
+ gl2.bindBuffer(target, value);
884
885
  };
885
886
  function isArray(array) {
886
887
  return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
887
888
  }
888
889
  var GL_PARAMETER_SETTERS = {
889
890
  [import_constants3.GL.BLEND]: enable,
890
- [import_constants3.GL.BLEND_COLOR]: (gl, value) => gl.blendColor(...value),
891
+ [import_constants3.GL.BLEND_COLOR]: (gl2, value) => gl2.blendColor(...value),
891
892
  [import_constants3.GL.BLEND_EQUATION_RGB]: "blendEquation",
892
893
  [import_constants3.GL.BLEND_EQUATION_ALPHA]: "blendEquation",
893
894
  [import_constants3.GL.BLEND_SRC_RGB]: "blendFunc",
894
895
  [import_constants3.GL.BLEND_DST_RGB]: "blendFunc",
895
896
  [import_constants3.GL.BLEND_SRC_ALPHA]: "blendFunc",
896
897
  [import_constants3.GL.BLEND_DST_ALPHA]: "blendFunc",
897
- [import_constants3.GL.COLOR_CLEAR_VALUE]: (gl, value) => gl.clearColor(...value),
898
- [import_constants3.GL.COLOR_WRITEMASK]: (gl, value) => gl.colorMask(...value),
898
+ [import_constants3.GL.COLOR_CLEAR_VALUE]: (gl2, value) => gl2.clearColor(...value),
899
+ [import_constants3.GL.COLOR_WRITEMASK]: (gl2, value) => gl2.colorMask(...value),
899
900
  [import_constants3.GL.CULL_FACE]: enable,
900
- [import_constants3.GL.CULL_FACE_MODE]: (gl, value) => gl.cullFace(value),
901
+ [import_constants3.GL.CULL_FACE_MODE]: (gl2, value) => gl2.cullFace(value),
901
902
  [import_constants3.GL.DEPTH_TEST]: enable,
902
- [import_constants3.GL.DEPTH_CLEAR_VALUE]: (gl, value) => gl.clearDepth(value),
903
- [import_constants3.GL.DEPTH_FUNC]: (gl, value) => gl.depthFunc(value),
904
- [import_constants3.GL.DEPTH_RANGE]: (gl, value) => gl.depthRange(...value),
905
- [import_constants3.GL.DEPTH_WRITEMASK]: (gl, value) => gl.depthMask(value),
903
+ [import_constants3.GL.DEPTH_CLEAR_VALUE]: (gl2, value) => gl2.clearDepth(value),
904
+ [import_constants3.GL.DEPTH_FUNC]: (gl2, value) => gl2.depthFunc(value),
905
+ [import_constants3.GL.DEPTH_RANGE]: (gl2, value) => gl2.depthRange(...value),
906
+ [import_constants3.GL.DEPTH_WRITEMASK]: (gl2, value) => gl2.depthMask(value),
906
907
  [import_constants3.GL.DITHER]: enable,
907
908
  [import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,
908
- [import_constants3.GL.CURRENT_PROGRAM]: (gl, value) => gl.useProgram(value),
909
- [import_constants3.GL.RENDERBUFFER_BINDING]: (gl, value) => gl.bindRenderbuffer(import_constants3.GL.RENDERBUFFER, value),
910
- [import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: (gl, value) => {
909
+ [import_constants3.GL.CURRENT_PROGRAM]: (gl2, value) => gl2.useProgram(value),
910
+ [import_constants3.GL.RENDERBUFFER_BINDING]: (gl2, value) => gl2.bindRenderbuffer(import_constants3.GL.RENDERBUFFER, value),
911
+ [import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: (gl2, value) => {
911
912
  var _a;
912
- return (_a = gl.bindTransformFeedback) == null ? void 0 : _a.call(gl, import_constants3.GL.TRANSFORM_FEEDBACK, value);
913
+ return (_a = gl2.bindTransformFeedback) == null ? void 0 : _a.call(gl2, import_constants3.GL.TRANSFORM_FEEDBACK, value);
913
914
  },
914
- [import_constants3.GL.VERTEX_ARRAY_BINDING]: (gl, value) => gl.bindVertexArray(value),
915
+ [import_constants3.GL.VERTEX_ARRAY_BINDING]: (gl2, value) => gl2.bindVertexArray(value),
915
916
  // NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
916
917
  [import_constants3.GL.FRAMEBUFFER_BINDING]: bindFramebuffer,
917
918
  [import_constants3.GL.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,
@@ -921,9 +922,9 @@ var GL_PARAMETER_SETTERS = {
921
922
  [import_constants3.GL.COPY_WRITE_BUFFER_BINDING]: bindBuffer,
922
923
  [import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: bindBuffer,
923
924
  [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: bindBuffer,
924
- [import_constants3.GL.FRONT_FACE]: (gl, value) => gl.frontFace(value),
925
+ [import_constants3.GL.FRONT_FACE]: (gl2, value) => gl2.frontFace(value),
925
926
  [import_constants3.GL.GENERATE_MIPMAP_HINT]: hint,
926
- [import_constants3.GL.LINE_WIDTH]: (gl, value) => gl.lineWidth(value),
927
+ [import_constants3.GL.LINE_WIDTH]: (gl2, value) => gl2.lineWidth(value),
927
928
  [import_constants3.GL.POLYGON_OFFSET_FILL]: enable,
928
929
  [import_constants3.GL.POLYGON_OFFSET_FACTOR]: "polygonOffset",
929
930
  [import_constants3.GL.POLYGON_OFFSET_UNITS]: "polygonOffset",
@@ -933,11 +934,11 @@ var GL_PARAMETER_SETTERS = {
933
934
  [import_constants3.GL.SAMPLE_COVERAGE_VALUE]: "sampleCoverage",
934
935
  [import_constants3.GL.SAMPLE_COVERAGE_INVERT]: "sampleCoverage",
935
936
  [import_constants3.GL.SCISSOR_TEST]: enable,
936
- [import_constants3.GL.SCISSOR_BOX]: (gl, value) => gl.scissor(...value),
937
+ [import_constants3.GL.SCISSOR_BOX]: (gl2, value) => gl2.scissor(...value),
937
938
  [import_constants3.GL.STENCIL_TEST]: enable,
938
- [import_constants3.GL.STENCIL_CLEAR_VALUE]: (gl, value) => gl.clearStencil(value),
939
- [import_constants3.GL.STENCIL_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.GL.FRONT, value),
940
- [import_constants3.GL.STENCIL_BACK_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.GL.BACK, value),
939
+ [import_constants3.GL.STENCIL_CLEAR_VALUE]: (gl2, value) => gl2.clearStencil(value),
940
+ [import_constants3.GL.STENCIL_WRITEMASK]: (gl2, value) => gl2.stencilMaskSeparate(import_constants3.GL.FRONT, value),
941
+ [import_constants3.GL.STENCIL_BACK_WRITEMASK]: (gl2, value) => gl2.stencilMaskSeparate(import_constants3.GL.BACK, value),
941
942
  [import_constants3.GL.STENCIL_FUNC]: "stencilFuncFront",
942
943
  [import_constants3.GL.STENCIL_REF]: "stencilFuncFront",
943
944
  [import_constants3.GL.STENCIL_VALUE_MASK]: "stencilFuncFront",
@@ -950,7 +951,7 @@ var GL_PARAMETER_SETTERS = {
950
951
  [import_constants3.GL.STENCIL_BACK_FAIL]: "stencilOpBack",
951
952
  [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
952
953
  [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
953
- [import_constants3.GL.VIEWPORT]: (gl, value) => gl.viewport(...value),
954
+ [import_constants3.GL.VIEWPORT]: (gl2, value) => gl2.viewport(...value),
954
955
  // WEBGL1 PIXEL PACK/UNPACK MODES
955
956
  [import_constants3.GL.PACK_ALIGNMENT]: pixelStorei,
956
957
  [import_constants3.GL.UNPACK_ALIGNMENT]: pixelStorei,
@@ -968,104 +969,104 @@ var GL_PARAMETER_SETTERS = {
968
969
  [import_constants3.GL.UNPACK_SKIP_ROWS]: pixelStorei,
969
970
  [import_constants3.GL.UNPACK_SKIP_IMAGES]: pixelStorei,
970
971
  // Function-style setters
971
- framebuffer: (gl, framebuffer) => {
972
+ framebuffer: (gl2, framebuffer) => {
972
973
  const handle = framebuffer && "handle" in framebuffer ? framebuffer.handle : framebuffer;
973
- return gl.bindFramebuffer(import_constants3.GL.FRAMEBUFFER, handle);
974
+ return gl2.bindFramebuffer(import_constants3.GL.FRAMEBUFFER, handle);
974
975
  },
975
- blend: (gl, value) => value ? gl.enable(import_constants3.GL.BLEND) : gl.disable(import_constants3.GL.BLEND),
976
- blendColor: (gl, value) => gl.blendColor(...value),
977
- blendEquation: (gl, args) => {
976
+ blend: (gl2, value) => value ? gl2.enable(import_constants3.GL.BLEND) : gl2.disable(import_constants3.GL.BLEND),
977
+ blendColor: (gl2, value) => gl2.blendColor(...value),
978
+ blendEquation: (gl2, args) => {
978
979
  const separateModes = typeof args === "number" ? [args, args] : args;
979
- gl.blendEquationSeparate(...separateModes);
980
+ gl2.blendEquationSeparate(...separateModes);
980
981
  },
981
- blendFunc: (gl, args) => {
982
+ blendFunc: (gl2, args) => {
982
983
  const separateFuncs = (args == null ? void 0 : args.length) === 2 ? [...args, ...args] : args;
983
- gl.blendFuncSeparate(...separateFuncs);
984
+ gl2.blendFuncSeparate(...separateFuncs);
984
985
  },
985
- clearColor: (gl, value) => gl.clearColor(...value),
986
- clearDepth: (gl, value) => gl.clearDepth(value),
987
- clearStencil: (gl, value) => gl.clearStencil(value),
988
- colorMask: (gl, value) => gl.colorMask(...value),
989
- cull: (gl, value) => value ? gl.enable(import_constants3.GL.CULL_FACE) : gl.disable(import_constants3.GL.CULL_FACE),
990
- cullFace: (gl, value) => gl.cullFace(value),
991
- depthTest: (gl, value) => value ? gl.enable(import_constants3.GL.DEPTH_TEST) : gl.disable(import_constants3.GL.DEPTH_TEST),
992
- depthFunc: (gl, value) => gl.depthFunc(value),
993
- depthMask: (gl, value) => gl.depthMask(value),
994
- depthRange: (gl, value) => gl.depthRange(...value),
995
- dither: (gl, value) => value ? gl.enable(import_constants3.GL.DITHER) : gl.disable(import_constants3.GL.DITHER),
996
- derivativeHint: (gl, value) => {
997
- gl.hint(import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT, value);
986
+ clearColor: (gl2, value) => gl2.clearColor(...value),
987
+ clearDepth: (gl2, value) => gl2.clearDepth(value),
988
+ clearStencil: (gl2, value) => gl2.clearStencil(value),
989
+ colorMask: (gl2, value) => gl2.colorMask(...value),
990
+ cull: (gl2, value) => value ? gl2.enable(import_constants3.GL.CULL_FACE) : gl2.disable(import_constants3.GL.CULL_FACE),
991
+ cullFace: (gl2, value) => gl2.cullFace(value),
992
+ depthTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.DEPTH_TEST) : gl2.disable(import_constants3.GL.DEPTH_TEST),
993
+ depthFunc: (gl2, value) => gl2.depthFunc(value),
994
+ depthMask: (gl2, value) => gl2.depthMask(value),
995
+ depthRange: (gl2, value) => gl2.depthRange(...value),
996
+ dither: (gl2, value) => value ? gl2.enable(import_constants3.GL.DITHER) : gl2.disable(import_constants3.GL.DITHER),
997
+ derivativeHint: (gl2, value) => {
998
+ gl2.hint(import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT, value);
998
999
  },
999
- frontFace: (gl, value) => gl.frontFace(value),
1000
- mipmapHint: (gl, value) => gl.hint(import_constants3.GL.GENERATE_MIPMAP_HINT, value),
1001
- lineWidth: (gl, value) => gl.lineWidth(value),
1002
- polygonOffsetFill: (gl, value) => value ? gl.enable(import_constants3.GL.POLYGON_OFFSET_FILL) : gl.disable(import_constants3.GL.POLYGON_OFFSET_FILL),
1003
- polygonOffset: (gl, value) => gl.polygonOffset(...value),
1004
- sampleCoverage: (gl, value) => gl.sampleCoverage(...value),
1005
- scissorTest: (gl, value) => value ? gl.enable(import_constants3.GL.SCISSOR_TEST) : gl.disable(import_constants3.GL.SCISSOR_TEST),
1006
- scissor: (gl, value) => gl.scissor(...value),
1007
- stencilTest: (gl, value) => value ? gl.enable(import_constants3.GL.STENCIL_TEST) : gl.disable(import_constants3.GL.STENCIL_TEST),
1008
- stencilMask: (gl, value) => {
1000
+ frontFace: (gl2, value) => gl2.frontFace(value),
1001
+ mipmapHint: (gl2, value) => gl2.hint(import_constants3.GL.GENERATE_MIPMAP_HINT, value),
1002
+ lineWidth: (gl2, value) => gl2.lineWidth(value),
1003
+ polygonOffsetFill: (gl2, value) => value ? gl2.enable(import_constants3.GL.POLYGON_OFFSET_FILL) : gl2.disable(import_constants3.GL.POLYGON_OFFSET_FILL),
1004
+ polygonOffset: (gl2, value) => gl2.polygonOffset(...value),
1005
+ sampleCoverage: (gl2, value) => gl2.sampleCoverage(...value),
1006
+ scissorTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.SCISSOR_TEST) : gl2.disable(import_constants3.GL.SCISSOR_TEST),
1007
+ scissor: (gl2, value) => gl2.scissor(...value),
1008
+ stencilTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.STENCIL_TEST) : gl2.disable(import_constants3.GL.STENCIL_TEST),
1009
+ stencilMask: (gl2, value) => {
1009
1010
  value = isArray(value) ? value : [value, value];
1010
1011
  const [mask, backMask] = value;
1011
- gl.stencilMaskSeparate(import_constants3.GL.FRONT, mask);
1012
- gl.stencilMaskSeparate(import_constants3.GL.BACK, backMask);
1012
+ gl2.stencilMaskSeparate(import_constants3.GL.FRONT, mask);
1013
+ gl2.stencilMaskSeparate(import_constants3.GL.BACK, backMask);
1013
1014
  },
1014
- stencilFunc: (gl, args) => {
1015
+ stencilFunc: (gl2, args) => {
1015
1016
  args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
1016
1017
  const [func, ref, mask, backFunc, backRef, backMask] = args;
1017
- gl.stencilFuncSeparate(import_constants3.GL.FRONT, func, ref, mask);
1018
- gl.stencilFuncSeparate(import_constants3.GL.BACK, backFunc, backRef, backMask);
1018
+ gl2.stencilFuncSeparate(import_constants3.GL.FRONT, func, ref, mask);
1019
+ gl2.stencilFuncSeparate(import_constants3.GL.BACK, backFunc, backRef, backMask);
1019
1020
  },
1020
- stencilOp: (gl, args) => {
1021
+ stencilOp: (gl2, args) => {
1021
1022
  args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
1022
1023
  const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;
1023
- gl.stencilOpSeparate(import_constants3.GL.FRONT, sfail, dpfail, dppass);
1024
- gl.stencilOpSeparate(import_constants3.GL.BACK, backSfail, backDpfail, backDppass);
1024
+ gl2.stencilOpSeparate(import_constants3.GL.FRONT, sfail, dpfail, dppass);
1025
+ gl2.stencilOpSeparate(import_constants3.GL.BACK, backSfail, backDpfail, backDppass);
1025
1026
  },
1026
- viewport: (gl, value) => gl.viewport(...value)
1027
+ viewport: (gl2, value) => gl2.viewport(...value)
1027
1028
  };
1028
1029
  function getValue(glEnum, values, cache) {
1029
1030
  return values[glEnum] !== void 0 ? values[glEnum] : cache[glEnum];
1030
1031
  }
1031
1032
  var GL_COMPOSITE_PARAMETER_SETTERS = {
1032
- blendEquation: (gl, values, cache) => gl.blendEquationSeparate(
1033
+ blendEquation: (gl2, values, cache) => gl2.blendEquationSeparate(
1033
1034
  getValue(import_constants3.GL.BLEND_EQUATION_RGB, values, cache),
1034
1035
  getValue(import_constants3.GL.BLEND_EQUATION_ALPHA, values, cache)
1035
1036
  ),
1036
- blendFunc: (gl, values, cache) => gl.blendFuncSeparate(
1037
+ blendFunc: (gl2, values, cache) => gl2.blendFuncSeparate(
1037
1038
  getValue(import_constants3.GL.BLEND_SRC_RGB, values, cache),
1038
1039
  getValue(import_constants3.GL.BLEND_DST_RGB, values, cache),
1039
1040
  getValue(import_constants3.GL.BLEND_SRC_ALPHA, values, cache),
1040
1041
  getValue(import_constants3.GL.BLEND_DST_ALPHA, values, cache)
1041
1042
  ),
1042
- polygonOffset: (gl, values, cache) => gl.polygonOffset(
1043
+ polygonOffset: (gl2, values, cache) => gl2.polygonOffset(
1043
1044
  getValue(import_constants3.GL.POLYGON_OFFSET_FACTOR, values, cache),
1044
1045
  getValue(import_constants3.GL.POLYGON_OFFSET_UNITS, values, cache)
1045
1046
  ),
1046
- sampleCoverage: (gl, values, cache) => gl.sampleCoverage(
1047
+ sampleCoverage: (gl2, values, cache) => gl2.sampleCoverage(
1047
1048
  getValue(import_constants3.GL.SAMPLE_COVERAGE_VALUE, values, cache),
1048
1049
  getValue(import_constants3.GL.SAMPLE_COVERAGE_INVERT, values, cache)
1049
1050
  ),
1050
- stencilFuncFront: (gl, values, cache) => gl.stencilFuncSeparate(
1051
+ stencilFuncFront: (gl2, values, cache) => gl2.stencilFuncSeparate(
1051
1052
  import_constants3.GL.FRONT,
1052
1053
  getValue(import_constants3.GL.STENCIL_FUNC, values, cache),
1053
1054
  getValue(import_constants3.GL.STENCIL_REF, values, cache),
1054
1055
  getValue(import_constants3.GL.STENCIL_VALUE_MASK, values, cache)
1055
1056
  ),
1056
- stencilFuncBack: (gl, values, cache) => gl.stencilFuncSeparate(
1057
+ stencilFuncBack: (gl2, values, cache) => gl2.stencilFuncSeparate(
1057
1058
  import_constants3.GL.BACK,
1058
1059
  getValue(import_constants3.GL.STENCIL_BACK_FUNC, values, cache),
1059
1060
  getValue(import_constants3.GL.STENCIL_BACK_REF, values, cache),
1060
1061
  getValue(import_constants3.GL.STENCIL_BACK_VALUE_MASK, values, cache)
1061
1062
  ),
1062
- stencilOpFront: (gl, values, cache) => gl.stencilOpSeparate(
1063
+ stencilOpFront: (gl2, values, cache) => gl2.stencilOpSeparate(
1063
1064
  import_constants3.GL.FRONT,
1064
1065
  getValue(import_constants3.GL.STENCIL_FAIL, values, cache),
1065
1066
  getValue(import_constants3.GL.STENCIL_PASS_DEPTH_FAIL, values, cache),
1066
1067
  getValue(import_constants3.GL.STENCIL_PASS_DEPTH_PASS, values, cache)
1067
1068
  ),
1068
- stencilOpBack: (gl, values, cache) => gl.stencilOpSeparate(
1069
+ stencilOpBack: (gl2, values, cache) => gl2.stencilOpSeparate(
1069
1070
  import_constants3.GL.BACK,
1070
1071
  getValue(import_constants3.GL.STENCIL_BACK_FAIL, values, cache),
1071
1072
  getValue(import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL, values, cache),
@@ -1228,7 +1229,7 @@ var GL_HOOKED_SETTERS = {
1228
1229
  [import_constants3.GL.VIEWPORT]: [x, y, width, height]
1229
1230
  })
1230
1231
  };
1231
- var isEnabled = (gl, key) => gl.isEnabled(key);
1232
+ var isEnabled = (gl2, key) => gl2.isEnabled(key);
1232
1233
  var GL_PARAMETER_GETTERS = {
1233
1234
  [import_constants3.GL.BLEND]: isEnabled,
1234
1235
  [import_constants3.GL.CULL_FACE]: isEnabled,
@@ -1284,7 +1285,7 @@ var NON_CACHE_PARAMETERS = /* @__PURE__ */ new Set([
1284
1285
  // src/context/parameters/unified-parameter-api.ts
1285
1286
  function setParameters(device, parameters) {
1286
1287
  const webglDevice = WebGLDevice.attach(device);
1287
- const gl = webglDevice.gl;
1288
+ const gl2 = webglDevice.gl;
1288
1289
  if (isObjectEmpty(parameters)) {
1289
1290
  return;
1290
1291
  }
@@ -1296,31 +1297,31 @@ function setParameters(device, parameters) {
1296
1297
  if (typeof setter === "string") {
1297
1298
  compositeSetters[setter] = true;
1298
1299
  } else {
1299
- setter(gl, parameters[key], glConstant);
1300
+ setter(gl2, parameters[key], glConstant);
1300
1301
  }
1301
1302
  }
1302
1303
  }
1303
- const cache = gl.state && gl.state.cache;
1304
+ const cache = gl2.state && gl2.state.cache;
1304
1305
  if (cache) {
1305
1306
  for (const key in compositeSetters) {
1306
1307
  const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
1307
- compositeSetter(gl, parameters, cache);
1308
+ compositeSetter(gl2, parameters, cache);
1308
1309
  }
1309
1310
  }
1310
1311
  }
1311
1312
  function getParameters(device, parameters = GL_PARAMETER_DEFAULTS) {
1312
1313
  const webglDevice = WebGLDevice.attach(device);
1313
- const gl = webglDevice.gl;
1314
+ const gl2 = webglDevice.gl;
1314
1315
  if (typeof parameters === "number") {
1315
1316
  const key = parameters;
1316
1317
  const getter = GL_PARAMETER_GETTERS[key];
1317
- return getter ? getter(gl, key) : gl.getParameter(key);
1318
+ return getter ? getter(gl2, key) : gl2.getParameter(key);
1318
1319
  }
1319
1320
  const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
1320
1321
  const state = {};
1321
1322
  for (const key of parameterKeys) {
1322
1323
  const getter = GL_PARAMETER_GETTERS[key];
1323
- state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
1324
+ state[key] = getter ? getter(gl2, Number(key)) : gl2.getParameter(Number(key));
1324
1325
  }
1325
1326
  return state;
1326
1327
  }
@@ -1354,7 +1355,7 @@ function deepArrayEqual(x, y) {
1354
1355
 
1355
1356
  // src/context/state-tracker/track-context-state.ts
1356
1357
  var GLState = class {
1357
- constructor(gl, {
1358
+ constructor(gl2, {
1358
1359
  copyState = false,
1359
1360
  // Copy cache from params (slow) or initialize from WebGL defaults (fast)
1360
1361
  log: log9 = () => {
@@ -1364,8 +1365,8 @@ var GLState = class {
1364
1365
  this.program = null;
1365
1366
  this.stateStack = [];
1366
1367
  this.enable = true;
1367
- this.gl = gl;
1368
- this.cache = copyState ? getParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);
1368
+ this.gl = gl2;
1369
+ this.cache = copyState ? getParameters(gl2) : Object.assign({}, GL_PARAMETER_DEFAULTS);
1369
1370
  this.log = log9;
1370
1371
  this._updateCache = this._updateCache.bind(this);
1371
1372
  Object.seal(this);
@@ -1405,46 +1406,46 @@ var GLState = class {
1405
1406
  return { valueChanged, oldValue };
1406
1407
  }
1407
1408
  };
1408
- function getContextState(gl) {
1409
- return gl.state;
1409
+ function getContextState(gl2) {
1410
+ return gl2.state;
1410
1411
  }
1411
- function trackContextState(gl, options) {
1412
+ function trackContextState(gl2, options) {
1412
1413
  const { enable: enable2 = true, copyState } = options;
1413
1414
  (0, import_api4.assert)(copyState !== void 0);
1414
- if (!gl.state) {
1415
- gl.state = new GLState(gl, { copyState });
1416
- installProgramSpy(gl);
1415
+ if (!gl2.state) {
1416
+ gl2.state = new GLState(gl2, { copyState });
1417
+ installProgramSpy(gl2);
1417
1418
  for (const key in GL_HOOKED_SETTERS) {
1418
1419
  const setter = GL_HOOKED_SETTERS[key];
1419
- installSetterSpy(gl, key, setter);
1420
+ installSetterSpy(gl2, key, setter);
1420
1421
  }
1421
- installGetterOverride(gl, "getParameter");
1422
- installGetterOverride(gl, "isEnabled");
1422
+ installGetterOverride(gl2, "getParameter");
1423
+ installGetterOverride(gl2, "isEnabled");
1423
1424
  }
1424
- const glState = getContextState(gl);
1425
+ const glState = getContextState(gl2);
1425
1426
  glState.enable = enable2;
1426
- return gl;
1427
+ return gl2;
1427
1428
  }
1428
- function pushContextState(gl) {
1429
- let glState = getContextState(gl);
1429
+ function pushContextState(gl2) {
1430
+ let glState = getContextState(gl2);
1430
1431
  if (!glState) {
1431
- trackContextState(gl, { copyState: false });
1432
- glState = getContextState(gl);
1432
+ trackContextState(gl2, { copyState: false });
1433
+ glState = getContextState(gl2);
1433
1434
  }
1434
1435
  glState.push();
1435
1436
  }
1436
- function popContextState(gl) {
1437
- const glState = getContextState(gl);
1437
+ function popContextState(gl2) {
1438
+ const glState = getContextState(gl2);
1438
1439
  (0, import_api4.assert)(glState);
1439
1440
  glState.pop();
1440
1441
  }
1441
- function installGetterOverride(gl, functionName) {
1442
- const originalGetterFunc = gl[functionName].bind(gl);
1443
- gl[functionName] = function get(pname) {
1442
+ function installGetterOverride(gl2, functionName) {
1443
+ const originalGetterFunc = gl2[functionName].bind(gl2);
1444
+ gl2[functionName] = function get(pname) {
1444
1445
  if (pname === void 0 || NON_CACHE_PARAMETERS.has(pname)) {
1445
1446
  return originalGetterFunc(pname);
1446
1447
  }
1447
- const glState = getContextState(gl);
1448
+ const glState = getContextState(gl2);
1448
1449
  if (!(pname in glState.cache)) {
1449
1450
  glState.cache[pname] = originalGetterFunc(pname);
1450
1451
  }
@@ -1456,33 +1457,33 @@ function installGetterOverride(gl, functionName) {
1456
1457
  originalGetterFunc(pname)
1457
1458
  );
1458
1459
  };
1459
- Object.defineProperty(gl[functionName], "name", {
1460
+ Object.defineProperty(gl2[functionName], "name", {
1460
1461
  value: `${functionName}-from-cache`,
1461
1462
  configurable: false
1462
1463
  });
1463
1464
  }
1464
- function installSetterSpy(gl, functionName, setter) {
1465
- if (!gl[functionName]) {
1465
+ function installSetterSpy(gl2, functionName, setter) {
1466
+ if (!gl2[functionName]) {
1466
1467
  return;
1467
1468
  }
1468
- const originalSetterFunc = gl[functionName].bind(gl);
1469
- gl[functionName] = function set(...params) {
1470
- const glState = getContextState(gl);
1469
+ const originalSetterFunc = gl2[functionName].bind(gl2);
1470
+ gl2[functionName] = function set(...params) {
1471
+ const glState = getContextState(gl2);
1471
1472
  const { valueChanged, oldValue } = setter(glState._updateCache, ...params);
1472
1473
  if (valueChanged) {
1473
1474
  originalSetterFunc(...params);
1474
1475
  }
1475
1476
  return oldValue;
1476
1477
  };
1477
- Object.defineProperty(gl[functionName], "name", {
1478
+ Object.defineProperty(gl2[functionName], "name", {
1478
1479
  value: `${functionName}-to-cache`,
1479
1480
  configurable: false
1480
1481
  });
1481
1482
  }
1482
- function installProgramSpy(gl) {
1483
- const originalUseProgram = gl.useProgram.bind(gl);
1484
- gl.useProgram = function useProgramLuma(handle) {
1485
- const glState = getContextState(gl);
1483
+ function installProgramSpy(gl2) {
1484
+ const originalUseProgram = gl2.useProgram.bind(gl2);
1485
+ gl2.useProgram = function useProgramLuma(handle) {
1486
+ const glState = getContextState(gl2);
1486
1487
  if (glState.program !== handle) {
1487
1488
  originalUseProgram(handle);
1488
1489
  glState.program = handle;
@@ -1508,21 +1509,21 @@ function createBrowserContext(canvas, props) {
1508
1509
  let errorMessage = null;
1509
1510
  const onCreateError = (error2) => errorMessage = error2.statusMessage || errorMessage;
1510
1511
  canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
1511
- let gl = null;
1512
+ let gl2 = null;
1512
1513
  if (props.type === "webgl2") {
1513
1514
  props = __spreadProps(__spreadValues({}, props), { webgl1: false });
1514
1515
  }
1515
1516
  if (props.type === "webgl1") {
1516
1517
  props = __spreadProps(__spreadValues({}, props), { webgl2: false });
1517
1518
  }
1518
- if (!gl && props.webgl2) {
1519
- gl = canvas.getContext("webgl2", props);
1519
+ if (!gl2 && props.webgl2) {
1520
+ gl2 = canvas.getContext("webgl2", props);
1520
1521
  }
1521
- if (!gl && props.webgl1) {
1522
- gl = canvas.getContext("webgl", props);
1522
+ if (!gl2 && props.webgl1) {
1523
+ gl2 = canvas.getContext("webgl", props);
1523
1524
  }
1524
1525
  canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
1525
- if (!gl) {
1526
+ if (!gl2) {
1526
1527
  throw new Error(
1527
1528
  `Failed to create ${props.webgl2 && !props.webgl1 ? "WebGL2" : "WebGL"} context: ${errorMessage || "Unknown error"}`
1528
1529
  );
@@ -1539,29 +1540,29 @@ function createBrowserContext(canvas, props) {
1539
1540
  false
1540
1541
  );
1541
1542
  }
1542
- return gl;
1543
+ return gl2;
1543
1544
  }
1544
1545
 
1545
1546
  // src/adapter/device-helpers/get-device-info.ts
1546
1547
  var import_constants4 = require("@luma.gl/constants");
1547
- function getDeviceInfo(gl) {
1548
- const vendorMasked = gl.getParameter(import_constants4.GL.VENDOR);
1549
- const rendererMasked = gl.getParameter(import_constants4.GL.RENDERER);
1550
- const ext = gl.getExtension("WEBGL_debug_renderer_info");
1551
- const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : import_constants4.GL.VENDOR);
1552
- const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : import_constants4.GL.RENDERER);
1548
+ function getDeviceInfo(gl2) {
1549
+ const vendorMasked = gl2.getParameter(import_constants4.GL.VENDOR);
1550
+ const rendererMasked = gl2.getParameter(import_constants4.GL.RENDERER);
1551
+ const ext = gl2.getExtension("WEBGL_debug_renderer_info");
1552
+ const vendorUnmasked = gl2.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : import_constants4.GL.VENDOR);
1553
+ const rendererUnmasked = gl2.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : import_constants4.GL.RENDERER);
1553
1554
  const vendor = vendorUnmasked || vendorMasked;
1554
1555
  const renderer = rendererUnmasked || rendererMasked;
1555
1556
  const gpu = identifyGPUVendor(vendor, renderer);
1556
1557
  return {
1557
- type: isWebGL2(gl) ? "webgl2" : "webgl",
1558
+ type: isWebGL2(gl2) ? "webgl2" : "webgl",
1558
1559
  gpu,
1559
1560
  vendor: vendorUnmasked || vendorMasked,
1560
1561
  renderer: rendererUnmasked || rendererMasked,
1561
- version: gl.getParameter(import_constants4.GL.VERSION),
1562
+ version: gl2.getParameter(import_constants4.GL.VERSION),
1562
1563
  shadingLanguages: ["glsl"],
1563
1564
  shadingLanguageVersions: {
1564
- "glsl": gl.getParameter(import_constants4.GL.SHADING_LANGUAGE_VERSION)
1565
+ "glsl": gl2.getParameter(import_constants4.GL.SHADING_LANGUAGE_VERSION)
1565
1566
  }
1566
1567
  };
1567
1568
  }
@@ -1615,39 +1616,39 @@ var EXT_SRGB = "EXT_sRGB";
1615
1616
  var EXT_TEXTURE_NORM16 = "EXT_texture_norm16";
1616
1617
  var EXT_FLOAT_WEBGL1 = "WEBGL_color_buffer_float";
1617
1618
  var EXT_FLOAT_RENDER_WEBGL2 = "EXT_color_buffer_float";
1618
- var checkExtension = (gl, extension) => gl.getExtension(extension);
1619
- var checkExtensions = (gl, extensions) => extensions.every((extension) => gl.getExtension(extension));
1619
+ var checkExtension = (gl2, extension) => gl2.getExtension(extension);
1620
+ var checkExtensions = (gl2, extensions) => extensions.every((extension) => gl2.getExtension(extension));
1620
1621
  var TEXTURE_FEATURE_CHECKS = {
1621
- "texture-blend-float-webgl1": (gl) => isWebGL2(gl) ? true : checkExtension(gl, "EXT_float_blend"),
1622
- "texture-formats-srgb-webgl1": (gl) => isWebGL2(gl) ? true : checkExtension(gl, EXT_SRGB),
1623
- "texture-formats-depth-webgl1": (gl) => isWebGL2(gl) ? true : checkExtension(gl, "WEBGL_depth_texture"),
1624
- "texture-formats-float32-webgl1": (gl) => isWebGL2(gl) ? true : checkExtension(gl, "OES_texture_float"),
1625
- "texture-formats-float16-webgl1": (gl) => isWebGL2(gl) ? true : checkExtension(gl, "OES_texture_half_float"),
1626
- "texture-formats-norm16-webgl": (gl) => isWebGL2(gl) ? checkExtension(gl, EXT_TEXTURE_NORM16) : false,
1627
- "texture-filter-linear-float32-webgl": (gl) => checkExtension(gl, "OES_texture_float_linear"),
1628
- "texture-filter-linear-float16-webgl": (gl) => checkExtension(gl, "OES_texture_half_float_linear"),
1629
- "texture-filter-anisotropic-webgl": (gl) => checkExtension(gl, "EXT_texture_filter_anisotropic"),
1630
- "texture-renderable-float32-webgl": (gl) => checkExtension(gl, "EXT_color_buffer_float"),
1622
+ "texture-blend-float-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "EXT_float_blend"),
1623
+ "texture-formats-srgb-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, EXT_SRGB),
1624
+ "texture-formats-depth-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "WEBGL_depth_texture"),
1625
+ "texture-formats-float32-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "OES_texture_float"),
1626
+ "texture-formats-float16-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "OES_texture_half_float"),
1627
+ "texture-formats-norm16-webgl": (gl2) => isWebGL2(gl2) ? checkExtension(gl2, EXT_TEXTURE_NORM16) : false,
1628
+ "texture-filter-linear-float32-webgl": (gl2) => checkExtension(gl2, "OES_texture_float_linear"),
1629
+ "texture-filter-linear-float16-webgl": (gl2) => checkExtension(gl2, "OES_texture_half_float_linear"),
1630
+ "texture-filter-anisotropic-webgl": (gl2) => checkExtension(gl2, "EXT_texture_filter_anisotropic"),
1631
+ "texture-renderable-float32-webgl": (gl2) => checkExtension(gl2, "EXT_color_buffer_float"),
1631
1632
  // [false, 'EXT_color_buffer_float'],
1632
- "texture-renderable-float16-webgl": (gl) => checkExtension(gl, "EXT_color_buffer_half_float"),
1633
- "texture-compression-bc": (gl) => checkExtensions(gl, [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC]),
1634
- "texture-compression-bc5-webgl": (gl) => checkExtensions(gl, [X_RGTC]),
1633
+ "texture-renderable-float16-webgl": (gl2) => checkExtension(gl2, "EXT_color_buffer_half_float"),
1634
+ "texture-compression-bc": (gl2) => checkExtensions(gl2, [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC]),
1635
+ "texture-compression-bc5-webgl": (gl2) => checkExtensions(gl2, [X_RGTC]),
1635
1636
  // 'texture-compression-bc7-webgl': gl => checkExtensions(gl, [X_BPTC]),
1636
1637
  // 'texture-compression-bc3-srgb-webgl': gl => checkExtensions(gl, [X_S3TC_SRGB]),
1637
1638
  // 'texture-compression-bc3-webgl': gl => checkExtensions(gl, [X_S3TC]),
1638
- "texture-compression-etc2": (gl) => checkExtensions(gl, [X_ETC2]),
1639
- "texture-compression-astc": (gl) => checkExtensions(gl, [X_ASTC]),
1640
- "texture-compression-etc1-webgl": (gl) => checkExtensions(gl, [X_ETC1]),
1641
- "texture-compression-pvrtc-webgl": (gl) => checkExtensions(gl, [X_PVRTC]),
1642
- "texture-compression-atc-webgl": (gl) => checkExtensions(gl, [X_ATC])
1639
+ "texture-compression-etc2": (gl2) => checkExtensions(gl2, [X_ETC2]),
1640
+ "texture-compression-astc": (gl2) => checkExtensions(gl2, [X_ASTC]),
1641
+ "texture-compression-etc1-webgl": (gl2) => checkExtensions(gl2, [X_ETC1]),
1642
+ "texture-compression-pvrtc-webgl": (gl2) => checkExtensions(gl2, [X_PVRTC]),
1643
+ "texture-compression-atc-webgl": (gl2) => checkExtensions(gl2, [X_ATC])
1643
1644
  };
1644
- function checkTextureFeature(gl, feature) {
1645
+ function checkTextureFeature(gl2, feature) {
1645
1646
  var _a;
1646
- return ((_a = TEXTURE_FEATURE_CHECKS[feature]) == null ? void 0 : _a.call(TEXTURE_FEATURE_CHECKS, gl)) || false;
1647
+ return ((_a = TEXTURE_FEATURE_CHECKS[feature]) == null ? void 0 : _a.call(TEXTURE_FEATURE_CHECKS, gl2)) || false;
1647
1648
  }
1648
- function getTextureFeatures(gl) {
1649
+ function getTextureFeatures(gl2) {
1649
1650
  const textureFeatures = Object.keys(TEXTURE_FEATURE_CHECKS);
1650
- return textureFeatures.filter((feature) => checkTextureFeature(gl, feature));
1651
+ return textureFeatures.filter((feature) => checkTextureFeature(gl2, feature));
1651
1652
  }
1652
1653
  var TEXTURE_FORMATS = {
1653
1654
  // Unsized formats that leave the precision up to the driver.
@@ -1855,24 +1856,24 @@ var TYPE_SIZES = {
1855
1856
  [import_constants5.GL.BYTE]: 1,
1856
1857
  [import_constants5.GL.UNSIGNED_BYTE]: 1
1857
1858
  };
1858
- function isTextureFormatSupported(gl, formatOrGL) {
1859
+ function isTextureFormatSupported(gl2, formatOrGL) {
1859
1860
  const format = convertGLToTextureFormat(formatOrGL);
1860
1861
  const info = TEXTURE_FORMATS[format];
1861
1862
  if (!info) {
1862
1863
  return false;
1863
1864
  }
1864
- if (isWebGL2(gl) ? info.gl === void 0 : info.gl1 === void 0) {
1865
+ if (isWebGL2(gl2) ? info.gl === void 0 : info.gl1 === void 0) {
1865
1866
  return false;
1866
1867
  }
1867
- const extension = info.x || (isWebGL2(gl) ? info.gl2ext || info.gl1ext : info.gl1ext);
1868
+ const extension = info.x || (isWebGL2(gl2) ? info.gl2ext || info.gl1ext : info.gl1ext);
1868
1869
  if (extension) {
1869
- return Boolean(gl.getExtension(extension));
1870
+ return Boolean(gl2.getExtension(extension));
1870
1871
  }
1871
1872
  return true;
1872
1873
  }
1873
- function isRenderbufferFormatSupported(gl, format) {
1874
+ function isRenderbufferFormatSupported(gl2, format) {
1874
1875
  var _a;
1875
- return isTextureFormatSupported(gl, format) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.renderbuffer);
1876
+ return isTextureFormatSupported(gl2, format) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.renderbuffer);
1876
1877
  }
1877
1878
  function convertGLToTextureFormat(format) {
1878
1879
  if (typeof format === "string") {
@@ -1894,9 +1895,9 @@ function convertTextureFormatToGL(format, isWebGL23) {
1894
1895
  }
1895
1896
  return webglFormat;
1896
1897
  }
1897
- function isTextureFormatFilterable(gl, formatOrGL) {
1898
+ function isTextureFormatFilterable(gl2, formatOrGL) {
1898
1899
  const format = convertGLToTextureFormat(formatOrGL);
1899
- if (!isTextureFormatSupported(gl, format)) {
1900
+ if (!isTextureFormatSupported(gl2, format)) {
1900
1901
  return false;
1901
1902
  }
1902
1903
  try {
@@ -1908,16 +1909,16 @@ function isTextureFormatFilterable(gl, formatOrGL) {
1908
1909
  return false;
1909
1910
  }
1910
1911
  if (format.endsWith("32float")) {
1911
- return Boolean(gl.getExtension("OES_texture_float_linear"));
1912
+ return Boolean(gl2.getExtension("OES_texture_float_linear"));
1912
1913
  }
1913
1914
  if (format.endsWith("16float")) {
1914
- return Boolean(gl.getExtension("OES_texture_half_float_linear"));
1915
+ return Boolean(gl2.getExtension("OES_texture_half_float_linear"));
1915
1916
  }
1916
1917
  return true;
1917
1918
  }
1918
- function isTextureFormatRenderable(gl, formatOrGL) {
1919
+ function isTextureFormatRenderable(gl2, formatOrGL) {
1919
1920
  const format = convertGLToTextureFormat(formatOrGL);
1920
- if (!isTextureFormatSupported(gl, format)) {
1921
+ if (!isTextureFormatSupported(gl2, format)) {
1921
1922
  return false;
1922
1923
  }
1923
1924
  if (typeof format === "number") {
@@ -1949,19 +1950,19 @@ function getDepthStencilAttachmentWebGL(format) {
1949
1950
  }
1950
1951
  return info.attachment;
1951
1952
  }
1952
- function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat = import_constants5.GL.RGBA, srcType = import_constants5.GL.UNSIGNED_BYTE) {
1953
+ function _checkFloat32ColorAttachment(gl2, internalFormat = gl2.RGBA, srcFormat = import_constants5.GL.RGBA, srcType = import_constants5.GL.UNSIGNED_BYTE) {
1953
1954
  let texture = null;
1954
1955
  let framebuffer = null;
1955
1956
  try {
1956
- texture = gl.createTexture();
1957
- gl.bindTexture(import_constants5.GL.TEXTURE_2D, texture);
1957
+ texture = gl2.createTexture();
1958
+ gl2.bindTexture(import_constants5.GL.TEXTURE_2D, texture);
1958
1959
  const level = 0;
1959
1960
  const width = 1;
1960
1961
  const height = 1;
1961
1962
  const border = 0;
1962
1963
  const pixel = new Uint8Array([0, 0, 255, 255]);
1963
- gl.texImage2D(
1964
- gl.TEXTURE_2D,
1964
+ gl2.texImage2D(
1965
+ gl2.TEXTURE_2D,
1965
1966
  level,
1966
1967
  internalFormat,
1967
1968
  width,
@@ -1971,15 +1972,15 @@ function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat =
1971
1972
  srcType,
1972
1973
  pixel
1973
1974
  );
1974
- framebuffer = gl.createFramebuffer();
1975
- gl.bindFramebuffer(import_constants5.GL.FRAMEBUFFER, framebuffer);
1976
- gl.framebufferTexture2D(import_constants5.GL.FRAMEBUFFER, import_constants5.GL.COLOR_ATTACHMENT0, import_constants5.GL.TEXTURE_2D, texture, 0);
1977
- const status = gl.checkFramebufferStatus(import_constants5.GL.FRAMEBUFFER) === import_constants5.GL.FRAMEBUFFER_COMPLETE;
1978
- gl.bindTexture(import_constants5.GL.TEXTURE_2D, null);
1975
+ framebuffer = gl2.createFramebuffer();
1976
+ gl2.bindFramebuffer(import_constants5.GL.FRAMEBUFFER, framebuffer);
1977
+ gl2.framebufferTexture2D(import_constants5.GL.FRAMEBUFFER, import_constants5.GL.COLOR_ATTACHMENT0, import_constants5.GL.TEXTURE_2D, texture, 0);
1978
+ const status = gl2.checkFramebufferStatus(import_constants5.GL.FRAMEBUFFER) === import_constants5.GL.FRAMEBUFFER_COMPLETE;
1979
+ gl2.bindTexture(import_constants5.GL.TEXTURE_2D, null);
1979
1980
  return status;
1980
1981
  } finally {
1981
- gl.deleteTexture(texture);
1982
- gl.deleteFramebuffer(framebuffer);
1982
+ gl2.deleteTexture(texture);
1983
+ gl2.deleteFramebuffer(framebuffer);
1983
1984
  }
1984
1985
  }
1985
1986
  function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
@@ -2030,50 +2031,50 @@ function getWebGLDataType(dataType) {
2030
2031
  }
2031
2032
 
2032
2033
  // src/adapter/device-helpers/device-features.ts
2033
- function getDeviceFeatures(gl) {
2034
- const features = getWebGLFeatures(gl);
2035
- for (const textureFeature of getTextureFeatures(gl)) {
2034
+ function getDeviceFeatures(gl2) {
2035
+ const features = getWebGLFeatures(gl2);
2036
+ for (const textureFeature of getTextureFeatures(gl2)) {
2036
2037
  features.add(textureFeature);
2037
2038
  }
2038
2039
  return features;
2039
2040
  }
2040
- function getWebGLFeatures(gl) {
2041
- gl.getExtension("EXT_color_buffer_float");
2042
- gl.getExtension("WEBGL_color_buffer_float");
2043
- gl.getExtension("EXT_float_blend");
2041
+ function getWebGLFeatures(gl2) {
2042
+ gl2.getExtension("EXT_color_buffer_float");
2043
+ gl2.getExtension("WEBGL_color_buffer_float");
2044
+ gl2.getExtension("EXT_float_blend");
2044
2045
  const features = /* @__PURE__ */ new Set();
2045
2046
  for (const feature of Object.keys(WEBGL_FEATURES)) {
2046
- if (isFeatureSupported(gl, feature)) {
2047
+ if (isFeatureSupported(gl2, feature)) {
2047
2048
  features.add(feature);
2048
2049
  }
2049
2050
  }
2050
2051
  return features;
2051
2052
  }
2052
- function isFeatureSupported(gl, feature) {
2053
+ function isFeatureSupported(gl2, feature) {
2053
2054
  const featureInfo = WEBGL_FEATURES[feature];
2054
2055
  if (!featureInfo) {
2055
2056
  return false;
2056
2057
  }
2057
2058
  const [webgl1Feature, webgl2Feature] = featureInfo || [];
2058
- const featureDefinition = isWebGL2(gl) ? webgl2Feature : webgl1Feature;
2059
+ const featureDefinition = isWebGL2(gl2) ? webgl2Feature : webgl1Feature;
2059
2060
  if (typeof featureDefinition === "boolean") {
2060
2061
  return featureDefinition;
2061
2062
  }
2062
2063
  switch (feature) {
2063
2064
  case "texture-renderable-rgba32float-webgl":
2064
- return isWebGL2(gl) ? Boolean(gl.getExtension(featureDefinition)) : _checkFloat32ColorAttachment(gl);
2065
+ return isWebGL2(gl2) ? Boolean(gl2.getExtension(featureDefinition)) : _checkFloat32ColorAttachment(gl2);
2065
2066
  case "glsl-derivatives":
2066
- return canCompileGLSLExtension(gl, featureDefinition);
2067
+ return canCompileGLSLExtension(gl2, featureDefinition);
2067
2068
  case "glsl-frag-data":
2068
- return canCompileGLSLExtension(gl, featureDefinition, { behavior: "require" });
2069
+ return canCompileGLSLExtension(gl2, featureDefinition, { behavior: "require" });
2069
2070
  case "glsl-frag-depth":
2070
- return canCompileGLSLExtension(gl, featureDefinition);
2071
+ return canCompileGLSLExtension(gl2, featureDefinition);
2071
2072
  default:
2072
- return Boolean(gl.getExtension(featureDefinition));
2073
+ return Boolean(gl2.getExtension(featureDefinition));
2073
2074
  }
2074
2075
  }
2075
2076
  var compiledGLSLExtensions = {};
2076
- function canCompileGLSLExtension(gl, extensionName, opts = {}) {
2077
+ function canCompileGLSLExtension(gl2, extensionName, opts = {}) {
2077
2078
  if (!isOldIE(opts)) {
2078
2079
  return true;
2079
2080
  }
@@ -2083,14 +2084,14 @@ function canCompileGLSLExtension(gl, extensionName, opts = {}) {
2083
2084
  const behavior = opts.behavior || "enable";
2084
2085
  const source = `#extension GL_${extensionName} : ${behavior}
2085
2086
  void main(void) {}`;
2086
- const shader = gl.createShader(gl.VERTEX_SHADER);
2087
+ const shader = gl2.createShader(gl2.VERTEX_SHADER);
2087
2088
  if (!shader) {
2088
2089
  throw new Error("shader");
2089
2090
  }
2090
- gl.shaderSource(shader, source);
2091
- gl.compileShader(shader);
2092
- const canCompile = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
2093
- gl.deleteShader(shader);
2091
+ gl2.shaderSource(shader, source);
2092
+ gl2.compileShader(shader);
2093
+ const canCompile = gl2.getShaderParameter(shader, gl2.COMPILE_STATUS);
2094
+ gl2.deleteShader(shader);
2094
2095
  compiledGLSLExtensions[extensionName] = canCompile;
2095
2096
  return canCompile;
2096
2097
  }
@@ -2128,38 +2129,38 @@ var WEBGL_FEATURES = {
2128
2129
 
2129
2130
  // src/adapter/device-helpers/device-limits.ts
2130
2131
  var import_constants6 = require("@luma.gl/constants");
2131
- function getDeviceLimits(gl) {
2132
- const gl2 = getWebGL2Context(gl);
2132
+ function getDeviceLimits(gl2) {
2133
+ const gl22 = getWebGL2Context(gl2);
2133
2134
  return {
2134
2135
  maxTextureDimension1D: 0,
2135
2136
  // WebGL does not support 1D textures
2136
- maxTextureDimension2D: gl.getParameter(import_constants6.GL.MAX_TEXTURE_SIZE),
2137
- maxTextureDimension3D: gl2 ? gl2.getParameter(import_constants6.GL.MAX_3D_TEXTURE_SIZE) : 0,
2138
- maxTextureArrayLayers: gl2 ? gl2.getParameter(import_constants6.GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
2137
+ maxTextureDimension2D: gl2.getParameter(import_constants6.GL.MAX_TEXTURE_SIZE),
2138
+ maxTextureDimension3D: gl22 ? gl22.getParameter(import_constants6.GL.MAX_3D_TEXTURE_SIZE) : 0,
2139
+ maxTextureArrayLayers: gl22 ? gl22.getParameter(import_constants6.GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
2139
2140
  maxBindGroups: 1,
2140
2141
  // TBD
2141
2142
  maxDynamicUniformBuffersPerPipelineLayout: 0,
2142
2143
  // TBD
2143
2144
  maxDynamicStorageBuffersPerPipelineLayout: 0,
2144
2145
  // TBD
2145
- maxSampledTexturesPerShaderStage: gl.getParameter(import_constants6.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
2146
+ maxSampledTexturesPerShaderStage: gl2.getParameter(import_constants6.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
2146
2147
  // TBD
2147
- maxSamplersPerShaderStage: gl.getParameter(import_constants6.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
2148
+ maxSamplersPerShaderStage: gl2.getParameter(import_constants6.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
2148
2149
  maxStorageBuffersPerShaderStage: 0,
2149
2150
  // TBD
2150
2151
  maxStorageTexturesPerShaderStage: 0,
2151
2152
  // TBD
2152
- maxUniformBuffersPerShaderStage: gl2 ? gl2.getParameter(import_constants6.GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
2153
- maxUniformBufferBindingSize: gl2 ? gl2.getParameter(import_constants6.GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
2153
+ maxUniformBuffersPerShaderStage: gl22 ? gl22.getParameter(import_constants6.GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
2154
+ maxUniformBufferBindingSize: gl22 ? gl22.getParameter(import_constants6.GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
2154
2155
  maxStorageBufferBindingSize: 0,
2155
- minUniformBufferOffsetAlignment: gl2 ? gl2.getParameter(import_constants6.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
2156
+ minUniformBufferOffsetAlignment: gl22 ? gl22.getParameter(import_constants6.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
2156
2157
  minStorageBufferOffsetAlignment: 0,
2157
2158
  // TBD
2158
2159
  maxVertexBuffers: 0,
2159
- maxVertexAttributes: gl.getParameter(import_constants6.GL.MAX_VERTEX_ATTRIBS),
2160
+ maxVertexAttributes: gl2.getParameter(import_constants6.GL.MAX_VERTEX_ATTRIBS),
2160
2161
  maxVertexBufferArrayStride: 2048,
2161
2162
  // TBD, this is just the default value from WebGPU
2162
- maxInterStageShaderComponents: gl2 ? gl2.getParameter(import_constants6.GL.MAX_VARYING_COMPONENTS) : 0,
2163
+ maxInterStageShaderComponents: gl22 ? gl22.getParameter(import_constants6.GL.MAX_VARYING_COMPONENTS) : 0,
2163
2164
  maxComputeWorkgroupStorageSize: 0,
2164
2165
  // WebGL does not support compute shaders
2165
2166
  maxComputeInvocationsPerWorkgroup: 0,
@@ -2174,13 +2175,13 @@ function getDeviceLimits(gl) {
2174
2175
  // WebGL does not support compute shaders
2175
2176
  };
2176
2177
  }
2177
- function getWebGLLimits(gl) {
2178
- const gl2 = getWebGL2Context(gl);
2178
+ function getWebGLLimits(gl2) {
2179
+ const gl22 = getWebGL2Context(gl2);
2179
2180
  function get(pname) {
2180
- return gl.getParameter(pname);
2181
+ return gl2.getParameter(pname);
2181
2182
  }
2182
2183
  function get2(pname, defaultValue) {
2183
- return gl2 ? gl2.getParameter(pname) : defaultValue || 0;
2184
+ return gl22 ? gl22.getParameter(pname) : defaultValue || 0;
2184
2185
  }
2185
2186
  return {
2186
2187
  [import_constants6.GL.ALIASED_LINE_WIDTH_RANGE]: get(import_constants6.GL.ALIASED_LINE_WIDTH_RANGE),
@@ -2285,22 +2286,22 @@ var import_constants11 = require("@luma.gl/constants");
2285
2286
  // src/context/state-tracker/with-parameters.ts
2286
2287
  function withParameters(device, parameters, func) {
2287
2288
  const webglDevice = WebGLDevice.attach(device);
2288
- const gl = webglDevice.gl;
2289
+ const gl2 = webglDevice.gl;
2289
2290
  if (isObjectEmpty2(parameters)) {
2290
2291
  return func(device);
2291
2292
  }
2292
2293
  const { nocatch = true } = parameters;
2293
- pushContextState(gl);
2294
- setParameters(gl, parameters);
2294
+ pushContextState(gl2);
2295
+ setParameters(gl2, parameters);
2295
2296
  let value;
2296
2297
  if (nocatch) {
2297
- value = func(gl);
2298
- popContextState(gl);
2298
+ value = func(gl2);
2299
+ popContextState(gl2);
2299
2300
  } else {
2300
2301
  try {
2301
- value = func(gl);
2302
+ value = func(gl2);
2302
2303
  } finally {
2303
- popContextState(gl);
2304
+ popContextState(gl2);
2304
2305
  }
2305
2306
  }
2306
2307
  return value;
@@ -2344,24 +2345,24 @@ function withDeviceParameters(device, parameters, func) {
2344
2345
  }
2345
2346
  function setDeviceParameters(device, parameters) {
2346
2347
  const webglDevice = WebGLDevice.attach(device);
2347
- const { gl } = webglDevice;
2348
+ const { gl: gl2 } = webglDevice;
2348
2349
  if (parameters.cullMode) {
2349
2350
  switch (parameters.cullMode) {
2350
2351
  case "none":
2351
- gl.disable(import_constants7.GL.CULL_FACE);
2352
+ gl2.disable(import_constants7.GL.CULL_FACE);
2352
2353
  break;
2353
2354
  case "front":
2354
- gl.enable(import_constants7.GL.CULL_FACE);
2355
- gl.cullFace(import_constants7.GL.FRONT);
2355
+ gl2.enable(import_constants7.GL.CULL_FACE);
2356
+ gl2.cullFace(import_constants7.GL.FRONT);
2356
2357
  break;
2357
2358
  case "back":
2358
- gl.enable(import_constants7.GL.CULL_FACE);
2359
- gl.cullFace(import_constants7.GL.BACK);
2359
+ gl2.enable(import_constants7.GL.CULL_FACE);
2360
+ gl2.cullFace(import_constants7.GL.BACK);
2360
2361
  break;
2361
2362
  }
2362
2363
  }
2363
2364
  if (parameters.frontFace) {
2364
- gl.frontFace(
2365
+ gl2.frontFace(
2365
2366
  map("frontFace", parameters.frontFace, {
2366
2367
  ccw: import_constants7.GL.CCW,
2367
2368
  cw: import_constants7.GL.CW
@@ -2369,19 +2370,19 @@ function setDeviceParameters(device, parameters) {
2369
2370
  );
2370
2371
  }
2371
2372
  if (parameters.depthBias !== void 0) {
2372
- gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
2373
+ gl2.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
2373
2374
  }
2374
2375
  if (parameters.depthWriteEnabled !== void 0) {
2375
- gl.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
2376
+ gl2.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
2376
2377
  }
2377
2378
  if (parameters.depthCompare) {
2378
- parameters.depthCompare !== "always" ? gl.enable(import_constants7.GL.DEPTH_TEST) : gl.disable(import_constants7.GL.DEPTH_TEST);
2379
- gl.depthFunc(convertCompareFunction("depthCompare", parameters.depthCompare));
2379
+ parameters.depthCompare !== "always" ? gl2.enable(import_constants7.GL.DEPTH_TEST) : gl2.disable(import_constants7.GL.DEPTH_TEST);
2380
+ gl2.depthFunc(convertCompareFunction("depthCompare", parameters.depthCompare));
2380
2381
  }
2381
2382
  if (parameters.stencilWriteMask) {
2382
2383
  const mask = parameters.stencilWriteMask;
2383
- gl.stencilMaskSeparate(import_constants7.GL.FRONT, mask);
2384
- gl.stencilMaskSeparate(import_constants7.GL.BACK, mask);
2384
+ gl2.stencilMaskSeparate(import_constants7.GL.FRONT, mask);
2385
+ gl2.stencilMaskSeparate(import_constants7.GL.BACK, mask);
2385
2386
  }
2386
2387
  if (parameters.stencilReadMask) {
2387
2388
  import_api6.log.warn("stencilReadMask not supported under WebGL");
@@ -2389,9 +2390,9 @@ function setDeviceParameters(device, parameters) {
2389
2390
  if (parameters.stencilCompare) {
2390
2391
  const mask = parameters.stencilReadMask || 4294967295;
2391
2392
  const glValue = convertCompareFunction("depthCompare", parameters.stencilCompare);
2392
- parameters.stencilCompare !== "always" ? gl.enable(import_constants7.GL.STENCIL_TEST) : gl.disable(import_constants7.GL.STENCIL_TEST);
2393
- gl.stencilFuncSeparate(import_constants7.GL.FRONT, glValue, 0, mask);
2394
- gl.stencilFuncSeparate(import_constants7.GL.BACK, glValue, 0, mask);
2393
+ parameters.stencilCompare !== "always" ? gl2.enable(import_constants7.GL.STENCIL_TEST) : gl2.disable(import_constants7.GL.STENCIL_TEST);
2394
+ gl2.stencilFuncSeparate(import_constants7.GL.FRONT, glValue, 0, mask);
2395
+ gl2.stencilFuncSeparate(import_constants7.GL.BACK, glValue, 0, mask);
2395
2396
  }
2396
2397
  if (parameters.stencilPassOperation && parameters.stencilFailOperation && parameters.stencilDepthFailOperation) {
2397
2398
  const dppass = convertStencilOperation("stencilPassOperation", parameters.stencilPassOperation);
@@ -2400,8 +2401,8 @@ function setDeviceParameters(device, parameters) {
2400
2401
  "stencilDepthFailOperation",
2401
2402
  parameters.stencilDepthFailOperation
2402
2403
  );
2403
- gl.stencilOpSeparate(import_constants7.GL.FRONT, sfail, dpfail, dppass);
2404
- gl.stencilOpSeparate(import_constants7.GL.BACK, sfail, dpfail, dppass);
2404
+ gl2.stencilOpSeparate(import_constants7.GL.FRONT, sfail, dpfail, dppass);
2405
+ gl2.stencilOpSeparate(import_constants7.GL.BACK, sfail, dpfail, dppass);
2405
2406
  }
2406
2407
  }
2407
2408
  function convertCompareFunction(parameter, value) {
@@ -2947,18 +2948,18 @@ var _WEBGLTexture = class extends import_api10.Texture {
2947
2948
  width,
2948
2949
  height
2949
2950
  }));
2950
- const { gl } = this;
2951
- gl.bindTexture(this.target, this.handle);
2951
+ const { gl: gl2 } = this;
2952
+ gl2.bindTexture(this.target, this.handle);
2952
2953
  let dataType = null;
2953
2954
  ({ data, dataType } = this._getDataType({ data, compressed }));
2954
- let gl2;
2955
+ let gl22;
2955
2956
  withParameters(this.gl, parameters, () => {
2956
2957
  switch (dataType) {
2957
2958
  case "null":
2958
- gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
2959
+ gl2.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
2959
2960
  break;
2960
2961
  case "typed-array":
2961
- gl.texImage2D(
2962
+ gl2.texImage2D(
2962
2963
  target,
2963
2964
  level,
2964
2965
  glFormat,
@@ -2974,9 +2975,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
2974
2975
  );
2975
2976
  break;
2976
2977
  case "buffer":
2977
- gl2 = this.device.assertWebGL2();
2978
- gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data.handle || data);
2979
- gl2.texImage2D(
2978
+ gl22 = this.device.assertWebGL2();
2979
+ gl22.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data.handle || data);
2980
+ gl22.texImage2D(
2980
2981
  target,
2981
2982
  level,
2982
2983
  glFormat,
@@ -2987,11 +2988,11 @@ var _WEBGLTexture = class extends import_api10.Texture {
2987
2988
  type,
2988
2989
  offset
2989
2990
  );
2990
- gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, null);
2991
+ gl22.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, null);
2991
2992
  break;
2992
2993
  case "browser-object":
2993
2994
  if (this.device.isWebGL2) {
2994
- gl.texImage2D(
2995
+ gl2.texImage2D(
2995
2996
  target,
2996
2997
  level,
2997
2998
  glFormat,
@@ -3003,12 +3004,12 @@ var _WEBGLTexture = class extends import_api10.Texture {
3003
3004
  data
3004
3005
  );
3005
3006
  } else {
3006
- gl.texImage2D(target, level, glFormat, dataFormat, type, data);
3007
+ gl2.texImage2D(target, level, glFormat, dataFormat, type, data);
3007
3008
  }
3008
3009
  break;
3009
3010
  case "compressed":
3010
3011
  for (const [levelIndex, levelData] of data.entries()) {
3011
- gl.compressedTexImage2D(
3012
+ gl2.compressedTexImage2D(
3012
3013
  target,
3013
3014
  levelIndex,
3014
3015
  levelData.format,
@@ -3115,21 +3116,21 @@ var _WEBGLTexture = class extends import_api10.Texture {
3115
3116
  return this.gl.getParameter(import_constants11.GL.ACTIVE_TEXTURE) - import_constants11.GL.TEXTURE0;
3116
3117
  }
3117
3118
  bind(textureUnit = this.textureUnit) {
3118
- const { gl } = this;
3119
+ const { gl: gl2 } = this;
3119
3120
  if (textureUnit !== void 0) {
3120
3121
  this.textureUnit = textureUnit;
3121
- gl.activeTexture(gl.TEXTURE0 + textureUnit);
3122
+ gl2.activeTexture(gl2.TEXTURE0 + textureUnit);
3122
3123
  }
3123
- gl.bindTexture(this.target, this.handle);
3124
+ gl2.bindTexture(this.target, this.handle);
3124
3125
  return textureUnit;
3125
3126
  }
3126
3127
  unbind(textureUnit = this.textureUnit) {
3127
- const { gl } = this;
3128
+ const { gl: gl2 } = this;
3128
3129
  if (textureUnit !== void 0) {
3129
3130
  this.textureUnit = textureUnit;
3130
- gl.activeTexture(gl.TEXTURE0 + textureUnit);
3131
+ gl2.activeTexture(gl2.TEXTURE0 + textureUnit);
3131
3132
  }
3132
- gl.bindTexture(this.target, null);
3133
+ gl2.bindTexture(this.target, null);
3133
3134
  return textureUnit;
3134
3135
  }
3135
3136
  // PRIVATE METHODS
@@ -3195,7 +3196,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3195
3196
  /* eslint-disable max-statements, max-len */
3196
3197
  setCubeMapImageData(options) {
3197
3198
  return __async(this, null, function* () {
3198
- const { gl } = this;
3199
+ const { gl: gl2 } = this;
3199
3200
  const { width, height, pixels, data, format = import_constants11.GL.RGBA, type = import_constants11.GL.UNSIGNED_BYTE } = options;
3200
3201
  const imageDataMap = pixels || data;
3201
3202
  const resolvedFaces = yield Promise.all(
@@ -3211,9 +3212,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
3211
3212
  }
3212
3213
  resolvedFaces[index].forEach((image, lodLevel) => {
3213
3214
  if (width && height) {
3214
- gl.texImage2D(face, lodLevel, format, width, height, 0, format, type, image);
3215
+ gl2.texImage2D(face, lodLevel, format, width, height, 0, format, type, image);
3215
3216
  } else {
3216
- gl.texImage2D(face, lodLevel, format, format, type, image);
3217
+ gl2.texImage2D(face, lodLevel, format, format, type, image);
3217
3218
  }
3218
3219
  });
3219
3220
  });
@@ -3232,7 +3233,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3232
3233
  type = import_constants11.GL.UNSIGNED_BYTE
3233
3234
  // generateMipmap = false // TODO
3234
3235
  } = options;
3235
- const { gl } = this;
3236
+ const { gl: gl2 } = this;
3236
3237
  const imageData = pixels || data;
3237
3238
  this.bind();
3238
3239
  if (imageData instanceof Promise) {
@@ -3246,9 +3247,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
3246
3247
  )
3247
3248
  );
3248
3249
  } else if (this.width || this.height) {
3249
- gl.texImage2D(face, 0, format, width, height, 0, format, type, imageData);
3250
+ gl2.texImage2D(face, 0, format, width, height, 0, format, type, imageData);
3250
3251
  } else {
3251
- gl.texImage2D(face, 0, format, format, type, imageData);
3252
+ gl2.texImage2D(face, 0, format, format, type, imageData);
3252
3253
  }
3253
3254
  return this;
3254
3255
  }
@@ -3406,7 +3407,7 @@ var import_api12 = require("@luma.gl/api");
3406
3407
 
3407
3408
  // src/adapter/objects/constants-to-keys.ts
3408
3409
  var import_api11 = require("@luma.gl/api");
3409
- function getKeyValue(gl, name) {
3410
+ function getKeyValue(gl2, name) {
3410
3411
  if (typeof name !== "string") {
3411
3412
  return name;
3412
3413
  }
@@ -3415,7 +3416,7 @@ function getKeyValue(gl, name) {
3415
3416
  return number;
3416
3417
  }
3417
3418
  name = name.replace(/^.*\./, "");
3418
- const value = gl[name];
3419
+ const value = gl2[name];
3419
3420
  (0, import_api11.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
3420
3421
  return value;
3421
3422
  }
@@ -3429,11 +3430,11 @@ var WebGLResource = class extends import_api12.Resource {
3429
3430
  // Only meaningful for resources that allocate GPU memory
3430
3431
  this.byteLength = 0;
3431
3432
  this.device = WebGLDevice.attach(device);
3432
- const gl = this.device.gl;
3433
- assertWebGLContext(gl);
3433
+ const gl2 = this.device.gl;
3434
+ assertWebGLContext(gl2);
3434
3435
  const { id } = props || {};
3435
- this.gl = gl;
3436
- this.gl2 = gl;
3436
+ this.gl = gl2;
3437
+ this.gl2 = gl2;
3437
3438
  this.id = id || (0, import_api12.uid)(this.constructor.name);
3438
3439
  this._handle = props == null ? void 0 : props.handle;
3439
3440
  if (this._handle === void 0) {
@@ -3744,11 +3745,11 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3744
3745
  // PRIVATE
3745
3746
  /** Check the status */
3746
3747
  _checkStatus() {
3747
- const { gl } = this;
3748
- const prevHandle2 = gl.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, this.handle);
3749
- const status = gl.checkFramebufferStatus(import_constants13.GL.FRAMEBUFFER);
3750
- gl.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, prevHandle2 || null);
3751
- if (status !== gl.FRAMEBUFFER_COMPLETE) {
3748
+ const { gl: gl2 } = this;
3749
+ const prevHandle2 = gl2.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, this.handle);
3750
+ const status = gl2.checkFramebufferStatus(import_constants13.GL.FRAMEBUFFER);
3751
+ gl2.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, prevHandle2 || null);
3752
+ if (status !== gl2.FRAMEBUFFER_COMPLETE) {
3752
3753
  throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
3753
3754
  }
3754
3755
  }
@@ -3817,25 +3818,25 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3817
3818
  * @param level = 0 - mipmapLevel (must be 0 in WebGL1)
3818
3819
  */
3819
3820
  _attachTexture(attachment, texture, layer, level) {
3820
- const { gl, gl2 } = this.device;
3821
- gl.bindTexture(texture.target, texture.handle);
3821
+ const { gl: gl2, gl2: gl22 } = this.device;
3822
+ gl2.bindTexture(texture.target, texture.handle);
3822
3823
  switch (texture.target) {
3823
3824
  case import_constants13.GL.TEXTURE_2D_ARRAY:
3824
3825
  case import_constants13.GL.TEXTURE_3D:
3825
3826
  this.device.assertWebGL2();
3826
- gl2 == null ? void 0 : gl2.framebufferTextureLayer(import_constants13.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
3827
+ gl22 == null ? void 0 : gl22.framebufferTextureLayer(import_constants13.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
3827
3828
  break;
3828
3829
  case import_constants13.GL.TEXTURE_CUBE_MAP:
3829
3830
  const face = mapIndexToCubeMapFace(layer);
3830
- gl.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
3831
+ gl2.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
3831
3832
  break;
3832
3833
  case import_constants13.GL.TEXTURE_2D:
3833
- gl.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, import_constants13.GL.TEXTURE_2D, texture.handle, level);
3834
+ gl2.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, import_constants13.GL.TEXTURE_2D, texture.handle, level);
3834
3835
  break;
3835
3836
  default:
3836
3837
  (0, import_api14.assert)(false, "Illegal texture type");
3837
3838
  }
3838
- gl.bindTexture(texture.target, null);
3839
+ gl2.bindTexture(texture.target, null);
3839
3840
  }
3840
3841
  };
3841
3842
  function mapIndexToCubeMapFace(layer) {
@@ -3897,6 +3898,7 @@ var WebGLCanvasContext = class extends import_api15.CanvasContext {
3897
3898
  */
3898
3899
  resize(options) {
3899
3900
  if (this.canvas) {
3901
+ const devicePixelRatio = this.getDevicePixelRatio(options == null ? void 0 : options.useDevicePixels);
3900
3902
  this.setDevicePixelRatio(devicePixelRatio, options);
3901
3903
  return;
3902
3904
  }
@@ -3972,9 +3974,9 @@ function initializeSpectorJS(props) {
3972
3974
  var import_api17 = require("@luma.gl/api");
3973
3975
  var import_constants14 = require("@luma.gl/constants");
3974
3976
  var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
3975
- function getContextData2(gl) {
3976
- gl.luma = gl.luma || {};
3977
- return gl.luma;
3977
+ function getContextData2(gl2) {
3978
+ gl2.luma = gl2.luma || {};
3979
+ return gl2.luma;
3978
3980
  }
3979
3981
  function loadWebGLDeveloperTools() {
3980
3982
  return __async(this, null, function* () {
@@ -3985,28 +3987,28 @@ function loadWebGLDeveloperTools() {
3985
3987
  }
3986
3988
  });
3987
3989
  }
3988
- function makeDebugContext(gl, props = {}) {
3989
- if (!gl) {
3990
+ function makeDebugContext(gl2, props = {}) {
3991
+ if (!gl2) {
3990
3992
  return null;
3991
3993
  }
3992
- return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
3994
+ return props.debug ? getDebugContext(gl2, props) : getRealContext(gl2);
3993
3995
  }
3994
- function getRealContext(gl) {
3995
- const data = getContextData2(gl);
3996
- return data.realContext ? data.realContext : gl;
3996
+ function getRealContext(gl2) {
3997
+ const data = getContextData2(gl2);
3998
+ return data.realContext ? data.realContext : gl2;
3997
3999
  }
3998
- function getDebugContext(gl, props) {
4000
+ function getDebugContext(gl2, props) {
3999
4001
  if (!globalThis.WebGLDebugUtils) {
4000
4002
  import_api17.log.warn("webgl-debug not loaded")();
4001
- return gl;
4003
+ return gl2;
4002
4004
  }
4003
- const data = getContextData2(gl);
4005
+ const data = getContextData2(gl2);
4004
4006
  if (data.debugContext) {
4005
4007
  return data.debugContext;
4006
4008
  }
4007
- globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants14.GL), gl));
4009
+ globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants14.GL), gl2));
4008
4010
  const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
4009
- gl,
4011
+ gl2,
4010
4012
  onGLError.bind(null, props),
4011
4013
  onValidateGLFunc.bind(null, props)
4012
4014
  );
@@ -4017,10 +4019,10 @@ function getDebugContext(gl, props) {
4017
4019
  }
4018
4020
  class WebGLDebugContext {
4019
4021
  }
4020
- Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));
4022
+ Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl2));
4021
4023
  Object.setPrototypeOf(WebGLDebugContext, glDebug);
4022
4024
  const debugContext = Object.create(WebGLDebugContext);
4023
- data.realContext = gl;
4025
+ data.realContext = gl2;
4024
4026
  data.debugContext = debugContext;
4025
4027
  debugContext.debug = true;
4026
4028
  return debugContext;
@@ -4390,13 +4392,13 @@ var BufferWithAccessor = class extends WEBGLBuffer {
4390
4392
  */
4391
4393
  copyData(options) {
4392
4394
  const { sourceBuffer, readOffset = 0, writeOffset = 0, size } = options;
4393
- const { gl, gl2 } = this;
4394
- assertWebGL2Context(gl);
4395
- gl.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, sourceBuffer.handle);
4396
- gl.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, this.handle);
4397
- gl2 == null ? void 0 : gl2.copyBufferSubData(import_constants17.GL.COPY_READ_BUFFER, import_constants17.GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
4398
- gl.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, null);
4399
- gl.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, null);
4395
+ const { gl: gl2, gl2: gl22 } = this;
4396
+ assertWebGL2Context(gl2);
4397
+ gl2.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, sourceBuffer.handle);
4398
+ gl2.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, this.handle);
4399
+ gl22 == null ? void 0 : gl22.copyBufferSubData(import_constants17.GL.COPY_READ_BUFFER, import_constants17.GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
4400
+ gl2.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, null);
4401
+ gl2.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, null);
4400
4402
  this.debugData = null;
4401
4403
  return this;
4402
4404
  }
@@ -4650,12 +4652,12 @@ var WEBGLShader = class extends import_api20.Shader {
4650
4652
  const addGLSLVersion = (source2) => source2.startsWith("#version ") ? source2 : `#version 100
4651
4653
  ${source2}`;
4652
4654
  source = addGLSLVersion(source);
4653
- const { gl } = this.device;
4654
- gl.shaderSource(this.handle, source);
4655
- gl.compileShader(this.handle);
4656
- const compileStatus = gl.getShaderParameter(this.handle, import_constants18.GL.COMPILE_STATUS);
4655
+ const { gl: gl2 } = this.device;
4656
+ gl2.shaderSource(this.handle, source);
4657
+ gl2.compileShader(this.handle);
4658
+ const compileStatus = gl2.getShaderParameter(this.handle, import_constants18.GL.COMPILE_STATUS);
4657
4659
  if (!compileStatus) {
4658
- const shaderLog = gl.getShaderInfoLog(this.handle);
4660
+ const shaderLog = gl2.getShaderInfoLog(this.handle);
4659
4661
  const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
4660
4662
  const messages = parsedLog.filter((message2) => message2.type === "error");
4661
4663
  const formattedLog = (0, import_api20.formatCompilerLog)(messages, source);
@@ -4904,9 +4906,9 @@ function getDataFormat(type) {
4904
4906
  }
4905
4907
 
4906
4908
  // src/adapter/helpers/get-shader-layout.ts
4907
- function getShaderLayout(gl, program) {
4909
+ function getShaderLayout(gl2, program) {
4908
4910
  var _a, _b;
4909
- const programBindings = getProgramBindings(gl, program);
4911
+ const programBindings = getProgramBindings(gl2, program);
4910
4912
  const shaderLayout = {
4911
4913
  attributes: [],
4912
4914
  bindings: []
@@ -4965,26 +4967,26 @@ function getShaderLayout(gl, program) {
4965
4967
  }
4966
4968
  return shaderLayout;
4967
4969
  }
4968
- function getProgramBindings(gl, program) {
4970
+ function getProgramBindings(gl2, program) {
4969
4971
  const config = {
4970
- attributes: readAttributeBindings(gl, program),
4971
- uniforms: readUniformBindings(gl, program),
4972
- uniformBlocks: readUniformBlocks(gl, program),
4973
- varyings: readVaryings(gl, program)
4972
+ attributes: readAttributeBindings(gl2, program),
4973
+ uniforms: readUniformBindings(gl2, program),
4974
+ uniformBlocks: readUniformBlocks(gl2, program),
4975
+ varyings: readVaryings(gl2, program)
4974
4976
  };
4975
4977
  Object.seal(config);
4976
4978
  return config;
4977
4979
  }
4978
- function readAttributeBindings(gl, program) {
4980
+ function readAttributeBindings(gl2, program) {
4979
4981
  const attributes = [];
4980
- const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
4982
+ const count = gl2.getProgramParameter(program, gl2.ACTIVE_ATTRIBUTES);
4981
4983
  for (let index = 0; index < count; index++) {
4982
- const activeInfo = gl.getActiveAttrib(program, index);
4984
+ const activeInfo = gl2.getActiveAttrib(program, index);
4983
4985
  if (!activeInfo) {
4984
4986
  throw new Error("activeInfo");
4985
4987
  }
4986
4988
  const { name, type: compositeType, size } = activeInfo;
4987
- const location = gl.getAttribLocation(program, name);
4989
+ const location = gl2.getAttribLocation(program, name);
4988
4990
  if (location >= 0) {
4989
4991
  const { glType, components } = decodeAttributeType(compositeType);
4990
4992
  const accessor = { type: glType, size: size * components };
@@ -4998,15 +5000,15 @@ function readAttributeBindings(gl, program) {
4998
5000
  attributes.sort((a, b) => a.location - b.location);
4999
5001
  return attributes;
5000
5002
  }
5001
- function readVaryings(gl, program) {
5002
- if (!isWebGL2(gl)) {
5003
+ function readVaryings(gl2, program) {
5004
+ if (!isWebGL2(gl2)) {
5003
5005
  return [];
5004
5006
  }
5005
- const gl2 = gl;
5007
+ const gl22 = gl2;
5006
5008
  const varyings = [];
5007
- const count = gl.getProgramParameter(program, import_constants22.GL.TRANSFORM_FEEDBACK_VARYINGS);
5009
+ const count = gl2.getProgramParameter(program, import_constants22.GL.TRANSFORM_FEEDBACK_VARYINGS);
5008
5010
  for (let location = 0; location < count; location++) {
5009
- const activeInfo = gl2.getTransformFeedbackVarying(program, location);
5011
+ const activeInfo = gl22.getTransformFeedbackVarying(program, location);
5010
5012
  if (!activeInfo) {
5011
5013
  throw new Error("activeInfo");
5012
5014
  }
@@ -5019,17 +5021,17 @@ function readVaryings(gl, program) {
5019
5021
  varyings.sort((a, b) => a.location - b.location);
5020
5022
  return varyings;
5021
5023
  }
5022
- function readUniformBindings(gl, program) {
5024
+ function readUniformBindings(gl2, program) {
5023
5025
  const uniforms = [];
5024
- const uniformCount = gl.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORMS);
5026
+ const uniformCount = gl2.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORMS);
5025
5027
  for (let i = 0; i < uniformCount; i++) {
5026
- const activeInfo = gl.getActiveUniform(program, i);
5028
+ const activeInfo = gl2.getActiveUniform(program, i);
5027
5029
  if (!activeInfo) {
5028
5030
  throw new Error("activeInfo");
5029
5031
  }
5030
5032
  const { name: rawName, size, type } = activeInfo;
5031
5033
  const { name, isArray: isArray2 } = parseUniformName(rawName);
5032
- let webglLocation = gl.getUniformLocation(program, name);
5034
+ let webglLocation = gl2.getUniformLocation(program, name);
5033
5035
  const uniformInfo = {
5034
5036
  // WebGL locations are uniquely typed but just numbers
5035
5037
  location: webglLocation,
@@ -5042,7 +5044,7 @@ function readUniformBindings(gl, program) {
5042
5044
  if (uniformInfo.size > 1) {
5043
5045
  for (let j = 0; j < uniformInfo.size; j++) {
5044
5046
  const elementName = `${name}[${j}]`;
5045
- webglLocation = gl.getUniformLocation(program, elementName);
5047
+ webglLocation = gl2.getUniformLocation(program, elementName);
5046
5048
  const arrayElementUniformInfo = __spreadProps(__spreadValues({}, uniformInfo), {
5047
5049
  name: elementName,
5048
5050
  location: webglLocation
@@ -5053,17 +5055,17 @@ function readUniformBindings(gl, program) {
5053
5055
  }
5054
5056
  return uniforms;
5055
5057
  }
5056
- function readUniformBlocks(gl, program) {
5057
- if (!isWebGL2(gl)) {
5058
+ function readUniformBlocks(gl2, program) {
5059
+ if (!isWebGL2(gl2)) {
5058
5060
  return [];
5059
5061
  }
5060
- const gl2 = gl;
5061
- const getBlockParameter = (blockIndex, pname) => gl2.getActiveUniformBlockParameter(program, blockIndex, pname);
5062
+ const gl22 = gl2;
5063
+ const getBlockParameter = (blockIndex, pname) => gl22.getActiveUniformBlockParameter(program, blockIndex, pname);
5062
5064
  const uniformBlocks = [];
5063
- const blockCount = gl2.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORM_BLOCKS);
5065
+ const blockCount = gl22.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORM_BLOCKS);
5064
5066
  for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
5065
5067
  const blockInfo = {
5066
- name: gl2.getActiveUniformBlockName(program, blockIndex) || "",
5068
+ name: gl22.getActiveUniformBlockName(program, blockIndex) || "",
5067
5069
  location: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_BINDING),
5068
5070
  byteLength: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_DATA_SIZE),
5069
5071
  vertex: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
@@ -5072,12 +5074,12 @@ function readUniformBlocks(gl, program) {
5072
5074
  uniforms: []
5073
5075
  };
5074
5076
  const uniformIndices = getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) || [];
5075
- const uniformType = gl2.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_TYPE);
5076
- const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_SIZE);
5077
- const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_OFFSET);
5078
- const uniformStride = gl2.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_ARRAY_STRIDE);
5077
+ const uniformType = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_TYPE);
5078
+ const uniformArrayLength = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_SIZE);
5079
+ const uniformOffset = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_OFFSET);
5080
+ const uniformStride = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_ARRAY_STRIDE);
5079
5081
  for (let i = 0; i < blockInfo.uniformCount; ++i) {
5080
- const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);
5082
+ const activeInfo = gl22.getActiveUniform(program, uniformIndices[i]);
5081
5083
  if (!activeInfo) {
5082
5084
  throw new Error("activeInfo");
5083
5085
  }
@@ -5144,8 +5146,8 @@ function parseUniformName(name) {
5144
5146
 
5145
5147
  // src/adapter/helpers/set-uniform.ts
5146
5148
  var import_constants23 = require("@luma.gl/constants");
5147
- function setUniform(gl, location, type, value) {
5148
- const gl2 = gl;
5149
+ function setUniform(gl2, location, type, value) {
5150
+ const gl22 = gl2;
5149
5151
  if (typeof value === "number") {
5150
5152
  switch (type) {
5151
5153
  case import_constants23.GL.SAMPLER_2D:
@@ -5163,7 +5165,7 @@ function setUniform(gl, location, type, value) {
5163
5165
  case import_constants23.GL.UNSIGNED_INT_SAMPLER_3D:
5164
5166
  case import_constants23.GL.UNSIGNED_INT_SAMPLER_CUBE:
5165
5167
  case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
5166
- return gl.uniform1i(location, value);
5168
+ return gl2.uniform1i(location, value);
5167
5169
  }
5168
5170
  }
5169
5171
  if (value === true) {
@@ -5175,55 +5177,55 @@ function setUniform(gl, location, type, value) {
5175
5177
  const arrayValue = typeof value === "number" ? [value] : value;
5176
5178
  switch (type) {
5177
5179
  case import_constants23.GL.FLOAT:
5178
- return gl.uniform1fv(location, arrayValue);
5180
+ return gl2.uniform1fv(location, arrayValue);
5179
5181
  case import_constants23.GL.FLOAT_VEC2:
5180
- return gl.uniform2fv(location, arrayValue);
5182
+ return gl2.uniform2fv(location, arrayValue);
5181
5183
  case import_constants23.GL.FLOAT_VEC3:
5182
- return gl.uniform3fv(location, arrayValue);
5184
+ return gl2.uniform3fv(location, arrayValue);
5183
5185
  case import_constants23.GL.FLOAT_VEC4:
5184
- return gl.uniform4fv(location, arrayValue);
5186
+ return gl2.uniform4fv(location, arrayValue);
5185
5187
  case import_constants23.GL.INT:
5186
- return gl.uniform1iv(location, arrayValue);
5188
+ return gl2.uniform1iv(location, arrayValue);
5187
5189
  case import_constants23.GL.INT_VEC2:
5188
- return gl.uniform2iv(location, arrayValue);
5190
+ return gl2.uniform2iv(location, arrayValue);
5189
5191
  case import_constants23.GL.INT_VEC3:
5190
- return gl.uniform3iv(location, arrayValue);
5192
+ return gl2.uniform3iv(location, arrayValue);
5191
5193
  case import_constants23.GL.INT_VEC4:
5192
- return gl.uniform4iv(location, arrayValue);
5194
+ return gl2.uniform4iv(location, arrayValue);
5193
5195
  case import_constants23.GL.BOOL:
5194
- return gl.uniform1iv(location, arrayValue);
5196
+ return gl2.uniform1iv(location, arrayValue);
5195
5197
  case import_constants23.GL.BOOL_VEC2:
5196
- return gl.uniform2iv(location, arrayValue);
5198
+ return gl2.uniform2iv(location, arrayValue);
5197
5199
  case import_constants23.GL.BOOL_VEC3:
5198
- return gl.uniform3iv(location, arrayValue);
5200
+ return gl2.uniform3iv(location, arrayValue);
5199
5201
  case import_constants23.GL.BOOL_VEC4:
5200
- return gl.uniform4iv(location, arrayValue);
5202
+ return gl2.uniform4iv(location, arrayValue);
5201
5203
  case import_constants23.GL.UNSIGNED_INT:
5202
- return gl2.uniform1uiv(location, arrayValue, 1);
5204
+ return gl22.uniform1uiv(location, arrayValue, 1);
5203
5205
  case import_constants23.GL.UNSIGNED_INT_VEC2:
5204
- return gl2.uniform2uiv(location, arrayValue, 2);
5206
+ return gl22.uniform2uiv(location, arrayValue, 2);
5205
5207
  case import_constants23.GL.UNSIGNED_INT_VEC3:
5206
- return gl2.uniform3uiv(location, arrayValue, 3);
5208
+ return gl22.uniform3uiv(location, arrayValue, 3);
5207
5209
  case import_constants23.GL.UNSIGNED_INT_VEC4:
5208
- return gl2.uniform4uiv(location, arrayValue, 4);
5210
+ return gl22.uniform4uiv(location, arrayValue, 4);
5209
5211
  case import_constants23.GL.FLOAT_MAT2:
5210
- return gl.uniformMatrix2fv(location, false, arrayValue);
5212
+ return gl2.uniformMatrix2fv(location, false, arrayValue);
5211
5213
  case import_constants23.GL.FLOAT_MAT3:
5212
- return gl.uniformMatrix3fv(location, false, arrayValue);
5214
+ return gl2.uniformMatrix3fv(location, false, arrayValue);
5213
5215
  case import_constants23.GL.FLOAT_MAT4:
5214
- return gl.uniformMatrix4fv(location, false, arrayValue);
5216
+ return gl2.uniformMatrix4fv(location, false, arrayValue);
5215
5217
  case import_constants23.GL.FLOAT_MAT2x3:
5216
- return gl2.uniformMatrix2x3fv(location, false, arrayValue);
5218
+ return gl22.uniformMatrix2x3fv(location, false, arrayValue);
5217
5219
  case import_constants23.GL.FLOAT_MAT2x4:
5218
- return gl2.uniformMatrix2x4fv(location, false, arrayValue);
5220
+ return gl22.uniformMatrix2x4fv(location, false, arrayValue);
5219
5221
  case import_constants23.GL.FLOAT_MAT3x2:
5220
- return gl2.uniformMatrix3x2fv(location, false, arrayValue);
5222
+ return gl22.uniformMatrix3x2fv(location, false, arrayValue);
5221
5223
  case import_constants23.GL.FLOAT_MAT3x4:
5222
- return gl2.uniformMatrix3x4fv(location, false, arrayValue);
5224
+ return gl22.uniformMatrix3x4fv(location, false, arrayValue);
5223
5225
  case import_constants23.GL.FLOAT_MAT4x2:
5224
- return gl2.uniformMatrix4x2fv(location, false, arrayValue);
5226
+ return gl22.uniformMatrix4x2fv(location, false, arrayValue);
5225
5227
  case import_constants23.GL.FLOAT_MAT4x3:
5226
- return gl2.uniformMatrix4x3fv(location, false, arrayValue);
5228
+ return gl22.uniformMatrix4x3fv(location, false, arrayValue);
5227
5229
  }
5228
5230
  throw new Error("Illegal uniform");
5229
5231
  }
@@ -5265,18 +5267,18 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
5265
5267
  return this.setElementBuffer(buffer, accessor);
5266
5268
  }
5267
5269
  const { size, type, stride, offset, normalized, integer, divisor } = accessor;
5268
- const { gl, gl2 } = this;
5270
+ const { gl: gl2, gl2: gl22 } = this;
5269
5271
  location = Number(location);
5270
5272
  this.bind(() => {
5271
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);
5273
+ gl2.bindBuffer(gl2.ARRAY_BUFFER, buffer.handle);
5272
5274
  if (integer) {
5273
5275
  this.device.assertWebGL2();
5274
- gl2.vertexAttribIPointer(location, size, type, stride, offset);
5276
+ gl22.vertexAttribIPointer(location, size, type, stride, offset);
5275
5277
  } else {
5276
- gl.vertexAttribPointer(location, size, type, normalized, stride, offset);
5278
+ gl2.vertexAttribPointer(location, size, type, normalized, stride, offset);
5277
5279
  }
5278
- gl.enableVertexAttribArray(location);
5279
- gl2.vertexAttribDivisor(location, divisor || 0);
5280
+ gl2.enableVertexAttribArray(location);
5281
+ gl22.vertexAttribDivisor(location, divisor || 0);
5280
5282
  });
5281
5283
  return this;
5282
5284
  }
@@ -5462,21 +5464,21 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
5462
5464
  // setAttributes(attributes: Record<string, Buffer>): void {}
5463
5465
  // setBindings(bindings: Record<string, Binding>): void {}
5464
5466
  _compileAndLink() {
5465
- const { gl } = this.device;
5466
- gl.attachShader(this.handle, this.vs.handle);
5467
- gl.attachShader(this.handle, this.fs.handle);
5467
+ const { gl: gl2 } = this.device;
5468
+ gl2.attachShader(this.handle, this.vs.handle);
5469
+ gl2.attachShader(this.handle, this.fs.handle);
5468
5470
  import_api23.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
5469
- gl.linkProgram(this.handle);
5471
+ gl2.linkProgram(this.handle);
5470
5472
  import_api23.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
5471
- if (gl.debug || import_api23.log.level > 0) {
5472
- const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);
5473
+ if (gl2.debug || import_api23.log.level > 0) {
5474
+ const linked = gl2.getProgramParameter(this.handle, gl2.LINK_STATUS);
5473
5475
  if (!linked) {
5474
- throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);
5476
+ throw new Error(`Error linking: ${gl2.getProgramInfoLog(this.handle)}`);
5475
5477
  }
5476
- gl.validateProgram(this.handle);
5477
- const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);
5478
+ gl2.validateProgram(this.handle);
5479
+ const validated = gl2.getProgramParameter(this.handle, gl2.VALIDATE_STATUS);
5478
5480
  if (!validated) {
5479
- throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);
5481
+ throw new Error(`Error validating: ${gl2.getProgramInfoLog(this.handle)}`);
5480
5482
  }
5481
5483
  }
5482
5484
  }
@@ -5882,13 +5884,13 @@ var _WebGLDevice = class extends import_api26.Device {
5882
5884
  message: "Computer entered sleep mode, or too many apps or browser tabs are using the GPU."
5883
5885
  });
5884
5886
  };
5885
- let gl = props.gl || null;
5886
- gl = gl || ((0, import_env2.isBrowser)() ? createBrowserContext(this.canvasContext.canvas, __spreadProps(__spreadValues({}, props), { onContextLost })) : null);
5887
- gl = gl || (!(0, import_env2.isBrowser)() ? createHeadlessContext(__spreadProps(__spreadValues({}, props), { onContextLost })) : null);
5888
- if (!gl) {
5887
+ let gl2 = props.gl || null;
5888
+ gl2 = gl2 || ((0, import_env2.isBrowser)() ? createBrowserContext(this.canvasContext.canvas, __spreadProps(__spreadValues({}, props), { onContextLost })) : null);
5889
+ gl2 = gl2 || (!(0, import_env2.isBrowser)() ? createHeadlessContext(__spreadProps(__spreadValues({}, props), { onContextLost })) : null);
5890
+ if (!gl2) {
5889
5891
  throw new Error("WebGL context creation failed");
5890
5892
  }
5891
- this.handle = gl;
5893
+ this.handle = gl2;
5892
5894
  this.gl = this.handle;
5893
5895
  this.gl2 = this.gl;
5894
5896
  this.isWebGL2 = isWebGL22(this.gl);
@@ -5938,17 +5940,17 @@ var _WebGLDevice = class extends import_api26.Device {
5938
5940
  * @param gl
5939
5941
  * @returns
5940
5942
  */
5941
- static attach(gl) {
5942
- if (gl instanceof _WebGLDevice) {
5943
- return gl;
5943
+ static attach(gl2) {
5944
+ if (gl2 instanceof _WebGLDevice) {
5945
+ return gl2;
5944
5946
  }
5945
- if ((gl == null ? void 0 : gl.device) instanceof import_api26.Device) {
5946
- return gl.device;
5947
+ if ((gl2 == null ? void 0 : gl2.device) instanceof import_api26.Device) {
5948
+ return gl2.device;
5947
5949
  }
5948
- if (!isWebGL3(gl)) {
5950
+ if (!isWebGL3(gl2)) {
5949
5951
  throw new Error("Invalid WebGLRenderingContext");
5950
5952
  }
5951
- return new _WebGLDevice({ gl });
5953
+ return new _WebGLDevice({ gl: gl2 });
5952
5954
  }
5953
5955
  static create() {
5954
5956
  return __async(this, arguments, function* (props = {}) {
@@ -6099,11 +6101,11 @@ var _WebGLDevice = class extends import_api26.Device {
6099
6101
  * Be aware that there are some duplicates especially for constants that are 0,
6100
6102
  * so this isn't guaranteed to return the right key in all cases.
6101
6103
  */
6102
- getGLKey(value, gl) {
6103
- gl = gl || this.gl2 || this.gl;
6104
+ getGLKey(value, gl2) {
6105
+ gl2 = gl2 || this.gl2 || this.gl;
6104
6106
  const number = Number(value);
6105
- for (const key in gl) {
6106
- if (gl[key] === number) {
6107
+ for (const key in gl2) {
6108
+ if (gl2[key] === number) {
6107
6109
  return `GL.${key}`;
6108
6110
  }
6109
6111
  }
@@ -6115,20 +6117,20 @@ var WebGLDevice = _WebGLDevice;
6115
6117
  // Public `Device` API
6116
6118
  //
6117
6119
  WebGLDevice.type = "webgl";
6118
- function isWebGL3(gl) {
6119
- if (typeof WebGLRenderingContext !== "undefined" && gl instanceof WebGLRenderingContext) {
6120
+ function isWebGL3(gl2) {
6121
+ if (typeof WebGLRenderingContext !== "undefined" && gl2 instanceof WebGLRenderingContext) {
6120
6122
  return true;
6121
6123
  }
6122
- if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
6124
+ if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
6123
6125
  return true;
6124
6126
  }
6125
- return Boolean(gl && Number.isFinite(gl._version));
6127
+ return Boolean(gl2 && Number.isFinite(gl2._version));
6126
6128
  }
6127
- function isWebGL22(gl) {
6128
- if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
6129
+ function isWebGL22(gl2) {
6130
+ if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
6129
6131
  return true;
6130
6132
  }
6131
- return Boolean(gl && gl._version === 2);
6133
+ return Boolean(gl2 && gl2._version === 2);
6132
6134
  }
6133
6135
 
6134
6136
  // src/classic/clear.ts
@@ -6137,8 +6139,8 @@ var GL_DEPTH_BUFFER_BIT2 = 256;
6137
6139
  var GL_STENCIL_BUFFER_BIT2 = 1024;
6138
6140
  var GL_COLOR_BUFFER_BIT2 = 16384;
6139
6141
  var ERR_ARGUMENTS = "clear: bad arguments";
6140
- function clear(gl, options) {
6141
- const device = WebGLDevice.attach(gl);
6142
+ function clear(gl2, options) {
6143
+ const device = WebGLDevice.attach(gl2);
6142
6144
  const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
6143
6145
  const parameters = {};
6144
6146
  if (framebuffer) {
@@ -6226,7 +6228,7 @@ function readPixelsToArray(source, options) {
6226
6228
  } = options || {};
6227
6229
  const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
6228
6230
  (0, import_api29.assert)(framebuffer);
6229
- const { gl, handle } = framebuffer;
6231
+ const { gl: gl2, handle } = framebuffer;
6230
6232
  sourceWidth = sourceWidth || framebuffer.width;
6231
6233
  sourceHeight = sourceHeight || framebuffer.height;
6232
6234
  if (sourceAttachment === import_constants28.GL.COLOR_ATTACHMENT0 && handle === null) {
@@ -6236,9 +6238,9 @@ function readPixelsToArray(source, options) {
6236
6238
  sourceType = sourceType || framebuffer.colorAttachments[attachment].type;
6237
6239
  target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
6238
6240
  sourceType = sourceType || getGLTypeFromTypedArray(target);
6239
- const prevHandle2 = gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
6240
- gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
6241
- gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle2 || null);
6241
+ const prevHandle2 = gl2.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
6242
+ gl2.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
6243
+ gl2.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle2 || null);
6242
6244
  if (deleteFramebuffer) {
6243
6245
  framebuffer.destroy();
6244
6246
  }
@@ -6278,6 +6280,98 @@ function readPixelsToBuffer(source, options) {
6278
6280
  }
6279
6281
  return target;
6280
6282
  }
6283
+ function copyToTexture(source, target, options) {
6284
+ const {
6285
+ sourceX = 0,
6286
+ sourceY = 0,
6287
+ // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
6288
+ targetMipmaplevel = 0,
6289
+ targetInternalFormat = import_constants28.GL.RGBA
6290
+ } = options || {};
6291
+ let {
6292
+ targetX,
6293
+ targetY,
6294
+ targetZ,
6295
+ width,
6296
+ // defaults to target width
6297
+ height
6298
+ // defaults to target height
6299
+ } = options || {};
6300
+ const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
6301
+ (0, import_api29.assert)(framebuffer);
6302
+ const webglFramebuffer = framebuffer;
6303
+ const { device, handle } = webglFramebuffer;
6304
+ const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
6305
+ targetX = targetX || 0;
6306
+ targetY = targetY || 0;
6307
+ targetZ = targetZ || 0;
6308
+ const prevHandle2 = device.gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
6309
+ (0, import_api29.assert)(target);
6310
+ let texture = null;
6311
+ let textureTarget;
6312
+ if (target instanceof import_api29.Texture) {
6313
+ texture = target;
6314
+ width = Number.isFinite(width) ? width : texture.width;
6315
+ height = Number.isFinite(height) ? height : texture.height;
6316
+ texture.bind(0);
6317
+ textureTarget = texture.target;
6318
+ } else {
6319
+ textureTarget = target;
6320
+ }
6321
+ if (!isSubCopy) {
6322
+ device.gl.copyTexImage2D(
6323
+ textureTarget,
6324
+ targetMipmaplevel,
6325
+ targetInternalFormat,
6326
+ sourceX,
6327
+ sourceY,
6328
+ width,
6329
+ height,
6330
+ 0
6331
+ /* border must be 0 */
6332
+ );
6333
+ } else {
6334
+ switch (textureTarget) {
6335
+ case import_constants28.GL.TEXTURE_2D:
6336
+ case import_constants28.GL.TEXTURE_CUBE_MAP:
6337
+ device.gl.copyTexSubImage2D(
6338
+ textureTarget,
6339
+ targetMipmaplevel,
6340
+ targetX,
6341
+ targetY,
6342
+ sourceX,
6343
+ sourceY,
6344
+ width,
6345
+ height
6346
+ );
6347
+ break;
6348
+ case import_constants28.GL.TEXTURE_2D_ARRAY:
6349
+ case import_constants28.GL.TEXTURE_3D:
6350
+ device.assertWebGL2();
6351
+ device.gl2.copyTexSubImage3D(
6352
+ textureTarget,
6353
+ targetMipmaplevel,
6354
+ targetX,
6355
+ targetY,
6356
+ targetZ,
6357
+ sourceX,
6358
+ sourceY,
6359
+ width,
6360
+ height
6361
+ );
6362
+ break;
6363
+ default:
6364
+ }
6365
+ }
6366
+ if (texture) {
6367
+ texture.unbind();
6368
+ }
6369
+ gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle2 || null);
6370
+ if (deleteFramebuffer) {
6371
+ framebuffer.destroy();
6372
+ }
6373
+ return texture;
6374
+ }
6281
6375
  function getFramebuffer2(source) {
6282
6376
  if (!(source instanceof import_api29.Framebuffer)) {
6283
6377
  return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };