@luma.gl/webgl 9.0.0-alpha.21 → 9.0.0-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts +1 -1
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/device-parameters.js +9 -9
  4. package/dist/adapter/converters/device-parameters.js.map +1 -1
  5. package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
  6. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  7. package/dist/adapter/converters/sampler-parameters.js +1 -1
  8. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  9. package/dist/adapter/converters/texture-formats.d.ts +29 -40
  10. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/texture-formats.js +152 -114
  12. package/dist/adapter/converters/texture-formats.js.map +1 -1
  13. package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
  14. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  15. package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
  16. package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
  17. package/dist/adapter/helpers/attribute-utils.js +1 -1
  18. package/dist/adapter/helpers/attribute-utils.js.map +1 -1
  19. package/dist/adapter/helpers/get-shader-info.d.ts +1 -1
  20. package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
  21. package/dist/adapter/helpers/get-shader-info.js.map +1 -1
  22. package/dist/adapter/helpers/uniforms.d.ts +7 -8
  23. package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
  24. package/dist/adapter/helpers/uniforms.js +4 -4
  25. package/dist/adapter/helpers/uniforms.js.map +1 -1
  26. package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
  27. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  28. package/dist/adapter/objects/constants-to-keys.js +0 -20
  29. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  30. package/dist/adapter/objects/webgl-renderbuffer.d.ts +12 -9
  31. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  32. package/dist/adapter/objects/webgl-renderbuffer.js +29 -19
  33. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  34. package/dist/adapter/objects/webgl-resource.d.ts +0 -1
  35. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  36. package/dist/adapter/objects/webgl-resource.js +4 -7
  37. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  38. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
  39. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  40. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-buffer.js +3 -2
  42. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  43. package/dist/adapter/resources/webgl-command-buffer.d.ts +13 -7
  44. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-command-buffer.js +168 -25
  46. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  47. package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -2
  48. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgl-command-encoder.js +6 -2
  50. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.d.ts +11 -14
  52. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgl-framebuffer.js +29 -79
  54. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  55. package/dist/adapter/resources/webgl-render-pass.d.ts +16 -1
  56. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pass.js +80 -0
  58. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  59. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
  60. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgl-render-pipeline.js +5 -5
  62. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  63. package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
  64. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  65. package/dist/adapter/resources/webgl-sampler.js +1 -1
  66. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  67. package/dist/adapter/resources/webgl-texture.d.ts +43 -23
  68. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  69. package/dist/adapter/resources/webgl-texture.js +32 -30
  70. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  71. package/dist/adapter/webgl-canvas-context.d.ts +1 -2
  72. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  73. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  74. package/dist/adapter/webgl-device.d.ts +13 -6
  75. package/dist/adapter/webgl-device.d.ts.map +1 -1
  76. package/dist/adapter/webgl-device.js +20 -2
  77. package/dist/adapter/webgl-device.js.map +1 -1
  78. package/dist/classic/buffer.d.ts +1 -2
  79. package/dist/classic/buffer.d.ts.map +1 -1
  80. package/dist/classic/buffer.js +0 -6
  81. package/dist/classic/buffer.js.map +1 -1
  82. package/dist/classic/clear.d.ts +22 -0
  83. package/dist/classic/clear.d.ts.map +1 -0
  84. package/dist/classic/clear.js +88 -0
  85. package/dist/classic/clear.js.map +1 -0
  86. package/dist/classic/copy-and-blit.d.ts +45 -0
  87. package/dist/classic/copy-and-blit.d.ts.map +1 -0
  88. package/dist/classic/copy-and-blit.js +136 -0
  89. package/dist/classic/copy-and-blit.js.map +1 -0
  90. package/dist/classic/format-utils.d.ts +3 -0
  91. package/dist/classic/format-utils.d.ts.map +1 -0
  92. package/dist/classic/format-utils.js +38 -0
  93. package/dist/classic/format-utils.js.map +1 -0
  94. package/dist/classic/typed-array-utils.d.ts +15 -17
  95. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  96. package/dist/classic/typed-array-utils.js +1 -1
  97. package/dist/classic/typed-array-utils.js.map +1 -1
  98. package/dist/context/context/create-browser-context.d.ts +17 -19
  99. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  100. package/dist/context/context/create-browser-context.js +4 -4
  101. package/dist/context/context/create-browser-context.js.map +1 -1
  102. package/dist/context/context/create-headless-context.d.ts +1 -1
  103. package/dist/context/context/create-headless-context.d.ts.map +1 -1
  104. package/dist/context/debug/spector.d.ts +1 -3
  105. package/dist/context/debug/spector.d.ts.map +1 -1
  106. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  107. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  108. package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
  109. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  110. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  111. package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -3
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  113. package/dist/context/parameters/webgl-parameter-tables.js +1 -1
  114. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  115. package/dist/dist.dev.js +1306 -659
  116. package/dist/index.cjs +1269 -897
  117. package/dist/index.d.ts +5 -2
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +4 -1
  120. package/dist/index.js.map +1 -1
  121. package/dist/types.d.ts +1 -1
  122. package/dist/types.d.ts.map +1 -1
  123. package/dist.min.js +22 -21
  124. package/package.json +7 -4
  125. package/src/adapter/converters/device-parameters.ts +46 -22
  126. package/src/adapter/converters/sampler-parameters.ts +1 -2
  127. package/src/adapter/converters/texture-formats.ts +242 -161
  128. package/src/adapter/helpers/attribute-utils.ts +1 -2
  129. package/src/adapter/helpers/get-shader-info.ts +3 -0
  130. package/src/adapter/helpers/uniforms.ts +9 -10
  131. package/src/adapter/objects/constants-to-keys.ts +0 -25
  132. package/src/adapter/objects/webgl-renderbuffer.ts +32 -29
  133. package/src/adapter/objects/webgl-resource.ts +4 -8
  134. package/src/adapter/resources/webgl-buffer.ts +4 -5
  135. package/src/adapter/resources/webgl-command-buffer.ts +328 -21
  136. package/src/adapter/resources/webgl-command-encoder.ts +7 -2
  137. package/src/adapter/resources/webgl-framebuffer.ts +63 -111
  138. package/src/adapter/resources/webgl-render-pass.ts +146 -2
  139. package/src/adapter/resources/webgl-render-pipeline.ts +7 -4
  140. package/src/adapter/resources/webgl-sampler.ts +1 -2
  141. package/src/adapter/resources/webgl-texture.ts +61 -43
  142. package/src/adapter/webgl-canvas-context.ts +2 -2
  143. package/src/adapter/webgl-device.ts +37 -8
  144. package/src/classic/buffer.ts +3 -3
  145. package/src/classic/clear.ts +110 -0
  146. package/src/classic/copy-and-blit.ts +189 -0
  147. package/src/classic/format-utils.ts +43 -0
  148. package/src/classic/typed-array-utils.ts +15 -26
  149. package/src/context/context/create-browser-context.ts +37 -30
  150. package/src/context/parameters/unified-parameter-api.ts +1 -1
  151. package/src/context/parameters/webgl-parameter-tables.ts +2 -2
  152. package/src/index.ts +10 -3
  153. package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
  154. package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
  155. package/dist/adapter/converters/renderbuffer-formats.js +0 -180
  156. package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
  157. package/dist/types/webgl.d.ts +0 -145
  158. package/dist/types/webgl.d.ts.map +0 -1
  159. package/dist/types/webgl.js +0 -2
  160. package/dist/types/webgl.js.map +0 -1
  161. package/src/.DS_Store +0 -0
  162. package/src/adapter/.DS_Store +0 -0
  163. package/src/adapter/converters/renderbuffer-formats.ts +0 -90
  164. package/src/context/.DS_Store +0 -0
  165. package/src/types/webgl.ts +0 -286
package/dist/index.cjs CHANGED
@@ -83,9 +83,12 @@ __export(src_exports, {
83
83
  WebGLCanvasContext: () => WebGLCanvasContext,
84
84
  WebGLDevice: () => WebGLDevice,
85
85
  WebGLResource: () => WebGLResource,
86
+ _TEXTURE_FORMATS: () => TEXTURE_FORMATS,
86
87
  _checkFloat32ColorAttachment: () => _checkFloat32ColorAttachment,
87
88
  assertWebGL2Context: () => assertWebGL2Context,
88
89
  assertWebGLContext: () => assertWebGLContext,
90
+ clear: () => clear,
91
+ convertGLToTextureFormat: () => convertGLToTextureFormat,
89
92
  getParameters: () => getParameters,
90
93
  getProgramBindings: () => getProgramBindings,
91
94
  getShaderLayout: () => getShaderLayout,
@@ -95,6 +98,8 @@ __export(src_exports, {
95
98
  polyfillContext: () => polyfillContext,
96
99
  popContextState: () => popContextState,
97
100
  pushContextState: () => pushContextState,
101
+ readPixelsToArray: () => readPixelsToArray,
102
+ readPixelsToBuffer: () => readPixelsToBuffer,
98
103
  registerHeadlessGL: () => registerHeadlessGL,
99
104
  resetParameters: () => resetParameters,
100
105
  setDeviceParameters: () => setDeviceParameters,
@@ -138,7 +143,7 @@ function createHeadlessContext(options) {
138
143
  }
139
144
 
140
145
  // src/adapter/webgl-device.ts
141
- var import_api24 = require("@luma.gl/api");
146
+ var import_api26 = require("@luma.gl/api");
142
147
  var import_env2 = require("@probe.gl/env");
143
148
 
144
149
  // src/context/polyfill/polyfill-context.ts
@@ -781,109 +786,109 @@ function installOverrides(gl, { target, target2 }) {
781
786
  var import_api4 = require("@luma.gl/api");
782
787
 
783
788
  // src/context/parameters/webgl-parameter-tables.ts
784
- var import_constants3 = __toESM(require("@luma.gl/constants"), 1);
789
+ var import_constants3 = require("@luma.gl/constants");
785
790
  var GL_PARAMETER_DEFAULTS = {
786
- [import_constants3.default.BLEND]: false,
787
- [import_constants3.default.BLEND_COLOR]: new Float32Array([0, 0, 0, 0]),
788
- [import_constants3.default.BLEND_EQUATION_RGB]: import_constants3.default.FUNC_ADD,
789
- [import_constants3.default.BLEND_EQUATION_ALPHA]: import_constants3.default.FUNC_ADD,
790
- [import_constants3.default.BLEND_SRC_RGB]: import_constants3.default.ONE,
791
- [import_constants3.default.BLEND_DST_RGB]: import_constants3.default.ZERO,
792
- [import_constants3.default.BLEND_SRC_ALPHA]: import_constants3.default.ONE,
793
- [import_constants3.default.BLEND_DST_ALPHA]: import_constants3.default.ZERO,
794
- [import_constants3.default.COLOR_CLEAR_VALUE]: new Float32Array([0, 0, 0, 0]),
791
+ [import_constants3.GL.BLEND]: false,
792
+ [import_constants3.GL.BLEND_COLOR]: new Float32Array([0, 0, 0, 0]),
793
+ [import_constants3.GL.BLEND_EQUATION_RGB]: import_constants3.GL.FUNC_ADD,
794
+ [import_constants3.GL.BLEND_EQUATION_ALPHA]: import_constants3.GL.FUNC_ADD,
795
+ [import_constants3.GL.BLEND_SRC_RGB]: import_constants3.GL.ONE,
796
+ [import_constants3.GL.BLEND_DST_RGB]: import_constants3.GL.ZERO,
797
+ [import_constants3.GL.BLEND_SRC_ALPHA]: import_constants3.GL.ONE,
798
+ [import_constants3.GL.BLEND_DST_ALPHA]: import_constants3.GL.ZERO,
799
+ [import_constants3.GL.COLOR_CLEAR_VALUE]: new Float32Array([0, 0, 0, 0]),
795
800
  // TBD
796
- [import_constants3.default.COLOR_WRITEMASK]: [true, true, true, true],
797
- [import_constants3.default.CULL_FACE]: false,
798
- [import_constants3.default.CULL_FACE_MODE]: import_constants3.default.BACK,
799
- [import_constants3.default.DEPTH_TEST]: false,
800
- [import_constants3.default.DEPTH_CLEAR_VALUE]: 1,
801
- [import_constants3.default.DEPTH_FUNC]: import_constants3.default.LESS,
802
- [import_constants3.default.DEPTH_RANGE]: new Float32Array([0, 1]),
801
+ [import_constants3.GL.COLOR_WRITEMASK]: [true, true, true, true],
802
+ [import_constants3.GL.CULL_FACE]: false,
803
+ [import_constants3.GL.CULL_FACE_MODE]: import_constants3.GL.BACK,
804
+ [import_constants3.GL.DEPTH_TEST]: false,
805
+ [import_constants3.GL.DEPTH_CLEAR_VALUE]: 1,
806
+ [import_constants3.GL.DEPTH_FUNC]: import_constants3.GL.LESS,
807
+ [import_constants3.GL.DEPTH_RANGE]: new Float32Array([0, 1]),
803
808
  // TBD
804
- [import_constants3.default.DEPTH_WRITEMASK]: true,
805
- [import_constants3.default.DITHER]: true,
806
- [import_constants3.default.CURRENT_PROGRAM]: null,
809
+ [import_constants3.GL.DEPTH_WRITEMASK]: true,
810
+ [import_constants3.GL.DITHER]: true,
811
+ [import_constants3.GL.CURRENT_PROGRAM]: null,
807
812
  // FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
808
- [import_constants3.default.FRAMEBUFFER_BINDING]: null,
809
- [import_constants3.default.RENDERBUFFER_BINDING]: null,
810
- [import_constants3.default.VERTEX_ARRAY_BINDING]: null,
811
- [import_constants3.default.ARRAY_BUFFER_BINDING]: null,
812
- [import_constants3.default.FRONT_FACE]: import_constants3.default.CCW,
813
- [import_constants3.default.GENERATE_MIPMAP_HINT]: import_constants3.default.DONT_CARE,
814
- [import_constants3.default.LINE_WIDTH]: 1,
815
- [import_constants3.default.POLYGON_OFFSET_FILL]: false,
816
- [import_constants3.default.POLYGON_OFFSET_FACTOR]: 0,
817
- [import_constants3.default.POLYGON_OFFSET_UNITS]: 0,
818
- [import_constants3.default.SAMPLE_ALPHA_TO_COVERAGE]: false,
819
- [import_constants3.default.SAMPLE_COVERAGE]: false,
820
- [import_constants3.default.SAMPLE_COVERAGE_VALUE]: 1,
821
- [import_constants3.default.SAMPLE_COVERAGE_INVERT]: false,
822
- [import_constants3.default.SCISSOR_TEST]: false,
813
+ [import_constants3.GL.FRAMEBUFFER_BINDING]: null,
814
+ [import_constants3.GL.RENDERBUFFER_BINDING]: null,
815
+ [import_constants3.GL.VERTEX_ARRAY_BINDING]: null,
816
+ [import_constants3.GL.ARRAY_BUFFER_BINDING]: null,
817
+ [import_constants3.GL.FRONT_FACE]: import_constants3.GL.CCW,
818
+ [import_constants3.GL.GENERATE_MIPMAP_HINT]: import_constants3.GL.DONT_CARE,
819
+ [import_constants3.GL.LINE_WIDTH]: 1,
820
+ [import_constants3.GL.POLYGON_OFFSET_FILL]: false,
821
+ [import_constants3.GL.POLYGON_OFFSET_FACTOR]: 0,
822
+ [import_constants3.GL.POLYGON_OFFSET_UNITS]: 0,
823
+ [import_constants3.GL.SAMPLE_ALPHA_TO_COVERAGE]: false,
824
+ [import_constants3.GL.SAMPLE_COVERAGE]: false,
825
+ [import_constants3.GL.SAMPLE_COVERAGE_VALUE]: 1,
826
+ [import_constants3.GL.SAMPLE_COVERAGE_INVERT]: false,
827
+ [import_constants3.GL.SCISSOR_TEST]: false,
823
828
  // Note: Dynamic value. If scissor test enabled we expect users to set correct scissor box
824
- [import_constants3.default.SCISSOR_BOX]: new Int32Array([0, 0, 1024, 1024]),
825
- [import_constants3.default.STENCIL_TEST]: false,
826
- [import_constants3.default.STENCIL_CLEAR_VALUE]: 0,
827
- [import_constants3.default.STENCIL_WRITEMASK]: 4294967295,
828
- [import_constants3.default.STENCIL_BACK_WRITEMASK]: 4294967295,
829
- [import_constants3.default.STENCIL_FUNC]: import_constants3.default.ALWAYS,
830
- [import_constants3.default.STENCIL_REF]: 0,
831
- [import_constants3.default.STENCIL_VALUE_MASK]: 4294967295,
832
- [import_constants3.default.STENCIL_BACK_FUNC]: import_constants3.default.ALWAYS,
833
- [import_constants3.default.STENCIL_BACK_REF]: 0,
834
- [import_constants3.default.STENCIL_BACK_VALUE_MASK]: 4294967295,
835
- [import_constants3.default.STENCIL_FAIL]: import_constants3.default.KEEP,
836
- [import_constants3.default.STENCIL_PASS_DEPTH_FAIL]: import_constants3.default.KEEP,
837
- [import_constants3.default.STENCIL_PASS_DEPTH_PASS]: import_constants3.default.KEEP,
838
- [import_constants3.default.STENCIL_BACK_FAIL]: import_constants3.default.KEEP,
839
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_FAIL]: import_constants3.default.KEEP,
840
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_PASS]: import_constants3.default.KEEP,
829
+ [import_constants3.GL.SCISSOR_BOX]: new Int32Array([0, 0, 1024, 1024]),
830
+ [import_constants3.GL.STENCIL_TEST]: false,
831
+ [import_constants3.GL.STENCIL_CLEAR_VALUE]: 0,
832
+ [import_constants3.GL.STENCIL_WRITEMASK]: 4294967295,
833
+ [import_constants3.GL.STENCIL_BACK_WRITEMASK]: 4294967295,
834
+ [import_constants3.GL.STENCIL_FUNC]: import_constants3.GL.ALWAYS,
835
+ [import_constants3.GL.STENCIL_REF]: 0,
836
+ [import_constants3.GL.STENCIL_VALUE_MASK]: 4294967295,
837
+ [import_constants3.GL.STENCIL_BACK_FUNC]: import_constants3.GL.ALWAYS,
838
+ [import_constants3.GL.STENCIL_BACK_REF]: 0,
839
+ [import_constants3.GL.STENCIL_BACK_VALUE_MASK]: 4294967295,
840
+ [import_constants3.GL.STENCIL_FAIL]: import_constants3.GL.KEEP,
841
+ [import_constants3.GL.STENCIL_PASS_DEPTH_FAIL]: import_constants3.GL.KEEP,
842
+ [import_constants3.GL.STENCIL_PASS_DEPTH_PASS]: import_constants3.GL.KEEP,
843
+ [import_constants3.GL.STENCIL_BACK_FAIL]: import_constants3.GL.KEEP,
844
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: import_constants3.GL.KEEP,
845
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: import_constants3.GL.KEEP,
841
846
  // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.
842
- [import_constants3.default.VIEWPORT]: [0, 0, 1024, 1024],
847
+ [import_constants3.GL.VIEWPORT]: [0, 0, 1024, 1024],
843
848
  // WEBGL1 PIXEL PACK/UNPACK MODES
844
- [import_constants3.default.PACK_ALIGNMENT]: 4,
845
- [import_constants3.default.UNPACK_ALIGNMENT]: 4,
846
- [import_constants3.default.UNPACK_FLIP_Y_WEBGL]: false,
847
- [import_constants3.default.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
848
- [import_constants3.default.UNPACK_COLORSPACE_CONVERSION_WEBGL]: import_constants3.default.BROWSER_DEFAULT_WEBGL,
849
+ [import_constants3.GL.PACK_ALIGNMENT]: 4,
850
+ [import_constants3.GL.UNPACK_ALIGNMENT]: 4,
851
+ [import_constants3.GL.UNPACK_FLIP_Y_WEBGL]: false,
852
+ [import_constants3.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
853
+ [import_constants3.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: import_constants3.GL.BROWSER_DEFAULT_WEBGL,
849
854
  // WEBGL2 / EXTENSIONS
850
855
  // gl1: 'OES_standard_derivatives'
851
- [import_constants3.default.TRANSFORM_FEEDBACK_BINDING]: null,
852
- [import_constants3.default.COPY_READ_BUFFER_BINDING]: null,
853
- [import_constants3.default.COPY_WRITE_BUFFER_BINDING]: null,
854
- [import_constants3.default.PIXEL_PACK_BUFFER_BINDING]: null,
855
- [import_constants3.default.PIXEL_UNPACK_BUFFER_BINDING]: null,
856
- [import_constants3.default.FRAGMENT_SHADER_DERIVATIVE_HINT]: import_constants3.default.DONT_CARE,
857
- [import_constants3.default.READ_FRAMEBUFFER_BINDING]: null,
858
- [import_constants3.default.RASTERIZER_DISCARD]: false,
859
- [import_constants3.default.PACK_ROW_LENGTH]: 0,
860
- [import_constants3.default.PACK_SKIP_PIXELS]: 0,
861
- [import_constants3.default.PACK_SKIP_ROWS]: 0,
862
- [import_constants3.default.UNPACK_ROW_LENGTH]: 0,
863
- [import_constants3.default.UNPACK_IMAGE_HEIGHT]: 0,
864
- [import_constants3.default.UNPACK_SKIP_PIXELS]: 0,
865
- [import_constants3.default.UNPACK_SKIP_ROWS]: 0,
866
- [import_constants3.default.UNPACK_SKIP_IMAGES]: 0
856
+ [import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: null,
857
+ [import_constants3.GL.COPY_READ_BUFFER_BINDING]: null,
858
+ [import_constants3.GL.COPY_WRITE_BUFFER_BINDING]: null,
859
+ [import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: null,
860
+ [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: null,
861
+ [import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: import_constants3.GL.DONT_CARE,
862
+ [import_constants3.GL.READ_FRAMEBUFFER_BINDING]: null,
863
+ [import_constants3.GL.RASTERIZER_DISCARD]: false,
864
+ [import_constants3.GL.PACK_ROW_LENGTH]: 0,
865
+ [import_constants3.GL.PACK_SKIP_PIXELS]: 0,
866
+ [import_constants3.GL.PACK_SKIP_ROWS]: 0,
867
+ [import_constants3.GL.UNPACK_ROW_LENGTH]: 0,
868
+ [import_constants3.GL.UNPACK_IMAGE_HEIGHT]: 0,
869
+ [import_constants3.GL.UNPACK_SKIP_PIXELS]: 0,
870
+ [import_constants3.GL.UNPACK_SKIP_ROWS]: 0,
871
+ [import_constants3.GL.UNPACK_SKIP_IMAGES]: 0
867
872
  };
868
873
  var enable = (gl, value, key) => value ? gl.enable(key) : gl.disable(key);
869
874
  var hint = (gl, value, key) => gl.hint(key, value);
870
875
  var pixelStorei = (gl, value, key) => gl.pixelStorei(key, value);
871
876
  var bindFramebuffer = (gl, value, key) => {
872
877
  let target;
873
- if (key === import_constants3.default.FRAMEBUFFER_BINDING) {
874
- target = isWebGL2(gl) ? import_constants3.default.DRAW_FRAMEBUFFER : import_constants3.default.FRAMEBUFFER;
878
+ if (key === import_constants3.GL.FRAMEBUFFER_BINDING) {
879
+ target = isWebGL2(gl) ? import_constants3.GL.DRAW_FRAMEBUFFER : import_constants3.GL.FRAMEBUFFER;
875
880
  } else {
876
- target = import_constants3.default.READ_FRAMEBUFFER;
881
+ target = import_constants3.GL.READ_FRAMEBUFFER;
877
882
  }
878
883
  return gl.bindFramebuffer(target, value);
879
884
  };
880
885
  var bindBuffer = (gl, value, key) => {
881
886
  const bindingMap = {
882
- [import_constants3.default.ARRAY_BUFFER_BINDING]: import_constants3.default.ARRAY_BUFFER,
883
- [import_constants3.default.COPY_READ_BUFFER_BINDING]: import_constants3.default.COPY_READ_BUFFER,
884
- [import_constants3.default.COPY_WRITE_BUFFER_BINDING]: import_constants3.default.COPY_WRITE_BUFFER,
885
- [import_constants3.default.PIXEL_PACK_BUFFER_BINDING]: import_constants3.default.PIXEL_PACK_BUFFER,
886
- [import_constants3.default.PIXEL_UNPACK_BUFFER_BINDING]: import_constants3.default.PIXEL_UNPACK_BUFFER
887
+ [import_constants3.GL.ARRAY_BUFFER_BINDING]: import_constants3.GL.ARRAY_BUFFER,
888
+ [import_constants3.GL.COPY_READ_BUFFER_BINDING]: import_constants3.GL.COPY_READ_BUFFER,
889
+ [import_constants3.GL.COPY_WRITE_BUFFER_BINDING]: import_constants3.GL.COPY_WRITE_BUFFER,
890
+ [import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_PACK_BUFFER,
891
+ [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_UNPACK_BUFFER
887
892
  };
888
893
  const target = bindingMap[key];
889
894
  gl.bindBuffer(target, value);
@@ -892,93 +897,93 @@ function isArray(array) {
892
897
  return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
893
898
  }
894
899
  var GL_PARAMETER_SETTERS = {
895
- [import_constants3.default.BLEND]: enable,
896
- [import_constants3.default.BLEND_COLOR]: (gl, value) => gl.blendColor(...value),
897
- [import_constants3.default.BLEND_EQUATION_RGB]: "blendEquation",
898
- [import_constants3.default.BLEND_EQUATION_ALPHA]: "blendEquation",
899
- [import_constants3.default.BLEND_SRC_RGB]: "blendFunc",
900
- [import_constants3.default.BLEND_DST_RGB]: "blendFunc",
901
- [import_constants3.default.BLEND_SRC_ALPHA]: "blendFunc",
902
- [import_constants3.default.BLEND_DST_ALPHA]: "blendFunc",
903
- [import_constants3.default.COLOR_CLEAR_VALUE]: (gl, value) => gl.clearColor(...value),
904
- [import_constants3.default.COLOR_WRITEMASK]: (gl, value) => gl.colorMask(...value),
905
- [import_constants3.default.CULL_FACE]: enable,
906
- [import_constants3.default.CULL_FACE_MODE]: (gl, value) => gl.cullFace(value),
907
- [import_constants3.default.DEPTH_TEST]: enable,
908
- [import_constants3.default.DEPTH_CLEAR_VALUE]: (gl, value) => gl.clearDepth(value),
909
- [import_constants3.default.DEPTH_FUNC]: (gl, value) => gl.depthFunc(value),
910
- [import_constants3.default.DEPTH_RANGE]: (gl, value) => gl.depthRange(...value),
911
- [import_constants3.default.DEPTH_WRITEMASK]: (gl, value) => gl.depthMask(value),
912
- [import_constants3.default.DITHER]: enable,
913
- [import_constants3.default.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,
914
- [import_constants3.default.CURRENT_PROGRAM]: (gl, value) => gl.useProgram(value),
915
- [import_constants3.default.RENDERBUFFER_BINDING]: (gl, value) => gl.bindRenderbuffer(import_constants3.default.RENDERBUFFER, value),
916
- [import_constants3.default.TRANSFORM_FEEDBACK_BINDING]: (gl, value) => {
900
+ [import_constants3.GL.BLEND]: enable,
901
+ [import_constants3.GL.BLEND_COLOR]: (gl, value) => gl.blendColor(...value),
902
+ [import_constants3.GL.BLEND_EQUATION_RGB]: "blendEquation",
903
+ [import_constants3.GL.BLEND_EQUATION_ALPHA]: "blendEquation",
904
+ [import_constants3.GL.BLEND_SRC_RGB]: "blendFunc",
905
+ [import_constants3.GL.BLEND_DST_RGB]: "blendFunc",
906
+ [import_constants3.GL.BLEND_SRC_ALPHA]: "blendFunc",
907
+ [import_constants3.GL.BLEND_DST_ALPHA]: "blendFunc",
908
+ [import_constants3.GL.COLOR_CLEAR_VALUE]: (gl, value) => gl.clearColor(...value),
909
+ [import_constants3.GL.COLOR_WRITEMASK]: (gl, value) => gl.colorMask(...value),
910
+ [import_constants3.GL.CULL_FACE]: enable,
911
+ [import_constants3.GL.CULL_FACE_MODE]: (gl, value) => gl.cullFace(value),
912
+ [import_constants3.GL.DEPTH_TEST]: enable,
913
+ [import_constants3.GL.DEPTH_CLEAR_VALUE]: (gl, value) => gl.clearDepth(value),
914
+ [import_constants3.GL.DEPTH_FUNC]: (gl, value) => gl.depthFunc(value),
915
+ [import_constants3.GL.DEPTH_RANGE]: (gl, value) => gl.depthRange(...value),
916
+ [import_constants3.GL.DEPTH_WRITEMASK]: (gl, value) => gl.depthMask(value),
917
+ [import_constants3.GL.DITHER]: enable,
918
+ [import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,
919
+ [import_constants3.GL.CURRENT_PROGRAM]: (gl, value) => gl.useProgram(value),
920
+ [import_constants3.GL.RENDERBUFFER_BINDING]: (gl, value) => gl.bindRenderbuffer(import_constants3.GL.RENDERBUFFER, value),
921
+ [import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: (gl, value) => {
917
922
  var _a;
918
- return (_a = gl.bindTransformFeedback) == null ? void 0 : _a.call(gl, import_constants3.default.TRANSFORM_FEEDBACK, value);
923
+ return (_a = gl.bindTransformFeedback) == null ? void 0 : _a.call(gl, import_constants3.GL.TRANSFORM_FEEDBACK, value);
919
924
  },
920
- [import_constants3.default.VERTEX_ARRAY_BINDING]: (gl, value) => gl.bindVertexArray(value),
925
+ [import_constants3.GL.VERTEX_ARRAY_BINDING]: (gl, value) => gl.bindVertexArray(value),
921
926
  // NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
922
- [import_constants3.default.FRAMEBUFFER_BINDING]: bindFramebuffer,
923
- [import_constants3.default.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,
927
+ [import_constants3.GL.FRAMEBUFFER_BINDING]: bindFramebuffer,
928
+ [import_constants3.GL.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,
924
929
  // Buffers
925
- [import_constants3.default.ARRAY_BUFFER_BINDING]: bindBuffer,
926
- [import_constants3.default.COPY_READ_BUFFER_BINDING]: bindBuffer,
927
- [import_constants3.default.COPY_WRITE_BUFFER_BINDING]: bindBuffer,
928
- [import_constants3.default.PIXEL_PACK_BUFFER_BINDING]: bindBuffer,
929
- [import_constants3.default.PIXEL_UNPACK_BUFFER_BINDING]: bindBuffer,
930
- [import_constants3.default.FRONT_FACE]: (gl, value) => gl.frontFace(value),
931
- [import_constants3.default.GENERATE_MIPMAP_HINT]: hint,
932
- [import_constants3.default.LINE_WIDTH]: (gl, value) => gl.lineWidth(value),
933
- [import_constants3.default.POLYGON_OFFSET_FILL]: enable,
934
- [import_constants3.default.POLYGON_OFFSET_FACTOR]: "polygonOffset",
935
- [import_constants3.default.POLYGON_OFFSET_UNITS]: "polygonOffset",
936
- [import_constants3.default.RASTERIZER_DISCARD]: enable,
937
- [import_constants3.default.SAMPLE_ALPHA_TO_COVERAGE]: enable,
938
- [import_constants3.default.SAMPLE_COVERAGE]: enable,
939
- [import_constants3.default.SAMPLE_COVERAGE_VALUE]: "sampleCoverage",
940
- [import_constants3.default.SAMPLE_COVERAGE_INVERT]: "sampleCoverage",
941
- [import_constants3.default.SCISSOR_TEST]: enable,
942
- [import_constants3.default.SCISSOR_BOX]: (gl, value) => gl.scissor(...value),
943
- [import_constants3.default.STENCIL_TEST]: enable,
944
- [import_constants3.default.STENCIL_CLEAR_VALUE]: (gl, value) => gl.clearStencil(value),
945
- [import_constants3.default.STENCIL_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.default.FRONT, value),
946
- [import_constants3.default.STENCIL_BACK_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.default.BACK, value),
947
- [import_constants3.default.STENCIL_FUNC]: "stencilFuncFront",
948
- [import_constants3.default.STENCIL_REF]: "stencilFuncFront",
949
- [import_constants3.default.STENCIL_VALUE_MASK]: "stencilFuncFront",
950
- [import_constants3.default.STENCIL_BACK_FUNC]: "stencilFuncBack",
951
- [import_constants3.default.STENCIL_BACK_REF]: "stencilFuncBack",
952
- [import_constants3.default.STENCIL_BACK_VALUE_MASK]: "stencilFuncBack",
953
- [import_constants3.default.STENCIL_FAIL]: "stencilOpFront",
954
- [import_constants3.default.STENCIL_PASS_DEPTH_FAIL]: "stencilOpFront",
955
- [import_constants3.default.STENCIL_PASS_DEPTH_PASS]: "stencilOpFront",
956
- [import_constants3.default.STENCIL_BACK_FAIL]: "stencilOpBack",
957
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
958
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
959
- [import_constants3.default.VIEWPORT]: (gl, value) => gl.viewport(...value),
930
+ [import_constants3.GL.ARRAY_BUFFER_BINDING]: bindBuffer,
931
+ [import_constants3.GL.COPY_READ_BUFFER_BINDING]: bindBuffer,
932
+ [import_constants3.GL.COPY_WRITE_BUFFER_BINDING]: bindBuffer,
933
+ [import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: bindBuffer,
934
+ [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: bindBuffer,
935
+ [import_constants3.GL.FRONT_FACE]: (gl, value) => gl.frontFace(value),
936
+ [import_constants3.GL.GENERATE_MIPMAP_HINT]: hint,
937
+ [import_constants3.GL.LINE_WIDTH]: (gl, value) => gl.lineWidth(value),
938
+ [import_constants3.GL.POLYGON_OFFSET_FILL]: enable,
939
+ [import_constants3.GL.POLYGON_OFFSET_FACTOR]: "polygonOffset",
940
+ [import_constants3.GL.POLYGON_OFFSET_UNITS]: "polygonOffset",
941
+ [import_constants3.GL.RASTERIZER_DISCARD]: enable,
942
+ [import_constants3.GL.SAMPLE_ALPHA_TO_COVERAGE]: enable,
943
+ [import_constants3.GL.SAMPLE_COVERAGE]: enable,
944
+ [import_constants3.GL.SAMPLE_COVERAGE_VALUE]: "sampleCoverage",
945
+ [import_constants3.GL.SAMPLE_COVERAGE_INVERT]: "sampleCoverage",
946
+ [import_constants3.GL.SCISSOR_TEST]: enable,
947
+ [import_constants3.GL.SCISSOR_BOX]: (gl, value) => gl.scissor(...value),
948
+ [import_constants3.GL.STENCIL_TEST]: enable,
949
+ [import_constants3.GL.STENCIL_CLEAR_VALUE]: (gl, value) => gl.clearStencil(value),
950
+ [import_constants3.GL.STENCIL_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.GL.FRONT, value),
951
+ [import_constants3.GL.STENCIL_BACK_WRITEMASK]: (gl, value) => gl.stencilMaskSeparate(import_constants3.GL.BACK, value),
952
+ [import_constants3.GL.STENCIL_FUNC]: "stencilFuncFront",
953
+ [import_constants3.GL.STENCIL_REF]: "stencilFuncFront",
954
+ [import_constants3.GL.STENCIL_VALUE_MASK]: "stencilFuncFront",
955
+ [import_constants3.GL.STENCIL_BACK_FUNC]: "stencilFuncBack",
956
+ [import_constants3.GL.STENCIL_BACK_REF]: "stencilFuncBack",
957
+ [import_constants3.GL.STENCIL_BACK_VALUE_MASK]: "stencilFuncBack",
958
+ [import_constants3.GL.STENCIL_FAIL]: "stencilOpFront",
959
+ [import_constants3.GL.STENCIL_PASS_DEPTH_FAIL]: "stencilOpFront",
960
+ [import_constants3.GL.STENCIL_PASS_DEPTH_PASS]: "stencilOpFront",
961
+ [import_constants3.GL.STENCIL_BACK_FAIL]: "stencilOpBack",
962
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
963
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
964
+ [import_constants3.GL.VIEWPORT]: (gl, value) => gl.viewport(...value),
960
965
  // WEBGL1 PIXEL PACK/UNPACK MODES
961
- [import_constants3.default.PACK_ALIGNMENT]: pixelStorei,
962
- [import_constants3.default.UNPACK_ALIGNMENT]: pixelStorei,
963
- [import_constants3.default.UNPACK_FLIP_Y_WEBGL]: pixelStorei,
964
- [import_constants3.default.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,
965
- [import_constants3.default.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,
966
+ [import_constants3.GL.PACK_ALIGNMENT]: pixelStorei,
967
+ [import_constants3.GL.UNPACK_ALIGNMENT]: pixelStorei,
968
+ [import_constants3.GL.UNPACK_FLIP_Y_WEBGL]: pixelStorei,
969
+ [import_constants3.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,
970
+ [import_constants3.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,
966
971
  // WEBGL2 PIXEL PACK/UNPACK MODES
967
972
  // RASTERIZER_DISCARD ...
968
- [import_constants3.default.PACK_ROW_LENGTH]: pixelStorei,
969
- [import_constants3.default.PACK_SKIP_PIXELS]: pixelStorei,
970
- [import_constants3.default.PACK_SKIP_ROWS]: pixelStorei,
971
- [import_constants3.default.UNPACK_ROW_LENGTH]: pixelStorei,
972
- [import_constants3.default.UNPACK_IMAGE_HEIGHT]: pixelStorei,
973
- [import_constants3.default.UNPACK_SKIP_PIXELS]: pixelStorei,
974
- [import_constants3.default.UNPACK_SKIP_ROWS]: pixelStorei,
975
- [import_constants3.default.UNPACK_SKIP_IMAGES]: pixelStorei,
973
+ [import_constants3.GL.PACK_ROW_LENGTH]: pixelStorei,
974
+ [import_constants3.GL.PACK_SKIP_PIXELS]: pixelStorei,
975
+ [import_constants3.GL.PACK_SKIP_ROWS]: pixelStorei,
976
+ [import_constants3.GL.UNPACK_ROW_LENGTH]: pixelStorei,
977
+ [import_constants3.GL.UNPACK_IMAGE_HEIGHT]: pixelStorei,
978
+ [import_constants3.GL.UNPACK_SKIP_PIXELS]: pixelStorei,
979
+ [import_constants3.GL.UNPACK_SKIP_ROWS]: pixelStorei,
980
+ [import_constants3.GL.UNPACK_SKIP_IMAGES]: pixelStorei,
976
981
  // Function-style setters
977
982
  framebuffer: (gl, framebuffer) => {
978
983
  const handle = framebuffer && "handle" in framebuffer ? framebuffer.handle : framebuffer;
979
- return gl.bindFramebuffer(import_constants3.default.FRAMEBUFFER, handle);
984
+ return gl.bindFramebuffer(import_constants3.GL.FRAMEBUFFER, handle);
980
985
  },
981
- blend: (gl, value) => value ? gl.enable(import_constants3.default.BLEND) : gl.disable(import_constants3.default.BLEND),
986
+ blend: (gl, value) => value ? gl.enable(import_constants3.GL.BLEND) : gl.disable(import_constants3.GL.BLEND),
982
987
  blendColor: (gl, value) => gl.blendColor(...value),
983
988
  blendEquation: (gl, args) => {
984
989
  const separateModes = typeof args === "number" ? [args, args] : args;
@@ -992,42 +997,42 @@ var GL_PARAMETER_SETTERS = {
992
997
  clearDepth: (gl, value) => gl.clearDepth(value),
993
998
  clearStencil: (gl, value) => gl.clearStencil(value),
994
999
  colorMask: (gl, value) => gl.colorMask(...value),
995
- cull: (gl, value) => value ? gl.enable(import_constants3.default.CULL_FACE) : gl.disable(import_constants3.default.CULL_FACE),
1000
+ cull: (gl, value) => value ? gl.enable(import_constants3.GL.CULL_FACE) : gl.disable(import_constants3.GL.CULL_FACE),
996
1001
  cullFace: (gl, value) => gl.cullFace(value),
997
- depthTest: (gl, value) => value ? gl.enable(import_constants3.default.DEPTH_TEST) : gl.disable(import_constants3.default.DEPTH_TEST),
1002
+ depthTest: (gl, value) => value ? gl.enable(import_constants3.GL.DEPTH_TEST) : gl.disable(import_constants3.GL.DEPTH_TEST),
998
1003
  depthFunc: (gl, value) => gl.depthFunc(value),
999
1004
  depthMask: (gl, value) => gl.depthMask(value),
1000
1005
  depthRange: (gl, value) => gl.depthRange(...value),
1001
- dither: (gl, value) => value ? gl.enable(import_constants3.default.DITHER) : gl.disable(import_constants3.default.DITHER),
1006
+ dither: (gl, value) => value ? gl.enable(import_constants3.GL.DITHER) : gl.disable(import_constants3.GL.DITHER),
1002
1007
  derivativeHint: (gl, value) => {
1003
- gl.hint(import_constants3.default.FRAGMENT_SHADER_DERIVATIVE_HINT, value);
1008
+ gl.hint(import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT, value);
1004
1009
  },
1005
1010
  frontFace: (gl, value) => gl.frontFace(value),
1006
- mipmapHint: (gl, value) => gl.hint(import_constants3.default.GENERATE_MIPMAP_HINT, value),
1011
+ mipmapHint: (gl, value) => gl.hint(import_constants3.GL.GENERATE_MIPMAP_HINT, value),
1007
1012
  lineWidth: (gl, value) => gl.lineWidth(value),
1008
- polygonOffsetFill: (gl, value) => value ? gl.enable(import_constants3.default.POLYGON_OFFSET_FILL) : gl.disable(import_constants3.default.POLYGON_OFFSET_FILL),
1013
+ polygonOffsetFill: (gl, value) => value ? gl.enable(import_constants3.GL.POLYGON_OFFSET_FILL) : gl.disable(import_constants3.GL.POLYGON_OFFSET_FILL),
1009
1014
  polygonOffset: (gl, value) => gl.polygonOffset(...value),
1010
1015
  sampleCoverage: (gl, value) => gl.sampleCoverage(...value),
1011
- scissorTest: (gl, value) => value ? gl.enable(import_constants3.default.SCISSOR_TEST) : gl.disable(import_constants3.default.SCISSOR_TEST),
1016
+ scissorTest: (gl, value) => value ? gl.enable(import_constants3.GL.SCISSOR_TEST) : gl.disable(import_constants3.GL.SCISSOR_TEST),
1012
1017
  scissor: (gl, value) => gl.scissor(...value),
1013
- stencilTest: (gl, value) => value ? gl.enable(import_constants3.default.STENCIL_TEST) : gl.disable(import_constants3.default.STENCIL_TEST),
1018
+ stencilTest: (gl, value) => value ? gl.enable(import_constants3.GL.STENCIL_TEST) : gl.disable(import_constants3.GL.STENCIL_TEST),
1014
1019
  stencilMask: (gl, value) => {
1015
1020
  value = isArray(value) ? value : [value, value];
1016
1021
  const [mask, backMask] = value;
1017
- gl.stencilMaskSeparate(import_constants3.default.FRONT, mask);
1018
- gl.stencilMaskSeparate(import_constants3.default.BACK, backMask);
1022
+ gl.stencilMaskSeparate(import_constants3.GL.FRONT, mask);
1023
+ gl.stencilMaskSeparate(import_constants3.GL.BACK, backMask);
1019
1024
  },
1020
1025
  stencilFunc: (gl, args) => {
1021
1026
  args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
1022
1027
  const [func, ref, mask, backFunc, backRef, backMask] = args;
1023
- gl.stencilFuncSeparate(import_constants3.default.FRONT, func, ref, mask);
1024
- gl.stencilFuncSeparate(import_constants3.default.BACK, backFunc, backRef, backMask);
1028
+ gl.stencilFuncSeparate(import_constants3.GL.FRONT, func, ref, mask);
1029
+ gl.stencilFuncSeparate(import_constants3.GL.BACK, backFunc, backRef, backMask);
1025
1030
  },
1026
1031
  stencilOp: (gl, args) => {
1027
1032
  args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
1028
1033
  const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;
1029
- gl.stencilOpSeparate(import_constants3.default.FRONT, sfail, dpfail, dppass);
1030
- gl.stencilOpSeparate(import_constants3.default.BACK, backSfail, backDpfail, backDppass);
1034
+ gl.stencilOpSeparate(import_constants3.GL.FRONT, sfail, dpfail, dppass);
1035
+ gl.stencilOpSeparate(import_constants3.GL.BACK, backSfail, backDpfail, backDppass);
1031
1036
  },
1032
1037
  viewport: (gl, value) => gl.viewport(...value)
1033
1038
  };
@@ -1036,46 +1041,46 @@ function getValue(glEnum, values, cache) {
1036
1041
  }
1037
1042
  var GL_COMPOSITE_PARAMETER_SETTERS = {
1038
1043
  blendEquation: (gl, values, cache) => gl.blendEquationSeparate(
1039
- getValue(import_constants3.default.BLEND_EQUATION_RGB, values, cache),
1040
- getValue(import_constants3.default.BLEND_EQUATION_ALPHA, values, cache)
1044
+ getValue(import_constants3.GL.BLEND_EQUATION_RGB, values, cache),
1045
+ getValue(import_constants3.GL.BLEND_EQUATION_ALPHA, values, cache)
1041
1046
  ),
1042
1047
  blendFunc: (gl, values, cache) => gl.blendFuncSeparate(
1043
- getValue(import_constants3.default.BLEND_SRC_RGB, values, cache),
1044
- getValue(import_constants3.default.BLEND_DST_RGB, values, cache),
1045
- getValue(import_constants3.default.BLEND_SRC_ALPHA, values, cache),
1046
- getValue(import_constants3.default.BLEND_DST_ALPHA, values, cache)
1048
+ getValue(import_constants3.GL.BLEND_SRC_RGB, values, cache),
1049
+ getValue(import_constants3.GL.BLEND_DST_RGB, values, cache),
1050
+ getValue(import_constants3.GL.BLEND_SRC_ALPHA, values, cache),
1051
+ getValue(import_constants3.GL.BLEND_DST_ALPHA, values, cache)
1047
1052
  ),
1048
1053
  polygonOffset: (gl, values, cache) => gl.polygonOffset(
1049
- getValue(import_constants3.default.POLYGON_OFFSET_FACTOR, values, cache),
1050
- getValue(import_constants3.default.POLYGON_OFFSET_UNITS, values, cache)
1054
+ getValue(import_constants3.GL.POLYGON_OFFSET_FACTOR, values, cache),
1055
+ getValue(import_constants3.GL.POLYGON_OFFSET_UNITS, values, cache)
1051
1056
  ),
1052
1057
  sampleCoverage: (gl, values, cache) => gl.sampleCoverage(
1053
- getValue(import_constants3.default.SAMPLE_COVERAGE_VALUE, values, cache),
1054
- getValue(import_constants3.default.SAMPLE_COVERAGE_INVERT, values, cache)
1058
+ getValue(import_constants3.GL.SAMPLE_COVERAGE_VALUE, values, cache),
1059
+ getValue(import_constants3.GL.SAMPLE_COVERAGE_INVERT, values, cache)
1055
1060
  ),
1056
1061
  stencilFuncFront: (gl, values, cache) => gl.stencilFuncSeparate(
1057
- import_constants3.default.FRONT,
1058
- getValue(import_constants3.default.STENCIL_FUNC, values, cache),
1059
- getValue(import_constants3.default.STENCIL_REF, values, cache),
1060
- getValue(import_constants3.default.STENCIL_VALUE_MASK, values, cache)
1062
+ import_constants3.GL.FRONT,
1063
+ getValue(import_constants3.GL.STENCIL_FUNC, values, cache),
1064
+ getValue(import_constants3.GL.STENCIL_REF, values, cache),
1065
+ getValue(import_constants3.GL.STENCIL_VALUE_MASK, values, cache)
1061
1066
  ),
1062
1067
  stencilFuncBack: (gl, values, cache) => gl.stencilFuncSeparate(
1063
- import_constants3.default.BACK,
1064
- getValue(import_constants3.default.STENCIL_BACK_FUNC, values, cache),
1065
- getValue(import_constants3.default.STENCIL_BACK_REF, values, cache),
1066
- getValue(import_constants3.default.STENCIL_BACK_VALUE_MASK, values, cache)
1068
+ import_constants3.GL.BACK,
1069
+ getValue(import_constants3.GL.STENCIL_BACK_FUNC, values, cache),
1070
+ getValue(import_constants3.GL.STENCIL_BACK_REF, values, cache),
1071
+ getValue(import_constants3.GL.STENCIL_BACK_VALUE_MASK, values, cache)
1067
1072
  ),
1068
1073
  stencilOpFront: (gl, values, cache) => gl.stencilOpSeparate(
1069
- import_constants3.default.FRONT,
1070
- getValue(import_constants3.default.STENCIL_FAIL, values, cache),
1071
- getValue(import_constants3.default.STENCIL_PASS_DEPTH_FAIL, values, cache),
1072
- getValue(import_constants3.default.STENCIL_PASS_DEPTH_PASS, values, cache)
1074
+ import_constants3.GL.FRONT,
1075
+ getValue(import_constants3.GL.STENCIL_FAIL, values, cache),
1076
+ getValue(import_constants3.GL.STENCIL_PASS_DEPTH_FAIL, values, cache),
1077
+ getValue(import_constants3.GL.STENCIL_PASS_DEPTH_PASS, values, cache)
1073
1078
  ),
1074
1079
  stencilOpBack: (gl, values, cache) => gl.stencilOpSeparate(
1075
- import_constants3.default.BACK,
1076
- getValue(import_constants3.default.STENCIL_BACK_FAIL, values, cache),
1077
- getValue(import_constants3.default.STENCIL_BACK_PASS_DEPTH_FAIL, values, cache),
1078
- getValue(import_constants3.default.STENCIL_BACK_PASS_DEPTH_PASS, values, cache)
1080
+ import_constants3.GL.BACK,
1081
+ getValue(import_constants3.GL.STENCIL_BACK_FAIL, values, cache),
1082
+ getValue(import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL, values, cache),
1083
+ getValue(import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS, values, cache)
1079
1084
  )
1080
1085
  };
1081
1086
  var GL_HOOKED_SETTERS = {
@@ -1094,39 +1099,39 @@ var GL_HOOKED_SETTERS = {
1094
1099
  }),
1095
1100
  // SPECIFIC SETTERS
1096
1101
  useProgram: (update, value) => update({
1097
- [import_constants3.default.CURRENT_PROGRAM]: value
1102
+ [import_constants3.GL.CURRENT_PROGRAM]: value
1098
1103
  }),
1099
1104
  bindRenderbuffer: (update, target, value) => update({
1100
- [import_constants3.default.RENDERBUFFER_BINDING]: value
1105
+ [import_constants3.GL.RENDERBUFFER_BINDING]: value
1101
1106
  }),
1102
1107
  bindTransformFeedback: (update, target, value) => update({
1103
- [import_constants3.default.TRANSFORM_FEEDBACK_BINDING]: value
1108
+ [import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: value
1104
1109
  }),
1105
1110
  bindVertexArray: (update, value) => update({
1106
- [import_constants3.default.VERTEX_ARRAY_BINDING]: value
1111
+ [import_constants3.GL.VERTEX_ARRAY_BINDING]: value
1107
1112
  }),
1108
1113
  bindFramebuffer: (update, target, framebuffer) => {
1109
1114
  switch (target) {
1110
- case import_constants3.default.FRAMEBUFFER:
1115
+ case import_constants3.GL.FRAMEBUFFER:
1111
1116
  return update({
1112
- [import_constants3.default.DRAW_FRAMEBUFFER_BINDING]: framebuffer,
1113
- [import_constants3.default.READ_FRAMEBUFFER_BINDING]: framebuffer
1117
+ [import_constants3.GL.DRAW_FRAMEBUFFER_BINDING]: framebuffer,
1118
+ [import_constants3.GL.READ_FRAMEBUFFER_BINDING]: framebuffer
1114
1119
  });
1115
- case import_constants3.default.DRAW_FRAMEBUFFER:
1116
- return update({ [import_constants3.default.DRAW_FRAMEBUFFER_BINDING]: framebuffer });
1117
- case import_constants3.default.READ_FRAMEBUFFER:
1118
- return update({ [import_constants3.default.READ_FRAMEBUFFER_BINDING]: framebuffer });
1120
+ case import_constants3.GL.DRAW_FRAMEBUFFER:
1121
+ return update({ [import_constants3.GL.DRAW_FRAMEBUFFER_BINDING]: framebuffer });
1122
+ case import_constants3.GL.READ_FRAMEBUFFER:
1123
+ return update({ [import_constants3.GL.READ_FRAMEBUFFER_BINDING]: framebuffer });
1119
1124
  default:
1120
1125
  return null;
1121
1126
  }
1122
1127
  },
1123
1128
  bindBuffer: (update, target, buffer) => {
1124
1129
  const pname = {
1125
- [import_constants3.default.ARRAY_BUFFER]: [import_constants3.default.ARRAY_BUFFER_BINDING],
1126
- [import_constants3.default.COPY_READ_BUFFER]: [import_constants3.default.COPY_READ_BUFFER_BINDING],
1127
- [import_constants3.default.COPY_WRITE_BUFFER]: [import_constants3.default.COPY_WRITE_BUFFER_BINDING],
1128
- [import_constants3.default.PIXEL_PACK_BUFFER]: [import_constants3.default.PIXEL_PACK_BUFFER_BINDING],
1129
- [import_constants3.default.PIXEL_UNPACK_BUFFER]: [import_constants3.default.PIXEL_UNPACK_BUFFER_BINDING]
1130
+ [import_constants3.GL.ARRAY_BUFFER]: [import_constants3.GL.ARRAY_BUFFER_BINDING],
1131
+ [import_constants3.GL.COPY_READ_BUFFER]: [import_constants3.GL.COPY_READ_BUFFER_BINDING],
1132
+ [import_constants3.GL.COPY_WRITE_BUFFER]: [import_constants3.GL.COPY_WRITE_BUFFER_BINDING],
1133
+ [import_constants3.GL.PIXEL_PACK_BUFFER]: [import_constants3.GL.PIXEL_PACK_BUFFER_BINDING],
1134
+ [import_constants3.GL.PIXEL_UNPACK_BUFFER]: [import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]
1130
1135
  }[target];
1131
1136
  if (pname) {
1132
1137
  return update({ [pname]: buffer });
@@ -1134,157 +1139,157 @@ var GL_HOOKED_SETTERS = {
1134
1139
  return { valueChanged: true };
1135
1140
  },
1136
1141
  blendColor: (update, r, g, b, a) => update({
1137
- [import_constants3.default.BLEND_COLOR]: new Float32Array([r, g, b, a])
1142
+ [import_constants3.GL.BLEND_COLOR]: new Float32Array([r, g, b, a])
1138
1143
  }),
1139
1144
  blendEquation: (update, mode) => update({
1140
- [import_constants3.default.BLEND_EQUATION_RGB]: mode,
1141
- [import_constants3.default.BLEND_EQUATION_ALPHA]: mode
1145
+ [import_constants3.GL.BLEND_EQUATION_RGB]: mode,
1146
+ [import_constants3.GL.BLEND_EQUATION_ALPHA]: mode
1142
1147
  }),
1143
1148
  blendEquationSeparate: (update, modeRGB, modeAlpha) => update({
1144
- [import_constants3.default.BLEND_EQUATION_RGB]: modeRGB,
1145
- [import_constants3.default.BLEND_EQUATION_ALPHA]: modeAlpha
1149
+ [import_constants3.GL.BLEND_EQUATION_RGB]: modeRGB,
1150
+ [import_constants3.GL.BLEND_EQUATION_ALPHA]: modeAlpha
1146
1151
  }),
1147
1152
  blendFunc: (update, src, dst) => update({
1148
- [import_constants3.default.BLEND_SRC_RGB]: src,
1149
- [import_constants3.default.BLEND_DST_RGB]: dst,
1150
- [import_constants3.default.BLEND_SRC_ALPHA]: src,
1151
- [import_constants3.default.BLEND_DST_ALPHA]: dst
1153
+ [import_constants3.GL.BLEND_SRC_RGB]: src,
1154
+ [import_constants3.GL.BLEND_DST_RGB]: dst,
1155
+ [import_constants3.GL.BLEND_SRC_ALPHA]: src,
1156
+ [import_constants3.GL.BLEND_DST_ALPHA]: dst
1152
1157
  }),
1153
1158
  blendFuncSeparate: (update, srcRGB, dstRGB, srcAlpha, dstAlpha) => update({
1154
- [import_constants3.default.BLEND_SRC_RGB]: srcRGB,
1155
- [import_constants3.default.BLEND_DST_RGB]: dstRGB,
1156
- [import_constants3.default.BLEND_SRC_ALPHA]: srcAlpha,
1157
- [import_constants3.default.BLEND_DST_ALPHA]: dstAlpha
1159
+ [import_constants3.GL.BLEND_SRC_RGB]: srcRGB,
1160
+ [import_constants3.GL.BLEND_DST_RGB]: dstRGB,
1161
+ [import_constants3.GL.BLEND_SRC_ALPHA]: srcAlpha,
1162
+ [import_constants3.GL.BLEND_DST_ALPHA]: dstAlpha
1158
1163
  }),
1159
1164
  clearColor: (update, r, g, b, a) => update({
1160
- [import_constants3.default.COLOR_CLEAR_VALUE]: new Float32Array([r, g, b, a])
1165
+ [import_constants3.GL.COLOR_CLEAR_VALUE]: new Float32Array([r, g, b, a])
1161
1166
  }),
1162
1167
  clearDepth: (update, depth) => update({
1163
- [import_constants3.default.DEPTH_CLEAR_VALUE]: depth
1168
+ [import_constants3.GL.DEPTH_CLEAR_VALUE]: depth
1164
1169
  }),
1165
1170
  clearStencil: (update, s) => update({
1166
- [import_constants3.default.STENCIL_CLEAR_VALUE]: s
1171
+ [import_constants3.GL.STENCIL_CLEAR_VALUE]: s
1167
1172
  }),
1168
1173
  colorMask: (update, r, g, b, a) => update({
1169
- [import_constants3.default.COLOR_WRITEMASK]: [r, g, b, a]
1174
+ [import_constants3.GL.COLOR_WRITEMASK]: [r, g, b, a]
1170
1175
  }),
1171
1176
  cullFace: (update, mode) => update({
1172
- [import_constants3.default.CULL_FACE_MODE]: mode
1177
+ [import_constants3.GL.CULL_FACE_MODE]: mode
1173
1178
  }),
1174
1179
  depthFunc: (update, func) => update({
1175
- [import_constants3.default.DEPTH_FUNC]: func
1180
+ [import_constants3.GL.DEPTH_FUNC]: func
1176
1181
  }),
1177
1182
  depthRange: (update, zNear, zFar) => update({
1178
- [import_constants3.default.DEPTH_RANGE]: new Float32Array([zNear, zFar])
1183
+ [import_constants3.GL.DEPTH_RANGE]: new Float32Array([zNear, zFar])
1179
1184
  }),
1180
1185
  depthMask: (update, mask) => update({
1181
- [import_constants3.default.DEPTH_WRITEMASK]: mask
1186
+ [import_constants3.GL.DEPTH_WRITEMASK]: mask
1182
1187
  }),
1183
1188
  frontFace: (update, face) => update({
1184
- [import_constants3.default.FRONT_FACE]: face
1189
+ [import_constants3.GL.FRONT_FACE]: face
1185
1190
  }),
1186
1191
  lineWidth: (update, width) => update({
1187
- [import_constants3.default.LINE_WIDTH]: width
1192
+ [import_constants3.GL.LINE_WIDTH]: width
1188
1193
  }),
1189
1194
  polygonOffset: (update, factor, units) => update({
1190
- [import_constants3.default.POLYGON_OFFSET_FACTOR]: factor,
1191
- [import_constants3.default.POLYGON_OFFSET_UNITS]: units
1195
+ [import_constants3.GL.POLYGON_OFFSET_FACTOR]: factor,
1196
+ [import_constants3.GL.POLYGON_OFFSET_UNITS]: units
1192
1197
  }),
1193
1198
  sampleCoverage: (update, value, invert) => update({
1194
- [import_constants3.default.SAMPLE_COVERAGE_VALUE]: value,
1195
- [import_constants3.default.SAMPLE_COVERAGE_INVERT]: invert
1199
+ [import_constants3.GL.SAMPLE_COVERAGE_VALUE]: value,
1200
+ [import_constants3.GL.SAMPLE_COVERAGE_INVERT]: invert
1196
1201
  }),
1197
1202
  scissor: (update, x, y, width, height) => update({
1198
- [import_constants3.default.SCISSOR_BOX]: new Int32Array([x, y, width, height])
1203
+ [import_constants3.GL.SCISSOR_BOX]: new Int32Array([x, y, width, height])
1199
1204
  }),
1200
1205
  stencilMask: (update, mask) => update({
1201
- [import_constants3.default.STENCIL_WRITEMASK]: mask,
1202
- [import_constants3.default.STENCIL_BACK_WRITEMASK]: mask
1206
+ [import_constants3.GL.STENCIL_WRITEMASK]: mask,
1207
+ [import_constants3.GL.STENCIL_BACK_WRITEMASK]: mask
1203
1208
  }),
1204
1209
  stencilMaskSeparate: (update, face, mask) => update({
1205
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_WRITEMASK : import_constants3.default.STENCIL_BACK_WRITEMASK]: mask
1210
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_WRITEMASK : import_constants3.GL.STENCIL_BACK_WRITEMASK]: mask
1206
1211
  }),
1207
1212
  stencilFunc: (update, func, ref, mask) => update({
1208
- [import_constants3.default.STENCIL_FUNC]: func,
1209
- [import_constants3.default.STENCIL_REF]: ref,
1210
- [import_constants3.default.STENCIL_VALUE_MASK]: mask,
1211
- [import_constants3.default.STENCIL_BACK_FUNC]: func,
1212
- [import_constants3.default.STENCIL_BACK_REF]: ref,
1213
- [import_constants3.default.STENCIL_BACK_VALUE_MASK]: mask
1213
+ [import_constants3.GL.STENCIL_FUNC]: func,
1214
+ [import_constants3.GL.STENCIL_REF]: ref,
1215
+ [import_constants3.GL.STENCIL_VALUE_MASK]: mask,
1216
+ [import_constants3.GL.STENCIL_BACK_FUNC]: func,
1217
+ [import_constants3.GL.STENCIL_BACK_REF]: ref,
1218
+ [import_constants3.GL.STENCIL_BACK_VALUE_MASK]: mask
1214
1219
  }),
1215
1220
  stencilFuncSeparate: (update, face, func, ref, mask) => update({
1216
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_FUNC : import_constants3.default.STENCIL_BACK_FUNC]: func,
1217
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_REF : import_constants3.default.STENCIL_BACK_REF]: ref,
1218
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_VALUE_MASK : import_constants3.default.STENCIL_BACK_VALUE_MASK]: mask
1221
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_FUNC : import_constants3.GL.STENCIL_BACK_FUNC]: func,
1222
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_REF : import_constants3.GL.STENCIL_BACK_REF]: ref,
1223
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_VALUE_MASK : import_constants3.GL.STENCIL_BACK_VALUE_MASK]: mask
1219
1224
  }),
1220
1225
  stencilOp: (update, fail, zfail, zpass) => update({
1221
- [import_constants3.default.STENCIL_FAIL]: fail,
1222
- [import_constants3.default.STENCIL_PASS_DEPTH_FAIL]: zfail,
1223
- [import_constants3.default.STENCIL_PASS_DEPTH_PASS]: zpass,
1224
- [import_constants3.default.STENCIL_BACK_FAIL]: fail,
1225
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,
1226
- [import_constants3.default.STENCIL_BACK_PASS_DEPTH_PASS]: zpass
1226
+ [import_constants3.GL.STENCIL_FAIL]: fail,
1227
+ [import_constants3.GL.STENCIL_PASS_DEPTH_FAIL]: zfail,
1228
+ [import_constants3.GL.STENCIL_PASS_DEPTH_PASS]: zpass,
1229
+ [import_constants3.GL.STENCIL_BACK_FAIL]: fail,
1230
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,
1231
+ [import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: zpass
1227
1232
  }),
1228
1233
  stencilOpSeparate: (update, face, fail, zfail, zpass) => update({
1229
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_FAIL : import_constants3.default.STENCIL_BACK_FAIL]: fail,
1230
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_PASS_DEPTH_FAIL : import_constants3.default.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,
1231
- [face === import_constants3.default.FRONT ? import_constants3.default.STENCIL_PASS_DEPTH_PASS : import_constants3.default.STENCIL_BACK_PASS_DEPTH_PASS]: zpass
1234
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_FAIL : import_constants3.GL.STENCIL_BACK_FAIL]: fail,
1235
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_PASS_DEPTH_FAIL : import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,
1236
+ [face === import_constants3.GL.FRONT ? import_constants3.GL.STENCIL_PASS_DEPTH_PASS : import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: zpass
1232
1237
  }),
1233
1238
  viewport: (update, x, y, width, height) => update({
1234
- [import_constants3.default.VIEWPORT]: [x, y, width, height]
1239
+ [import_constants3.GL.VIEWPORT]: [x, y, width, height]
1235
1240
  })
1236
1241
  };
1237
1242
  var isEnabled = (gl, key) => gl.isEnabled(key);
1238
1243
  var GL_PARAMETER_GETTERS = {
1239
- [import_constants3.default.BLEND]: isEnabled,
1240
- [import_constants3.default.CULL_FACE]: isEnabled,
1241
- [import_constants3.default.DEPTH_TEST]: isEnabled,
1242
- [import_constants3.default.DITHER]: isEnabled,
1243
- [import_constants3.default.POLYGON_OFFSET_FILL]: isEnabled,
1244
- [import_constants3.default.SAMPLE_ALPHA_TO_COVERAGE]: isEnabled,
1245
- [import_constants3.default.SAMPLE_COVERAGE]: isEnabled,
1246
- [import_constants3.default.SCISSOR_TEST]: isEnabled,
1247
- [import_constants3.default.STENCIL_TEST]: isEnabled,
1244
+ [import_constants3.GL.BLEND]: isEnabled,
1245
+ [import_constants3.GL.CULL_FACE]: isEnabled,
1246
+ [import_constants3.GL.DEPTH_TEST]: isEnabled,
1247
+ [import_constants3.GL.DITHER]: isEnabled,
1248
+ [import_constants3.GL.POLYGON_OFFSET_FILL]: isEnabled,
1249
+ [import_constants3.GL.SAMPLE_ALPHA_TO_COVERAGE]: isEnabled,
1250
+ [import_constants3.GL.SAMPLE_COVERAGE]: isEnabled,
1251
+ [import_constants3.GL.SCISSOR_TEST]: isEnabled,
1252
+ [import_constants3.GL.STENCIL_TEST]: isEnabled,
1248
1253
  // WebGL 2
1249
- [import_constants3.default.RASTERIZER_DISCARD]: isEnabled
1254
+ [import_constants3.GL.RASTERIZER_DISCARD]: isEnabled
1250
1255
  };
1251
1256
  var NON_CACHE_PARAMETERS = /* @__PURE__ */ new Set([
1252
1257
  // setter not intercepted
1253
- import_constants3.default.ACTIVE_TEXTURE,
1254
- import_constants3.default.TRANSFORM_FEEDBACK_ACTIVE,
1255
- import_constants3.default.TRANSFORM_FEEDBACK_PAUSED,
1258
+ import_constants3.GL.ACTIVE_TEXTURE,
1259
+ import_constants3.GL.TRANSFORM_FEEDBACK_ACTIVE,
1260
+ import_constants3.GL.TRANSFORM_FEEDBACK_PAUSED,
1256
1261
  // setters bindBufferRange/bindBufferBase cannot be pruned based on cache
1257
- import_constants3.default.TRANSFORM_FEEDBACK_BUFFER_BINDING,
1258
- import_constants3.default.UNIFORM_BUFFER_BINDING,
1262
+ import_constants3.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,
1263
+ import_constants3.GL.UNIFORM_BUFFER_BINDING,
1259
1264
  // states depending on VERTEX_ARRAY_BINDING
1260
- import_constants3.default.ELEMENT_ARRAY_BUFFER_BINDING,
1265
+ import_constants3.GL.ELEMENT_ARRAY_BUFFER_BINDING,
1261
1266
  // states depending on READ_FRAMEBUFFER_BINDING
1262
- import_constants3.default.IMPLEMENTATION_COLOR_READ_FORMAT,
1263
- import_constants3.default.IMPLEMENTATION_COLOR_READ_TYPE,
1267
+ import_constants3.GL.IMPLEMENTATION_COLOR_READ_FORMAT,
1268
+ import_constants3.GL.IMPLEMENTATION_COLOR_READ_TYPE,
1264
1269
  // states depending on FRAMEBUFFER_BINDING
1265
- import_constants3.default.READ_BUFFER,
1266
- import_constants3.default.DRAW_BUFFER0,
1267
- import_constants3.default.DRAW_BUFFER1,
1268
- import_constants3.default.DRAW_BUFFER2,
1269
- import_constants3.default.DRAW_BUFFER3,
1270
- import_constants3.default.DRAW_BUFFER4,
1271
- import_constants3.default.DRAW_BUFFER5,
1272
- import_constants3.default.DRAW_BUFFER6,
1273
- import_constants3.default.DRAW_BUFFER7,
1274
- import_constants3.default.DRAW_BUFFER8,
1275
- import_constants3.default.DRAW_BUFFER9,
1276
- import_constants3.default.DRAW_BUFFER10,
1277
- import_constants3.default.DRAW_BUFFER11,
1278
- import_constants3.default.DRAW_BUFFER12,
1279
- import_constants3.default.DRAW_BUFFER13,
1280
- import_constants3.default.DRAW_BUFFER14,
1281
- import_constants3.default.DRAW_BUFFER15,
1270
+ import_constants3.GL.READ_BUFFER,
1271
+ import_constants3.GL.DRAW_BUFFER0,
1272
+ import_constants3.GL.DRAW_BUFFER1,
1273
+ import_constants3.GL.DRAW_BUFFER2,
1274
+ import_constants3.GL.DRAW_BUFFER3,
1275
+ import_constants3.GL.DRAW_BUFFER4,
1276
+ import_constants3.GL.DRAW_BUFFER5,
1277
+ import_constants3.GL.DRAW_BUFFER6,
1278
+ import_constants3.GL.DRAW_BUFFER7,
1279
+ import_constants3.GL.DRAW_BUFFER8,
1280
+ import_constants3.GL.DRAW_BUFFER9,
1281
+ import_constants3.GL.DRAW_BUFFER10,
1282
+ import_constants3.GL.DRAW_BUFFER11,
1283
+ import_constants3.GL.DRAW_BUFFER12,
1284
+ import_constants3.GL.DRAW_BUFFER13,
1285
+ import_constants3.GL.DRAW_BUFFER14,
1286
+ import_constants3.GL.DRAW_BUFFER15,
1282
1287
  // states depending on ACTIVE_TEXTURE
1283
- import_constants3.default.SAMPLER_BINDING,
1284
- import_constants3.default.TEXTURE_BINDING_2D,
1285
- import_constants3.default.TEXTURE_BINDING_2D_ARRAY,
1286
- import_constants3.default.TEXTURE_BINDING_3D,
1287
- import_constants3.default.TEXTURE_BINDING_CUBE_MAP
1288
+ import_constants3.GL.SAMPLER_BINDING,
1289
+ import_constants3.GL.TEXTURE_BINDING_2D,
1290
+ import_constants3.GL.TEXTURE_BINDING_2D_ARRAY,
1291
+ import_constants3.GL.TEXTURE_BINDING_3D,
1292
+ import_constants3.GL.TEXTURE_BINDING_CUBE_MAP
1288
1293
  ]);
1289
1294
 
1290
1295
  // src/context/parameters/unified-parameter-api.ts
@@ -1363,7 +1368,7 @@ var GLState = class {
1363
1368
  constructor(gl, {
1364
1369
  copyState = false,
1365
1370
  // Copy cache from params (slow) or initialize from WebGL defaults (fast)
1366
- log: log10 = () => {
1371
+ log: log9 = () => {
1367
1372
  }
1368
1373
  // Logging function, called when gl parameter change calls are actually issued
1369
1374
  } = {}) {
@@ -1372,7 +1377,7 @@ var GLState = class {
1372
1377
  this.enable = true;
1373
1378
  this.gl = gl;
1374
1379
  this.cache = copyState ? getParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);
1375
- this.log = log10;
1380
+ this.log = log9;
1376
1381
  this._updateCache = this._updateCache.bind(this);
1377
1382
  Object.seal(this);
1378
1383
  }
@@ -1521,11 +1526,11 @@ function createBrowserContext(canvas, props) {
1521
1526
  if (props.type === "webgl1") {
1522
1527
  props = __spreadProps(__spreadValues({}, props), { webgl2: false });
1523
1528
  }
1524
- if (props.webgl2) {
1525
- gl = gl || canvas.getContext("webgl2", props);
1529
+ if (!gl && props.webgl2) {
1530
+ gl = canvas.getContext("webgl2", props);
1526
1531
  }
1527
- if (props.webgl1) {
1528
- gl = gl || canvas.getContext("webgl", props);
1532
+ if (!gl && props.webgl1) {
1533
+ gl = canvas.getContext("webgl", props);
1529
1534
  }
1530
1535
  canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
1531
1536
  if (!gl) {
@@ -1539,7 +1544,11 @@ function createBrowserContext(canvas, props) {
1539
1544
  }
1540
1545
  if (props.onContextRestored) {
1541
1546
  const { onContextRestored } = props;
1542
- canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
1547
+ canvas.addEventListener(
1548
+ "webglcontextrestored",
1549
+ (event) => onContextRestored(event),
1550
+ false
1551
+ );
1543
1552
  }
1544
1553
  return gl;
1545
1554
  }
@@ -1676,27 +1685,27 @@ var TEXTURE_FORMATS = {
1676
1685
  // 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
1677
1686
  // 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
1678
1687
  // 8-bit formats
1679
- "r8unorm": { gl: import_constants5.default.R8, b: 1, c: 1 },
1688
+ "r8unorm": { gl: import_constants5.default.R8, b: 1, c: 1, renderbuffer: true },
1680
1689
  "r8snorm": { gl: import_constants5.default.R8_SNORM, b: 1, c: 1 },
1681
- "r8uint": { gl: import_constants5.default.R8UI, b: 1, c: 1 },
1682
- "r8sint": { gl: import_constants5.default.R8I, b: 1, c: 1 },
1690
+ "r8uint": { gl: import_constants5.default.R8UI, b: 1, c: 1, renderbuffer: true },
1691
+ "r8sint": { gl: import_constants5.default.R8I, b: 1, c: 1, renderbuffer: true },
1683
1692
  // 16-bit formats
1684
- "rg8unorm": { gl: import_constants5.default.RG8, b: 2, c: 2 },
1693
+ "rg8unorm": { gl: import_constants5.default.RG8, b: 2, c: 2, renderbuffer: true },
1685
1694
  "rg8snorm": { gl: import_constants5.default.RG8_SNORM, b: 2, c: 2 },
1686
- "rg8uint": { gl: import_constants5.default.RG8UI, b: 2, c: 2 },
1687
- "rg8sint": { gl: import_constants5.default.RG8I, b: 2, c: 2 },
1688
- "r16uint": { gl: import_constants5.default.R16UI, b: 2, c: 1 },
1689
- "r16sint": { gl: import_constants5.default.R16I, b: 2, c: 1 },
1690
- "r16float": { gl: import_constants5.default.R16F, b: 2, c: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
1691
- "r16unorm-webgl": { gl: import_constants5.default.R16_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl" },
1692
- "r16snorm-webgl": { gl: import_constants5.default.R16_SNORM_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl" },
1695
+ "rg8uint": { gl: import_constants5.default.RG8UI, b: 2, c: 2, renderbuffer: true },
1696
+ "rg8sint": { gl: import_constants5.default.RG8I, b: 2, c: 2, renderbuffer: true },
1697
+ "r16uint": { gl: import_constants5.default.R16UI, b: 2, c: 1, renderbuffer: true },
1698
+ "r16sint": { gl: import_constants5.default.R16I, b: 2, c: 1, renderbuffer: true },
1699
+ "r16float": { gl: import_constants5.default.R16F, b: 2, c: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
1700
+ "r16unorm-webgl": { gl: import_constants5.default.R16_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
1701
+ "r16snorm-webgl": { gl: import_constants5.default.R16_SNORM_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1693
1702
  // Packed 16-bit formats
1694
- "rgba4unorm-webgl": { gl: import_constants5.default.RGBA4, b: 2, c: 4, wgpu: false },
1695
- "rgb565unorm-webgl": { gl: import_constants5.default.RGB565, b: 2, c: 4, wgpu: false },
1696
- "rgb5a1unorm-webgl": { gl: import_constants5.default.RGB5_A1, b: 2, c: 4, wgpu: false },
1703
+ "rgba4unorm-webgl": { gl: import_constants5.default.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
1704
+ "rgb565unorm-webgl": { gl: import_constants5.default.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
1705
+ "rgb5a1unorm-webgl": { gl: import_constants5.default.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true },
1697
1706
  // 24-bit formats
1698
- "rbg8unorm-webgl": { gl: import_constants5.default.RGB8, b: 3, c: 3, wgpu: false },
1699
- "rbg8snorm-webgl": { gl: import_constants5.default.RGB8_SNORM, b: 3, c: 3, wgpu: false },
1707
+ "rgb8unorm-webgl": { gl: import_constants5.default.RGB8, b: 3, c: 3, wgpu: false },
1708
+ "rgb8snorm-webgl": { gl: import_constants5.default.RGB8_SNORM, b: 3, c: 3, wgpu: false },
1700
1709
  // 32-bit formats
1701
1710
  "rgba8unorm": { gl: import_constants5.default.RGBA8, gl1: import_constants5.default.RGBA, b: 4, c: 2, bpp: 4 },
1702
1711
  "rgba8unorm-srgb": { gl: import_constants5.default.SRGB8_ALPHA8, gl1: import_constants5.default.SRGB_ALPHA_EXT, b: 4, c: 4, gl1ext: EXT_SRGB, bpp: 4 },
@@ -1709,30 +1718,30 @@ var TEXTURE_FORMATS = {
1709
1718
  "rg16uint": { gl: import_constants5.default.RG16UI, b: 4, c: 1, bpp: 4 },
1710
1719
  "rg16sint": { gl: import_constants5.default.RG16I, b: 4, c: 2, bpp: 4 },
1711
1720
  // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
1712
- "rg16float": { gl: import_constants5.default.RG16F, bpp: 4, b: 4, c: 2, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
1713
- "rg16unorm-webgl": { gl: import_constants5.default.RG16_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl" },
1714
- "rg16snorm-webgl": { gl: import_constants5.default.RG16_SNORM_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl" },
1715
- "r32uint": { gl: import_constants5.default.R32UI, b: 4, c: 1, bpp: 4 },
1716
- "r32sint": { gl: import_constants5.default.R32I, b: 4, c: 1, bpp: 4 },
1721
+ "rg16float": { gl: import_constants5.default.RG16F, bpp: 4, b: 4, c: 2, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
1722
+ "rg16unorm-webgl": { gl: import_constants5.default.RG16_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1723
+ "rg16snorm-webgl": { gl: import_constants5.default.RG16_SNORM_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1724
+ "r32uint": { gl: import_constants5.default.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
1725
+ "r32sint": { gl: import_constants5.default.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
1717
1726
  "r32float": { gl: import_constants5.default.R32F, bpp: 4, b: 4, c: 1, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl" },
1718
1727
  // Packed 32-bit formats
1719
1728
  "rgb9e5ufloat": { gl: import_constants5.default.RGB9_E5, b: 4, c: 3, p: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
1720
- "rg11b10ufloat": { gl: import_constants5.default.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: "texture-renderable-float32-webgl" },
1721
- "rgb10a2unorm": { gl: import_constants5.default.RGB10_A2, b: 4, c: 4, p: 1 },
1729
+ "rg11b10ufloat": { gl: import_constants5.default.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: "texture-renderable-float32-webgl", renderbuffer: true },
1730
+ "rgb10a2unorm": { gl: import_constants5.default.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
1722
1731
  // webgl2 only
1723
- "rgb10a2unorm-webgl": { b: 4, c: 4, gl: import_constants5.default.RGB10_A2UI, p: 1, wgpu: false, bpp: 4 },
1732
+ "rgb10a2unorm-webgl": { b: 4, c: 4, gl: import_constants5.default.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
1724
1733
  // 48-bit formats
1725
- "rgb16unorm-webgl": { gl: import_constants5.default.RGB16_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl" },
1726
- "rgb16snorm-webgl": { gl: import_constants5.default.RGB16_SNORM_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl" },
1734
+ "rgb16unorm-webgl": { gl: import_constants5.default.RGB16_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1735
+ "rgb16snorm-webgl": { gl: import_constants5.default.RGB16_SNORM_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1727
1736
  // 64-bit formats
1728
- "rg32uint": { gl: import_constants5.default.RG32UI, b: 8, c: 2 },
1729
- "rg32sint": { gl: import_constants5.default.RG32I, b: 8, c: 2 },
1730
- "rg32float": { gl: import_constants5.default.RG32F, b: 8, c: 2, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl" },
1731
- "rgba16uint": { gl: import_constants5.default.RGBA16UI, b: 8, c: 4 },
1732
- "rgba16sint": { gl: import_constants5.default.RGBA16I, b: 8, c: 4 },
1737
+ "rg32uint": { gl: import_constants5.default.RG32UI, b: 8, c: 2, renderbuffer: true },
1738
+ "rg32sint": { gl: import_constants5.default.RG32I, b: 8, c: 2, renderbuffer: true },
1739
+ "rg32float": { gl: import_constants5.default.RG32F, b: 8, c: 2, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
1740
+ "rgba16uint": { gl: import_constants5.default.RGBA16UI, b: 8, c: 4, renderbuffer: true },
1741
+ "rgba16sint": { gl: import_constants5.default.RGBA16I, b: 8, c: 4, renderbuffer: true },
1733
1742
  "rgba16float": { gl: import_constants5.default.RGBA16F, gl1: import_constants5.default.RGBA, b: 8, c: 4, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
1734
- "rgba16unorm-webgl": { gl: import_constants5.default.RGBA16_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl" },
1735
- "rgba16snorm-webgl": { gl: import_constants5.default.RGBA16_SNORM_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl" },
1743
+ "rgba16unorm-webgl": { gl: import_constants5.default.RGBA16_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
1744
+ "rgba16snorm-webgl": { gl: import_constants5.default.RGBA16_SNORM_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
1736
1745
  // 96-bit formats (deprecated!)
1737
1746
  "rgb32float-webgl": {
1738
1747
  gl: import_constants5.default.RGB32F,
@@ -1746,21 +1755,22 @@ var TEXTURE_FORMATS = {
1746
1755
  types: [import_constants5.default.FLOAT]
1747
1756
  },
1748
1757
  // 128-bit formats
1749
- "rgba32uint": { gl: import_constants5.default.RGBA32UI, b: 16, c: 4 },
1750
- "rgba32sint": { gl: import_constants5.default.RGBA32I, b: 16, c: 4 },
1751
- "rgba32float": { gl: import_constants5.default.RGBA32F, gl1: import_constants5.default.RGBA, b: 16, c: 4, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl" },
1758
+ "rgba32uint": { gl: import_constants5.default.RGBA32UI, b: 16, c: 4, renderbuffer: true },
1759
+ "rgba32sint": { gl: import_constants5.default.RGBA32I, b: 16, c: 4, renderbuffer: true },
1760
+ "rgba32float": { gl: import_constants5.default.RGBA32F, b: 16, c: 4, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
1752
1761
  // Depth and stencil formats
1753
- "stencil8": { gl: import_constants5.default.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants5.default.STENCIL_ATTACHMENT },
1762
+ "stencil8": { gl: import_constants5.default.STENCIL_INDEX8, gl1: import_constants5.default.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants5.default.STENCIL_ATTACHMENT, renderbuffer: true },
1754
1763
  // 8 stencil bits
1755
- "depth16unorm": { gl: import_constants5.default.DEPTH_COMPONENT16, gl1: import_constants5.default.DEPTH_COMPONENT16, b: 2, c: 1, attachment: import_constants5.default.DEPTH_ATTACHMENT },
1764
+ "depth16unorm": { gl: import_constants5.default.DEPTH_COMPONENT16, gl1: import_constants5.default.DEPTH_COMPONENT16, b: 2, c: 1, attachment: import_constants5.default.DEPTH_ATTACHMENT, renderbuffer: true },
1756
1765
  // 16 depth bits
1757
1766
  "depth24plus": { gl: import_constants5.default.DEPTH_COMPONENT24, b: 3, c: 1, attachment: import_constants5.default.DEPTH_ATTACHMENT },
1758
- "depth32float": { gl: import_constants5.default.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: import_constants5.default.DEPTH_ATTACHMENT },
1759
- "depth24plus-stencil8": { b: 4, gl: import_constants5.default.UNSIGNED_INT_24_8, gl1: import_constants5.default.DEPTH_STENCIL, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT },
1767
+ "depth32float": { gl: import_constants5.default.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: import_constants5.default.DEPTH_ATTACHMENT, renderbuffer: true },
1768
+ // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
1769
+ "depth24plus-stencil8": { gl: import_constants5.default.DEPTH_STENCIL, gl1: import_constants5.default.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true },
1760
1770
  // "depth24unorm-stencil8" feature
1761
- "depth24unorm-stencil8": { gl: import_constants5.default.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT },
1771
+ "depth24unorm-stencil8": { gl: import_constants5.default.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
1762
1772
  // "depth32float-stencil8" feature
1763
- "depth32float-stencil8": { gl: import_constants5.default.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT },
1773
+ "depth32float-stencil8": { gl: import_constants5.default.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: import_constants5.default.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
1764
1774
  // BC compressed formats: check device.features.has("texture-compression-bc");
1765
1775
  "bc1-rgb-unorm-webgl": { gl: import_constants5.default.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
1766
1776
  "bc1-rgb-unorm-srgb-webgl": { gl: import_constants5.default.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
@@ -1831,18 +1841,33 @@ var TEXTURE_FORMATS = {
1831
1841
  "atc-rgba-unorm-webgl": { gl: import_constants5.default.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, f: texture_compression_atc_webgl },
1832
1842
  "atc-rgbai-unorm-webgl": { gl: import_constants5.default.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl }
1833
1843
  };
1834
- function getTextureFormat(format) {
1835
- if (typeof format === "string") {
1836
- return format;
1837
- }
1838
- const entry = Object.entries(TEXTURE_FORMATS).find(([, entry2]) => entry2.gl === format || entry2.gl1 === format);
1839
- if (!entry) {
1840
- throw new Error(`Unknown texture format ${format}`);
1841
- }
1842
- return entry[0];
1843
- }
1844
+ var DATA_FORMAT_CHANNELS = {
1845
+ [import_constants5.default.RED]: 1,
1846
+ [import_constants5.default.RED_INTEGER]: 1,
1847
+ [import_constants5.default.RG]: 2,
1848
+ [import_constants5.default.RG_INTEGER]: 2,
1849
+ [import_constants5.default.RGB]: 3,
1850
+ [import_constants5.default.RGB_INTEGER]: 3,
1851
+ [import_constants5.default.RGBA]: 4,
1852
+ [import_constants5.default.RGBA_INTEGER]: 4,
1853
+ [import_constants5.default.DEPTH_COMPONENT]: 1,
1854
+ [import_constants5.default.DEPTH_STENCIL]: 1,
1855
+ [import_constants5.default.ALPHA]: 1,
1856
+ [import_constants5.default.LUMINANCE]: 1,
1857
+ [import_constants5.default.LUMINANCE_ALPHA]: 2
1858
+ };
1859
+ var TYPE_SIZES = {
1860
+ [import_constants5.default.FLOAT]: 4,
1861
+ [import_constants5.default.UNSIGNED_INT]: 4,
1862
+ [import_constants5.default.INT]: 4,
1863
+ [import_constants5.default.UNSIGNED_SHORT]: 2,
1864
+ [import_constants5.default.SHORT]: 2,
1865
+ [import_constants5.default.HALF_FLOAT]: 2,
1866
+ [import_constants5.default.BYTE]: 1,
1867
+ [import_constants5.default.UNSIGNED_BYTE]: 1
1868
+ };
1844
1869
  function isTextureFormatSupported(gl, formatOrGL) {
1845
- const format = getTextureFormat(formatOrGL);
1870
+ const format = convertGLToTextureFormat(formatOrGL);
1846
1871
  const info = TEXTURE_FORMATS[format];
1847
1872
  if (!info) {
1848
1873
  return false;
@@ -1856,8 +1881,32 @@ function isTextureFormatSupported(gl, formatOrGL) {
1856
1881
  }
1857
1882
  return true;
1858
1883
  }
1884
+ function isRenderbufferFormatSupported(gl, format) {
1885
+ var _a;
1886
+ return isTextureFormatSupported(gl, format) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.renderbuffer);
1887
+ }
1888
+ function convertGLToTextureFormat(format) {
1889
+ if (typeof format === "string") {
1890
+ return format;
1891
+ }
1892
+ const entry = Object.entries(TEXTURE_FORMATS).find(
1893
+ ([, entry2]) => entry2.gl === format || entry2.gl1 === format
1894
+ );
1895
+ if (!entry) {
1896
+ throw new Error(`Unknown texture format ${format}`);
1897
+ }
1898
+ return entry[0];
1899
+ }
1900
+ function convertTextureFormatToGL(format, isWebGL23) {
1901
+ const formatInfo = TEXTURE_FORMATS[format];
1902
+ const webglFormat = isWebGL23 ? formatInfo == null ? void 0 : formatInfo.gl : formatInfo == null ? void 0 : formatInfo.gl1;
1903
+ if (webglFormat === void 0) {
1904
+ throw new Error(`Unsupported texture format ${format}`);
1905
+ }
1906
+ return webglFormat;
1907
+ }
1859
1908
  function isTextureFormatFilterable(gl, formatOrGL) {
1860
- const format = getTextureFormat(formatOrGL);
1909
+ const format = convertGLToTextureFormat(formatOrGL);
1861
1910
  if (!isTextureFormatSupported(gl, format)) {
1862
1911
  return false;
1863
1912
  }
@@ -1878,7 +1927,7 @@ function isTextureFormatFilterable(gl, formatOrGL) {
1878
1927
  return true;
1879
1928
  }
1880
1929
  function isTextureFormatRenderable(gl, formatOrGL) {
1881
- const format = getTextureFormat(formatOrGL);
1930
+ const format = convertGLToTextureFormat(formatOrGL);
1882
1931
  if (!isTextureFormatSupported(gl, format)) {
1883
1932
  return false;
1884
1933
  }
@@ -1887,21 +1936,9 @@ function isTextureFormatRenderable(gl, formatOrGL) {
1887
1936
  }
1888
1937
  return true;
1889
1938
  }
1890
- function getWebGLTextureFormat(gl, formatOrGL) {
1891
- const format = getTextureFormat(formatOrGL);
1892
- const formatInfo = TEXTURE_FORMATS[format];
1893
- const webglFormat = isWebGL2(gl) ? formatInfo == null ? void 0 : formatInfo.gl : formatInfo == null ? void 0 : formatInfo.gl1;
1894
- if (typeof format === "number") {
1895
- return webglFormat || format;
1896
- }
1897
- if (webglFormat === void 0) {
1898
- throw new Error(`Unsupported texture format ${format}`);
1899
- }
1900
- return webglFormat;
1901
- }
1902
- function getWebGLTextureParameters(gl, formatOrGL) {
1903
- const format = getTextureFormat(formatOrGL);
1904
- const webglFormat = getWebGLTextureFormat(gl, format);
1939
+ function getWebGLTextureParameters(formatOrGL, isWebGL23) {
1940
+ const format = convertGLToTextureFormat(formatOrGL);
1941
+ const webglFormat = convertTextureFormatToGL(format, isWebGL23);
1905
1942
  const decoded = (0, import_api5.decodeTextureFormat)(format);
1906
1943
  return {
1907
1944
  format: webglFormat,
@@ -1916,17 +1953,12 @@ function getWebGLTextureParameters(gl, formatOrGL) {
1916
1953
  compressed: decoded.compressed
1917
1954
  };
1918
1955
  }
1919
- function getWebGLDepthStencilAttachment(formatOrGL) {
1920
- const format = getTextureFormat(formatOrGL);
1921
- if (typeof format === "number") {
1922
- throw new Error("unsupported depth stencil format");
1923
- }
1956
+ function getDepthStencilAttachmentWebGL(format) {
1924
1957
  const info = TEXTURE_FORMATS[format];
1925
- const attachment = info.attachment;
1926
- if (!attachment) {
1927
- throw new Error("not a depth stencil format");
1958
+ if (!(info == null ? void 0 : info.attachment)) {
1959
+ throw new Error(`${format} is not a depth stencil format`);
1928
1960
  }
1929
- return attachment;
1961
+ return info.attachment;
1930
1962
  }
1931
1963
  function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat = import_constants5.default.RGBA, srcType = import_constants5.default.UNSIGNED_BYTE) {
1932
1964
  let texture = null;
@@ -1961,34 +1993,9 @@ function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat =
1961
1993
  gl.deleteFramebuffer(framebuffer);
1962
1994
  }
1963
1995
  }
1964
- var DATA_FORMAT_CHANNELS = {
1965
- [import_constants5.default.RED]: 1,
1966
- [import_constants5.default.RED_INTEGER]: 1,
1967
- [import_constants5.default.RG]: 2,
1968
- [import_constants5.default.RG_INTEGER]: 2,
1969
- [import_constants5.default.RGB]: 3,
1970
- [import_constants5.default.RGB_INTEGER]: 3,
1971
- [import_constants5.default.RGBA]: 4,
1972
- [import_constants5.default.RGBA_INTEGER]: 4,
1973
- [import_constants5.default.DEPTH_COMPONENT]: 1,
1974
- [import_constants5.default.DEPTH_STENCIL]: 1,
1975
- [import_constants5.default.ALPHA]: 1,
1976
- [import_constants5.default.LUMINANCE]: 1,
1977
- [import_constants5.default.LUMINANCE_ALPHA]: 2
1978
- };
1979
- var TYPE_SIZES = {
1980
- [import_constants5.default.FLOAT]: 4,
1981
- [import_constants5.default.UNSIGNED_INT]: 4,
1982
- [import_constants5.default.INT]: 4,
1983
- [import_constants5.default.UNSIGNED_SHORT]: 2,
1984
- [import_constants5.default.SHORT]: 2,
1985
- [import_constants5.default.HALF_FLOAT]: 2,
1986
- [import_constants5.default.BYTE]: 1,
1987
- [import_constants5.default.UNSIGNED_BYTE]: 1
1988
- };
1989
- function getTextureFormatBytesPerPixel(gl, formatOrGL) {
1990
- const format = getTextureFormat(formatOrGL);
1991
- const params = getWebGLTextureParameters(gl, format);
1996
+ function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
1997
+ const format = convertGLToTextureFormat(formatOrGL);
1998
+ const params = getWebGLTextureParameters(format, isWebGL23);
1992
1999
  const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
1993
2000
  const channelSize = TYPE_SIZES[params.type] || 1;
1994
2001
  return channels * channelSize;
@@ -2279,12 +2286,12 @@ var import_api15 = require("@luma.gl/api");
2279
2286
 
2280
2287
  // src/adapter/resources/webgl-framebuffer.ts
2281
2288
  var import_api14 = require("@luma.gl/api");
2282
- var import_constants14 = __toESM(require("@luma.gl/constants"), 1);
2289
+ var import_constants13 = __toESM(require("@luma.gl/constants"), 1);
2283
2290
 
2284
2291
  // src/adapter/resources/webgl-texture.ts
2285
2292
  var import_api9 = require("@luma.gl/api");
2286
2293
  var import_api10 = require("@luma.gl/api");
2287
- var import_constants11 = __toESM(require("@luma.gl/constants"), 1);
2294
+ var import_constants11 = require("@luma.gl/constants");
2288
2295
 
2289
2296
  // src/context/state-tracker/with-parameters.ts
2290
2297
  function withParameters(device, parameters, func) {
@@ -2317,7 +2324,7 @@ function isObjectEmpty2(object) {
2317
2324
  }
2318
2325
 
2319
2326
  // src/adapter/converters/sampler-parameters.ts
2320
- var import_constants8 = __toESM(require("@luma.gl/constants"), 1);
2327
+ var import_constants8 = require("@luma.gl/constants");
2321
2328
 
2322
2329
  // src/adapter/converters/device-parameters.ts
2323
2330
  var import_api6 = require("@luma.gl/api");
@@ -2365,10 +2372,12 @@ function setDeviceParameters(device, parameters) {
2365
2372
  }
2366
2373
  }
2367
2374
  if (parameters.frontFace) {
2368
- gl.frontFace(map("frontFace", parameters.frontFace, {
2369
- ccw: import_constants7.default.CCW,
2370
- cw: import_constants7.default.CW
2371
- }));
2375
+ gl.frontFace(
2376
+ map("frontFace", parameters.frontFace, {
2377
+ ccw: import_constants7.default.CCW,
2378
+ cw: import_constants7.default.CW
2379
+ })
2380
+ );
2372
2381
  }
2373
2382
  if (parameters.depthBias !== void 0) {
2374
2383
  gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
@@ -2398,29 +2407,32 @@ function setDeviceParameters(device, parameters) {
2398
2407
  if (parameters.stencilPassOperation && parameters.stencilFailOperation && parameters.stencilDepthFailOperation) {
2399
2408
  const dppass = convertStencilOperation("stencilPassOperation", parameters.stencilPassOperation);
2400
2409
  const sfail = convertStencilOperation("stencilFailOperation", parameters.stencilFailOperation);
2401
- const dpfail = convertStencilOperation("stencilDepthFailOperation", parameters.stencilDepthFailOperation);
2410
+ const dpfail = convertStencilOperation(
2411
+ "stencilDepthFailOperation",
2412
+ parameters.stencilDepthFailOperation
2413
+ );
2402
2414
  gl.stencilOpSeparate(import_constants7.default.FRONT, sfail, dpfail, dppass);
2403
2415
  gl.stencilOpSeparate(import_constants7.default.BACK, sfail, dpfail, dppass);
2404
2416
  }
2405
2417
  }
2406
2418
  function convertCompareFunction(parameter, value) {
2407
2419
  return map(parameter, value, {
2408
- "never": import_constants7.default.NEVER,
2409
- "less": import_constants7.default.LESS,
2410
- "equal": import_constants7.default.EQUAL,
2420
+ never: import_constants7.default.NEVER,
2421
+ less: import_constants7.default.LESS,
2422
+ equal: import_constants7.default.EQUAL,
2411
2423
  "less-equal": import_constants7.default.LEQUAL,
2412
- "greater": import_constants7.default.GREATER,
2424
+ greater: import_constants7.default.GREATER,
2413
2425
  "not-equal": import_constants7.default.NOTEQUAL,
2414
2426
  "greater-equal": import_constants7.default.GEQUAL,
2415
- "always": import_constants7.default.ALWAYS
2427
+ always: import_constants7.default.ALWAYS
2416
2428
  });
2417
2429
  }
2418
2430
  function convertStencilOperation(parameter, value) {
2419
2431
  return map(parameter, value, {
2420
- "keep": import_constants7.default.KEEP,
2421
- "zero": import_constants7.default.ZERO,
2422
- "replace": import_constants7.default.REPLACE,
2423
- "invert": import_constants7.default.INVERT,
2432
+ keep: import_constants7.default.KEEP,
2433
+ zero: import_constants7.default.ZERO,
2434
+ replace: import_constants7.default.REPLACE,
2435
+ invert: import_constants7.default.INVERT,
2424
2436
  "increment-clamp": import_constants7.default.INCR,
2425
2437
  "decrement-clamp": import_constants7.default.DECR,
2426
2438
  "increment-wrap": import_constants7.default.INCR_WRAP,
@@ -2444,53 +2456,53 @@ function mapBoolean(parameter, value) {
2444
2456
  function convertSamplerParametersToWebGL(props) {
2445
2457
  const params = {};
2446
2458
  if (props.addressModeU) {
2447
- params[import_constants8.default.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
2459
+ params[import_constants8.GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
2448
2460
  }
2449
2461
  if (props.addressModeV) {
2450
- params[import_constants8.default.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);
2462
+ params[import_constants8.GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);
2451
2463
  }
2452
2464
  if (props.addressModeW) {
2453
- params[import_constants8.default.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);
2465
+ params[import_constants8.GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);
2454
2466
  }
2455
2467
  if (props.magFilter) {
2456
- params[import_constants8.default.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);
2468
+ params[import_constants8.GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);
2457
2469
  }
2458
2470
  if (props.minFilter || props.mipmapFilter) {
2459
- params[import_constants8.default.TEXTURE_MIN_FILTER] = convertMinFilterMode(props.minFilter || "linear", props.mipmapFilter);
2471
+ params[import_constants8.GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(props.minFilter || "linear", props.mipmapFilter);
2460
2472
  }
2461
2473
  if (props.lodMinClamp !== void 0) {
2462
- params[import_constants8.default.TEXTURE_MIN_LOD] = props.lodMinClamp;
2474
+ params[import_constants8.GL.TEXTURE_MIN_LOD] = props.lodMinClamp;
2463
2475
  }
2464
2476
  if (props.lodMaxClamp !== void 0) {
2465
- params[import_constants8.default.TEXTURE_MAX_LOD] = props.lodMaxClamp;
2477
+ params[import_constants8.GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;
2466
2478
  }
2467
2479
  if (props.type === "comparison-sampler") {
2468
- params[import_constants8.default.TEXTURE_COMPARE_MODE] = import_constants8.default.COMPARE_REF_TO_TEXTURE;
2480
+ params[import_constants8.GL.TEXTURE_COMPARE_MODE] = import_constants8.GL.COMPARE_REF_TO_TEXTURE;
2469
2481
  }
2470
2482
  if (props.compare) {
2471
- params[import_constants8.default.TEXTURE_COMPARE_FUNC] = convertCompareFunction("compare", props.compare);
2483
+ params[import_constants8.GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction("compare", props.compare);
2472
2484
  }
2473
2485
  if (props.maxAnisotropy) {
2474
- params[import_constants8.default.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;
2486
+ params[import_constants8.GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;
2475
2487
  }
2476
2488
  return params;
2477
2489
  }
2478
2490
  function convertAddressMode(addressMode) {
2479
2491
  switch (addressMode) {
2480
2492
  case "clamp-to-edge":
2481
- return import_constants8.default.CLAMP_TO_EDGE;
2493
+ return import_constants8.GL.CLAMP_TO_EDGE;
2482
2494
  case "repeat":
2483
- return import_constants8.default.REPEAT;
2495
+ return import_constants8.GL.REPEAT;
2484
2496
  case "mirror-repeat":
2485
- return import_constants8.default.MIRRORED_REPEAT;
2497
+ return import_constants8.GL.MIRRORED_REPEAT;
2486
2498
  }
2487
2499
  }
2488
2500
  function convertMaxFilterMode(maxFilter) {
2489
2501
  switch (maxFilter) {
2490
2502
  case "nearest":
2491
- return import_constants8.default.NEAREST;
2503
+ return import_constants8.GL.NEAREST;
2492
2504
  case "linear":
2493
- return import_constants8.default.LINEAR;
2505
+ return import_constants8.GL.LINEAR;
2494
2506
  }
2495
2507
  }
2496
2508
  function convertMinFilterMode(minFilter, mipmapFilter) {
@@ -2499,18 +2511,18 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
2499
2511
  }
2500
2512
  switch (minFilter) {
2501
2513
  case "nearest":
2502
- return mipmapFilter === "nearest" ? import_constants8.default.NEAREST_MIPMAP_NEAREST : import_constants8.default.NEAREST_MIPMAP_LINEAR;
2514
+ return mipmapFilter === "nearest" ? import_constants8.GL.NEAREST_MIPMAP_NEAREST : import_constants8.GL.NEAREST_MIPMAP_LINEAR;
2503
2515
  case "linear":
2504
- return mipmapFilter === "nearest" ? import_constants8.default.LINEAR_MIPMAP_NEAREST : import_constants8.default.LINEAR_MIPMAP_LINEAR;
2516
+ return mipmapFilter === "nearest" ? import_constants8.GL.LINEAR_MIPMAP_NEAREST : import_constants8.GL.LINEAR_MIPMAP_LINEAR;
2505
2517
  }
2506
2518
  }
2507
2519
  function updateSamplerParametersForNPOT(parameters) {
2508
2520
  const newParameters = __spreadValues({}, parameters);
2509
- if (parameters[import_constants8.default.TEXTURE_MIN_FILTER] !== import_constants8.default.NEAREST) {
2510
- newParameters[import_constants8.default.TEXTURE_MIN_FILTER] = import_constants8.default.LINEAR;
2521
+ if (parameters[import_constants8.GL.TEXTURE_MIN_FILTER] !== import_constants8.GL.NEAREST) {
2522
+ newParameters[import_constants8.GL.TEXTURE_MIN_FILTER] = import_constants8.GL.LINEAR;
2511
2523
  }
2512
- newParameters[import_constants8.default.TEXTURE_WRAP_S] = import_constants8.default.CLAMP_TO_EDGE;
2513
- newParameters[import_constants8.default.TEXTURE_WRAP_T] = import_constants8.default.CLAMP_TO_EDGE;
2524
+ newParameters[import_constants8.GL.TEXTURE_WRAP_S] = import_constants8.GL.CLAMP_TO_EDGE;
2525
+ newParameters[import_constants8.GL.TEXTURE_WRAP_T] = import_constants8.GL.CLAMP_TO_EDGE;
2514
2526
  return newParameters;
2515
2527
  }
2516
2528
 
@@ -2575,16 +2587,17 @@ var WEBGLBuffer = class extends import_api7.Buffer {
2575
2587
  this.trackDeallocatedMemory();
2576
2588
  this.gl.deleteBuffer(this.handle);
2577
2589
  this.destroyed = true;
2590
+ this.handle = null;
2578
2591
  }
2579
2592
  }
2580
2593
  write(data, byteOffset = 0) {
2581
2594
  const srcOffset = 0;
2582
- const byteLength = data.byteLength;
2595
+ const byteLength = void 0;
2583
2596
  const target = this.device.isWebGL2 ? import_constants9.default.COPY_WRITE_BUFFER : this.target;
2584
2597
  this.gl.bindBuffer(target, this.handle);
2585
2598
  if (srcOffset !== 0 || byteLength !== void 0) {
2586
2599
  this.device.assertWebGL2();
2587
- this.gl.bufferSubData(this.target, byteOffset, data, srcOffset, byteLength);
2600
+ this.gl2.bufferSubData(target, byteOffset, data, srcOffset, byteLength);
2588
2601
  } else {
2589
2602
  this.gl.bufferSubData(target, byteOffset, data);
2590
2603
  }
@@ -2640,7 +2653,7 @@ function getWebGLUsage(usage) {
2640
2653
 
2641
2654
  // src/adapter/resources/webgl-sampler.ts
2642
2655
  var import_api8 = require("@luma.gl/api");
2643
- var import_constants10 = __toESM(require("@luma.gl/constants"), 1);
2656
+ var import_constants10 = require("@luma.gl/constants");
2644
2657
  var WEBGLSampler = class extends import_api8.Sampler {
2645
2658
  constructor(device, props) {
2646
2659
  super(device, props);
@@ -2665,8 +2678,8 @@ var WEBGLSampler = class extends import_api8.Sampler {
2665
2678
  for (const [pname, value] of Object.entries(parameters)) {
2666
2679
  const param = Number(pname);
2667
2680
  switch (param) {
2668
- case import_constants10.default.TEXTURE_MIN_LOD:
2669
- case import_constants10.default.TEXTURE_MAX_LOD:
2681
+ case import_constants10.GL.TEXTURE_MIN_LOD:
2682
+ case import_constants10.GL.TEXTURE_MAX_LOD:
2670
2683
  this.device.gl2.samplerParameterf(this.handle, param, value);
2671
2684
  break;
2672
2685
  default:
@@ -2678,20 +2691,28 @@ var WEBGLSampler = class extends import_api8.Sampler {
2678
2691
  };
2679
2692
 
2680
2693
  // src/adapter/resources/webgl-texture.ts
2694
+ var DEFAULT_WEBGL_TEXTURE_PROPS = {
2695
+ // deprecated
2696
+ parameters: {},
2697
+ pixelStore: {},
2698
+ pixels: null,
2699
+ border: 0,
2700
+ dataFormat: void 0,
2701
+ textureUnit: void 0,
2702
+ target: void 0
2703
+ };
2681
2704
  var _WEBGLTexture = class extends import_api10.Texture {
2682
2705
  constructor(device, props) {
2683
2706
  var _a;
2684
- super(device, __spreadValues({ format: import_constants11.default.RGBA }, props));
2685
- this.width = void 0;
2686
- this.height = void 0;
2687
- this.depth = void 0;
2688
- this.format = void 0;
2707
+ super(device, __spreadValues(__spreadProps(__spreadValues({}, DEFAULT_WEBGL_TEXTURE_PROPS), { format: "rgba8unorm" }), props));
2708
+ /** Sampler object (currently unused) */
2709
+ this.sampler = void 0;
2710
+ // data;
2711
+ this.glFormat = void 0;
2689
2712
  this.type = void 0;
2690
2713
  this.dataFormat = void 0;
2691
2714
  this.mipmaps = void 0;
2692
2715
  this.textureUnit = void 0;
2693
- /** Sampler object (currently unused) */
2694
- this.sampler = void 0;
2695
2716
  /**
2696
2717
  * Program.draw() checks the loaded flag of all textures to avoid
2697
2718
  * Textures that are still loading from promises
@@ -2703,6 +2724,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2703
2724
  this.gl2 = this.device.gl2;
2704
2725
  this.handle = this.props.handle || this.gl.createTexture();
2705
2726
  this.device.setSpectorMetadata(this.handle, __spreadProps(__spreadValues({}, this.props), { data: typeof this.props.data }));
2727
+ this.glFormat = import_constants11.GL.RGBA;
2706
2728
  this.target = getWebGLTextureTarget(this.props);
2707
2729
  this.loaded = false;
2708
2730
  if (typeof ((_a = this.props) == null ? void 0 : _a.data) === "string") {
@@ -2748,7 +2770,6 @@ var _WEBGLTexture = class extends import_api10.Texture {
2748
2770
  const { parameters = {} } = props;
2749
2771
  const {
2750
2772
  pixels = null,
2751
- recreate = false,
2752
2773
  pixelStore = {},
2753
2774
  textureUnit = void 0
2754
2775
  } = props;
@@ -2757,6 +2778,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2757
2778
  }
2758
2779
  let { width, height, dataFormat, type, compressed = false, mipmaps = true } = props;
2759
2780
  const { depth = 0 } = props;
2781
+ const glFormat = convertTextureFormatToGL(props.format, this.device.isWebGL2);
2760
2782
  ({ width, height, compressed, dataFormat, type } = this._deduceParameters({
2761
2783
  format: props.format,
2762
2784
  type,
@@ -2766,16 +2788,14 @@ var _WEBGLTexture = class extends import_api10.Texture {
2766
2788
  width,
2767
2789
  height
2768
2790
  }));
2769
- const format = getWebGLTextureFormat(this.gl, props.format);
2770
2791
  this.width = width;
2771
2792
  this.height = height;
2772
- this.depth = depth;
2773
- this.format = format;
2793
+ this.glFormat = glFormat;
2774
2794
  this.type = type;
2775
2795
  this.dataFormat = dataFormat;
2776
2796
  this.textureUnit = textureUnit;
2777
2797
  if (Number.isFinite(this.textureUnit)) {
2778
- this.gl.activeTexture(import_constants11.default.TEXTURE0 + this.textureUnit);
2798
+ this.gl.activeTexture(import_constants11.GL.TEXTURE0 + this.textureUnit);
2779
2799
  this.gl.bindTexture(this.target, this.handle);
2780
2800
  }
2781
2801
  if (mipmaps && this.device.isWebGL1 && isNPOT(this.width, this.height)) {
@@ -2788,7 +2808,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2788
2808
  width,
2789
2809
  height,
2790
2810
  depth,
2791
- format,
2811
+ format: glFormat,
2792
2812
  type,
2793
2813
  dataFormat,
2794
2814
  // @ts-expect-error
@@ -2800,9 +2820,6 @@ var _WEBGLTexture = class extends import_api10.Texture {
2800
2820
  if (mipmaps) {
2801
2821
  this.generateMipmap();
2802
2822
  }
2803
- if (recreate) {
2804
- this.data = data;
2805
- }
2806
2823
  if (isVideo) {
2807
2824
  this._video = {
2808
2825
  video: data,
@@ -2909,7 +2926,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2909
2926
  */
2910
2927
  // eslint-disable-next-line max-statements, complexity
2911
2928
  setImageData(options) {
2912
- if (this.props.dimension === "3d") {
2929
+ if (this.props.dimension === "3d" || this.props.dimension === "2d-array") {
2913
2930
  return this.setImageData3D(options);
2914
2931
  }
2915
2932
  this.trackDeallocatedMemory("Texture");
@@ -2917,7 +2934,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2917
2934
  target = this.target,
2918
2935
  pixels = null,
2919
2936
  level = 0,
2920
- format = this.format,
2937
+ glFormat = this.glFormat,
2921
2938
  offset = 0,
2922
2939
  parameters = {}
2923
2940
  } = options;
@@ -2949,13 +2966,13 @@ var _WEBGLTexture = class extends import_api10.Texture {
2949
2966
  withParameters(this.gl, parameters, () => {
2950
2967
  switch (dataType) {
2951
2968
  case "null":
2952
- gl.texImage2D(target, level, format, width, height, 0, dataFormat, type, data);
2969
+ gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
2953
2970
  break;
2954
2971
  case "typed-array":
2955
2972
  gl.texImage2D(
2956
2973
  target,
2957
2974
  level,
2958
- format,
2975
+ glFormat,
2959
2976
  width,
2960
2977
  height,
2961
2978
  0,
@@ -2969,11 +2986,11 @@ var _WEBGLTexture = class extends import_api10.Texture {
2969
2986
  break;
2970
2987
  case "buffer":
2971
2988
  gl2 = this.device.assertWebGL2();
2972
- gl2.bindBuffer(import_constants11.default.PIXEL_UNPACK_BUFFER, data.handle || data);
2989
+ gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data.handle || data);
2973
2990
  gl2.texImage2D(
2974
2991
  target,
2975
2992
  level,
2976
- format,
2993
+ glFormat,
2977
2994
  width,
2978
2995
  height,
2979
2996
  0,
@@ -2981,14 +2998,14 @@ var _WEBGLTexture = class extends import_api10.Texture {
2981
2998
  type,
2982
2999
  offset
2983
3000
  );
2984
- gl2.bindBuffer(import_constants11.default.PIXEL_UNPACK_BUFFER, null);
3001
+ gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, null);
2985
3002
  break;
2986
3003
  case "browser-object":
2987
3004
  if (this.device.isWebGL2) {
2988
3005
  gl.texImage2D(
2989
3006
  target,
2990
3007
  level,
2991
- format,
3008
+ glFormat,
2992
3009
  width,
2993
3010
  height,
2994
3011
  0,
@@ -2997,7 +3014,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
2997
3014
  data
2998
3015
  );
2999
3016
  } else {
3000
- gl.texImage2D(target, level, format, dataFormat, type, data);
3017
+ gl.texImage2D(target, level, glFormat, dataFormat, type, data);
3001
3018
  }
3002
3019
  break;
3003
3020
  case "compressed":
@@ -3020,7 +3037,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3020
3037
  if (data && data.byteLength) {
3021
3038
  this.trackAllocatedMemory(data.byteLength, "Texture");
3022
3039
  } else {
3023
- const bytesPerPixel = getTextureFormatBytesPerPixel(this.gl, this.props.format);
3040
+ const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
3024
3041
  this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, "Texture");
3025
3042
  }
3026
3043
  this.loaded = true;
@@ -3040,7 +3057,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3040
3057
  width = this.width,
3041
3058
  height = this.height,
3042
3059
  level = 0,
3043
- format = this.format,
3060
+ glFormat = this.glFormat,
3044
3061
  type = this.type,
3045
3062
  dataFormat = this.dataFormat,
3046
3063
  compressed = false,
@@ -3072,16 +3089,16 @@ var _WEBGLTexture = class extends import_api10.Texture {
3072
3089
  this.gl.bindTexture(this.target, this.handle);
3073
3090
  withParameters(this.gl, parameters, () => {
3074
3091
  if (compressed) {
3075
- this.gl.compressedTexSubImage2D(target, level, x, y, width, height, format, data);
3092
+ this.gl.compressedTexSubImage2D(target, level, x, y, width, height, glFormat, data);
3076
3093
  } else if (data === null) {
3077
3094
  this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, null);
3078
3095
  } else if (ArrayBuffer.isView(data)) {
3079
3096
  this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data, offset);
3080
3097
  } else if (typeof WebGLBuffer !== "undefined" && data instanceof WebGLBuffer) {
3081
3098
  const gl2 = this.device.assertWebGL2();
3082
- gl2.bindBuffer(import_constants11.default.PIXEL_UNPACK_BUFFER, data);
3099
+ gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data);
3083
3100
  gl2.texSubImage2D(target, level, x, y, width, height, dataFormat, type, offset);
3084
- gl2.bindBuffer(import_constants11.default.PIXEL_UNPACK_BUFFER, null);
3101
+ gl2.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, null);
3085
3102
  } else if (this.device.isWebGL2) {
3086
3103
  const gl2 = this.device.assertWebGL2();
3087
3104
  gl2.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data);
@@ -3106,7 +3123,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3106
3123
  return null;
3107
3124
  }
3108
3125
  getActiveUnit() {
3109
- return this.gl.getParameter(import_constants11.default.ACTIVE_TEXTURE) - import_constants11.default.TEXTURE0;
3126
+ return this.gl.getParameter(import_constants11.GL.ACTIVE_TEXTURE) - import_constants11.GL.TEXTURE0;
3110
3127
  }
3111
3128
  bind(textureUnit = this.textureUnit) {
3112
3129
  const { gl } = this;
@@ -3149,7 +3166,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3149
3166
  _deduceParameters(opts) {
3150
3167
  const { format, data } = opts;
3151
3168
  let { width, height, dataFormat, type, compressed } = opts;
3152
- const parameters = getWebGLTextureParameters(this.gl, format);
3169
+ const parameters = getWebGLTextureParameters(format, this.device.isWebGL2);
3153
3170
  dataFormat = dataFormat || parameters.dataFormat;
3154
3171
  type = type || parameters.type;
3155
3172
  compressed = compressed || parameters.compressed;
@@ -3190,7 +3207,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3190
3207
  setCubeMapImageData(options) {
3191
3208
  return __async(this, null, function* () {
3192
3209
  const { gl } = this;
3193
- const { width, height, pixels, data, format = import_constants11.default.RGBA, type = import_constants11.default.UNSIGNED_BYTE } = options;
3210
+ const { width, height, pixels, data, format = import_constants11.GL.RGBA, type = import_constants11.GL.UNSIGNED_BYTE } = options;
3194
3211
  const imageDataMap = pixels || data;
3195
3212
  const resolvedFaces = yield Promise.all(
3196
3213
  _WEBGLTexture.FACES.map((face) => {
@@ -3222,8 +3239,8 @@ var _WEBGLTexture = class extends import_api10.Texture {
3222
3239
  height,
3223
3240
  pixels,
3224
3241
  data,
3225
- format = import_constants11.default.RGBA,
3226
- type = import_constants11.default.UNSIGNED_BYTE
3242
+ format = import_constants11.GL.RGBA,
3243
+ type = import_constants11.GL.UNSIGNED_BYTE
3227
3244
  // generateMipmap = false // TODO
3228
3245
  } = options;
3229
3246
  const { gl } = this;
@@ -3263,7 +3280,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3263
3280
  } = options;
3264
3281
  this.trackDeallocatedMemory("Texture");
3265
3282
  this.gl.bindTexture(this.target, this.handle);
3266
- const webglTextureFormat = getWebGLTextureParameters(this.gl, format);
3283
+ const webglTextureFormat = getWebGLTextureParameters(format, this.device.isWebGL2);
3267
3284
  withParameters(this.gl, parameters, () => {
3268
3285
  if (ArrayBuffer.isView(data)) {
3269
3286
  this.gl.texImage3D(
@@ -3281,7 +3298,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3281
3298
  );
3282
3299
  }
3283
3300
  if (data instanceof WEBGLBuffer) {
3284
- this.gl.bindBuffer(import_constants11.default.PIXEL_UNPACK_BUFFER, data.handle);
3301
+ this.gl.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data.handle);
3285
3302
  this.gl.texImage3D(
3286
3303
  this.target,
3287
3304
  level,
@@ -3299,7 +3316,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
3299
3316
  if (data && data.byteLength) {
3300
3317
  this.trackAllocatedMemory(data.byteLength, "Texture");
3301
3318
  } else {
3302
- const bytesPerPixel = getTextureFormatBytesPerPixel(this.gl, this.props.format);
3319
+ const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
3303
3320
  this.trackAllocatedMemory(this.width * this.height * this.depth * bytesPerPixel, "Texture");
3304
3321
  }
3305
3322
  this.loaded = true;
@@ -3323,8 +3340,8 @@ var _WEBGLTexture = class extends import_api10.Texture {
3323
3340
  const param = Number(pname);
3324
3341
  const value = pvalue;
3325
3342
  switch (param) {
3326
- case import_constants11.default.TEXTURE_MIN_LOD:
3327
- case import_constants11.default.TEXTURE_MAX_LOD:
3343
+ case import_constants11.GL.TEXTURE_MIN_LOD:
3344
+ case import_constants11.GL.TEXTURE_MAX_LOD:
3328
3345
  this.gl.texParameterf(this.target, param, value);
3329
3346
  break;
3330
3347
  default:
@@ -3340,14 +3357,14 @@ var _WEBGLTexture = class extends import_api10.Texture {
3340
3357
  const npot = this.device.isWebGL1 && isNPOT(this.width, this.height);
3341
3358
  if (npot) {
3342
3359
  switch (pname) {
3343
- case import_constants11.default.TEXTURE_MIN_FILTER:
3344
- if (value !== import_constants11.default.LINEAR && value !== import_constants11.default.NEAREST) {
3345
- return import_constants11.default.LINEAR;
3360
+ case import_constants11.GL.TEXTURE_MIN_FILTER:
3361
+ if (value !== import_constants11.GL.LINEAR && value !== import_constants11.GL.NEAREST) {
3362
+ return import_constants11.GL.LINEAR;
3346
3363
  }
3347
3364
  break;
3348
- case import_constants11.default.TEXTURE_WRAP_S:
3349
- case import_constants11.default.TEXTURE_WRAP_T:
3350
- return import_constants11.default.CLAMP_TO_EDGE;
3365
+ case import_constants11.GL.TEXTURE_WRAP_S:
3366
+ case import_constants11.GL.TEXTURE_WRAP_T:
3367
+ return import_constants11.GL.CLAMP_TO_EDGE;
3351
3368
  default:
3352
3369
  break;
3353
3370
  }
@@ -3358,23 +3375,23 @@ var _WEBGLTexture = class extends import_api10.Texture {
3358
3375
  var WEBGLTexture = _WEBGLTexture;
3359
3376
  // TODO - remove?
3360
3377
  WEBGLTexture.FACES = [
3361
- import_constants11.default.TEXTURE_CUBE_MAP_POSITIVE_X,
3362
- import_constants11.default.TEXTURE_CUBE_MAP_NEGATIVE_X,
3363
- import_constants11.default.TEXTURE_CUBE_MAP_POSITIVE_Y,
3364
- import_constants11.default.TEXTURE_CUBE_MAP_NEGATIVE_Y,
3365
- import_constants11.default.TEXTURE_CUBE_MAP_POSITIVE_Z,
3366
- import_constants11.default.TEXTURE_CUBE_MAP_NEGATIVE_Z
3378
+ import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_X,
3379
+ import_constants11.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,
3380
+ import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,
3381
+ import_constants11.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,
3382
+ import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,
3383
+ import_constants11.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z
3367
3384
  ];
3368
3385
  function getWebGLTextureTarget(props) {
3369
3386
  switch (props.dimension) {
3370
3387
  case "2d":
3371
- return import_constants11.default.TEXTURE_2D;
3388
+ return import_constants11.GL.TEXTURE_2D;
3372
3389
  case "cube":
3373
- return import_constants11.default.TEXTURE_CUBE_MAP;
3390
+ return import_constants11.GL.TEXTURE_CUBE_MAP;
3374
3391
  case "2d-array":
3375
- return import_constants11.default.TEXTURE_2D_ARRAY;
3392
+ return import_constants11.GL.TEXTURE_2D_ARRAY;
3376
3393
  case "3d":
3377
- return import_constants11.default.TEXTURE_3D;
3394
+ return import_constants11.GL.TEXTURE_3D;
3378
3395
  case "1d":
3379
3396
  case "cube-array":
3380
3397
  default:
@@ -3393,7 +3410,7 @@ function logParameters(parameters) {
3393
3410
 
3394
3411
  // src/adapter/objects/webgl-renderbuffer.ts
3395
3412
  var import_api13 = require("@luma.gl/api");
3396
- var import_constants13 = __toESM(require("@luma.gl/constants"), 1);
3413
+ var import_constants12 = __toESM(require("@luma.gl/constants"), 1);
3397
3414
 
3398
3415
  // src/adapter/objects/webgl-resource.ts
3399
3416
  var import_api12 = require("@luma.gl/api");
@@ -3413,16 +3430,6 @@ function getKeyValue(gl, name) {
3413
3430
  (0, import_api11.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
3414
3431
  return value;
3415
3432
  }
3416
- function getKey(gl, value) {
3417
- gl = gl.gl || gl;
3418
- value = Number(value);
3419
- for (const key in gl) {
3420
- if (gl[key] === value) {
3421
- return `GL.${key}`;
3422
- }
3423
- }
3424
- return String(value);
3425
- }
3426
3433
 
3427
3434
  // src/adapter/objects/webgl-resource.ts
3428
3435
  var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
@@ -3451,9 +3458,6 @@ var WebGLResource = class extends import_api12.Resource {
3451
3458
  get handle() {
3452
3459
  return this._handle;
3453
3460
  }
3454
- destroy() {
3455
- this.delete();
3456
- }
3457
3461
  delete({ deleteChildren = false } = {}) {
3458
3462
  const children = this._handle && this._deleteHandle(this._handle);
3459
3463
  if (this._handle) {
@@ -3461,7 +3465,7 @@ var WebGLResource = class extends import_api12.Resource {
3461
3465
  }
3462
3466
  this._handle = null;
3463
3467
  if (children && deleteChildren) {
3464
- children.filter(Boolean).forEach((child) => child.delete());
3468
+ children.filter(Boolean).forEach((child) => child.destroy());
3465
3469
  }
3466
3470
  return this;
3467
3471
  }
@@ -3521,10 +3525,10 @@ var WebGLResource = class extends import_api12.Resource {
3521
3525
  const parameter = PARAMETERS[pname];
3522
3526
  const parameterAvailable = parameter && (!("webgl2" in parameter) || isWebgl2) && (!("extension" in parameter) || this.gl.getExtension(parameter.extension));
3523
3527
  if (parameterAvailable) {
3524
- const key = keys ? getKey(this.gl, pname) : pname;
3528
+ const key = keys ? this.device.getGLKey(pname) : pname;
3525
3529
  values[key] = this.getParameter(pname, options);
3526
3530
  if (keys && parameter.type === "GLenum") {
3527
- values[key] = getKey(this.gl, values[key]);
3531
+ values[key] = this.device.getGLKey(values[key]);
3528
3532
  }
3529
3533
  }
3530
3534
  }
@@ -3629,88 +3633,16 @@ var WebGLResource = class extends import_api12.Resource {
3629
3633
  */
3630
3634
  };
3631
3635
 
3632
- // src/adapter/converters/renderbuffer-formats.ts
3633
- var import_constants12 = __toESM(require("@luma.gl/constants"), 1);
3634
- function isRenderbufferFormatSupported(gl, format) {
3635
- const info = RENDERBUFFER_FORMATS[format];
3636
- if (!info) {
3637
- return false;
3638
- }
3639
- if (info.ext) {
3640
- return Boolean(gl.getExtension(info.ext));
3641
- }
3642
- if (info.gl2) {
3643
- return isWebGL2(gl);
3644
- }
3645
- return true;
3646
- }
3647
- function getRenderbufferFormatBytesPerPixel(format) {
3648
- return RENDERBUFFER_FORMATS[format].bpp;
3649
- }
3650
- var EXT_FLOAT_WEBGL2 = "EXT_color_buffer_float";
3651
- var RENDERBUFFER_FORMATS = {
3652
- [import_constants12.default.DEPTH_COMPONENT16]: { bpp: 2 },
3653
- // 16 depth bits.
3654
- [import_constants12.default.DEPTH_COMPONENT24]: { gl2: true, bpp: 3 },
3655
- [import_constants12.default.DEPTH_COMPONENT32F]: { gl2: true, bpp: 4 },
3656
- [import_constants12.default.STENCIL_INDEX8]: { bpp: 1 },
3657
- // 8 stencil bits.
3658
- [import_constants12.default.DEPTH_STENCIL]: { bpp: 4 },
3659
- [import_constants12.default.DEPTH24_STENCIL8]: { gl2: true, bpp: 4 },
3660
- [import_constants12.default.DEPTH32F_STENCIL8]: { gl2: true, bpp: 5 },
3661
- // When using a WebGL 1 context, color renderbuffer formats are limited
3662
- [import_constants12.default.RGBA4]: { bpp: 2 },
3663
- [import_constants12.default.RGB565]: { bpp: 2 },
3664
- [import_constants12.default.RGB5_A1]: { bpp: 2 },
3665
- // When using a WebGL 2 context, the following values are available additionally:
3666
- [import_constants12.default.R8]: { gl2: true, bpp: 1 },
3667
- [import_constants12.default.R8UI]: { gl2: true, bpp: 1 },
3668
- [import_constants12.default.R8I]: { gl2: true, bpp: 1 },
3669
- [import_constants12.default.R16UI]: { gl2: true, bpp: 2 },
3670
- [import_constants12.default.R16I]: { gl2: true, bpp: 2 },
3671
- [import_constants12.default.R32UI]: { gl2: true, bpp: 4 },
3672
- [import_constants12.default.R32I]: { gl2: true, bpp: 4 },
3673
- [import_constants12.default.RG8]: { gl2: true, bpp: 2 },
3674
- [import_constants12.default.RG8UI]: { gl2: true, bpp: 2 },
3675
- [import_constants12.default.RG8I]: { gl2: true, bpp: 2 },
3676
- [import_constants12.default.RG16UI]: { gl2: true, bpp: 4 },
3677
- [import_constants12.default.RG16I]: { gl2: true, bpp: 4 },
3678
- [import_constants12.default.RG32UI]: { gl2: true, bpp: 8 },
3679
- [import_constants12.default.RG32I]: { gl2: true, bpp: 8 },
3680
- [import_constants12.default.RGB8]: { gl2: true, bpp: 3 },
3681
- [import_constants12.default.RGBA8]: { gl2: true, bpp: 4 },
3682
- // [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
3683
- [import_constants12.default.RGB10_A2]: { gl2: true, bpp: 4 },
3684
- [import_constants12.default.RGBA8UI]: { gl2: true, bpp: 4 },
3685
- [import_constants12.default.RGBA8I]: { gl2: true, bpp: 4 },
3686
- [import_constants12.default.RGB10_A2UI]: { gl2: true, bpp: 4 },
3687
- [import_constants12.default.RGBA16UI]: { gl2: true, bpp: 8 },
3688
- [import_constants12.default.RGBA16I]: { gl2: true, bpp: 8 },
3689
- [import_constants12.default.RGBA32I]: { gl2: true, bpp: 16 },
3690
- [import_constants12.default.RGBA32UI]: { gl2: true, bpp: 16 },
3691
- // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
3692
- [import_constants12.default.R16F]: { ext: EXT_FLOAT_WEBGL2, bpp: 2 },
3693
- [import_constants12.default.RG16F]: { ext: EXT_FLOAT_WEBGL2, bpp: 4 },
3694
- [import_constants12.default.RGBA16F]: { ext: EXT_FLOAT_WEBGL2, bpp: 8 },
3695
- [import_constants12.default.R32F]: { ext: EXT_FLOAT_WEBGL2, bpp: 4 },
3696
- [import_constants12.default.RG32F]: { ext: EXT_FLOAT_WEBGL2, bpp: 8 },
3697
- // TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
3698
- [import_constants12.default.RGBA32F]: { ext: EXT_FLOAT_WEBGL2, bpp: 16 },
3699
- // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1},
3700
- [import_constants12.default.R11F_G11F_B10F]: { ext: EXT_FLOAT_WEBGL2, bpp: 4 }
3701
- };
3702
-
3703
3636
  // src/adapter/objects/webgl-renderbuffer.ts
3704
- var DEFAULT_RENDERBUFFER_PROPS = {
3705
- id: void 0,
3706
- handle: void 0,
3707
- userData: void 0,
3708
- format: 0,
3709
- width: 1,
3710
- height: 1,
3711
- samples: 0
3712
- };
3713
- var WEBGLRenderbuffer = class extends WebGLResource {
3637
+ var _WEBGLRenderbuffer = class extends WebGLResource {
3638
+ constructor(device, props) {
3639
+ if (typeof props.format === "number") {
3640
+ throw new Error("Renderbuffer");
3641
+ }
3642
+ super(device, props, _WEBGLRenderbuffer.defaultProps);
3643
+ this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
3644
+ this._initialize(this.props);
3645
+ }
3714
3646
  get [Symbol.toStringTag]() {
3715
3647
  return "Renderbuffer";
3716
3648
  }
@@ -3726,19 +3658,17 @@ var WEBGLRenderbuffer = class extends WebGLResource {
3726
3658
  get samples() {
3727
3659
  return this.props.samples;
3728
3660
  }
3729
- static isSupported(gl, options) {
3730
- return !(options == null ? void 0 : options.format) || isRenderbufferFormatSupported(gl, options.format);
3661
+ get attachment() {
3662
+ return;
3731
3663
  }
3732
- constructor(device, props) {
3733
- super(device, props, DEFAULT_RENDERBUFFER_PROPS);
3734
- this._initialize(this.props);
3664
+ static isTextureFormatSupported(device, format) {
3665
+ return isRenderbufferFormatSupported(device.gl, format);
3735
3666
  }
3736
3667
  resize(size) {
3737
3668
  if (size.width !== this.width || size.height !== this.height) {
3738
3669
  Object.assign(this.props, __spreadProps(__spreadValues({}, size), { format: this.format, samples: this.samples }));
3739
3670
  this._initialize(this.props);
3740
3671
  }
3741
- return this;
3742
3672
  }
3743
3673
  // PRIVATE METHODS
3744
3674
  /** Creates and initializes a renderbuffer object's data store */
@@ -3746,17 +3676,16 @@ var WEBGLRenderbuffer = class extends WebGLResource {
3746
3676
  const { format, width, height, samples } = props;
3747
3677
  (0, import_api13.assert)(format, "Needs format");
3748
3678
  this.trackDeallocatedMemory();
3749
- this.gl.bindRenderbuffer(import_constants13.default.RENDERBUFFER, this.handle);
3679
+ this.gl.bindRenderbuffer(import_constants12.default.RENDERBUFFER, this.handle);
3750
3680
  if (samples !== 0 && this.device.isWebGL2) {
3751
- this.gl.renderbufferStorageMultisample(import_constants13.default.RENDERBUFFER, samples, format, width, height);
3681
+ this.gl2.renderbufferStorageMultisample(import_constants12.default.RENDERBUFFER, samples, this.glFormat, width, height);
3752
3682
  } else {
3753
- this.gl.renderbufferStorage(import_constants13.default.RENDERBUFFER, format, width, height);
3683
+ this.gl.renderbufferStorage(import_constants12.default.RENDERBUFFER, this.glFormat, width, height);
3754
3684
  }
3755
- this.gl.bindRenderbuffer(import_constants13.default.RENDERBUFFER, null);
3685
+ this.gl.bindRenderbuffer(import_constants12.default.RENDERBUFFER, null);
3756
3686
  this.trackAllocatedMemory(
3757
- width * height * (samples || 1) * getRenderbufferFormatBytesPerPixel(format)
3687
+ width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)
3758
3688
  );
3759
- return this;
3760
3689
  }
3761
3690
  // RESOURCE IMPLEMENTATION
3762
3691
  _createHandle() {
@@ -3767,37 +3696,48 @@ var WEBGLRenderbuffer = class extends WebGLResource {
3767
3696
  this.trackDeallocatedMemory();
3768
3697
  }
3769
3698
  _bindHandle(handle) {
3770
- this.gl.bindRenderbuffer(import_constants13.default.RENDERBUFFER, handle);
3699
+ this.gl.bindRenderbuffer(import_constants12.default.RENDERBUFFER, handle);
3771
3700
  }
3772
3701
  };
3702
+ var WEBGLRenderbuffer = _WEBGLRenderbuffer;
3703
+ WEBGLRenderbuffer.defaultProps = {
3704
+ id: void 0,
3705
+ handle: void 0,
3706
+ userData: void 0,
3707
+ format: void 0,
3708
+ // 'depth16unorm'
3709
+ width: 1,
3710
+ height: 1,
3711
+ samples: 0
3712
+ };
3773
3713
 
3774
3714
  // src/adapter/resources/webgl-framebuffer.ts
3775
3715
  var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3776
3716
  constructor(device, props) {
3777
3717
  super(device, props);
3778
- this.colorAttachments = [];
3779
- this.depthStencilAttachment = null;
3780
- this._ownResources = [];
3718
+ const isDefaultFramebuffer = props.handle === null;
3781
3719
  this.device = device;
3782
3720
  this.gl = device.gl;
3783
- this.handle = this.props.handle !== void 0 ? this.props.handle : this.gl.createFramebuffer();
3784
- if (this.handle) {
3721
+ this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
3722
+ if (!isDefaultFramebuffer) {
3785
3723
  device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
3786
- }
3787
- this.colorAttachments = this._createColorAttachments();
3788
- this.depthStencilAttachment = this._createDepthStencilAttachment();
3789
- const prevHandle = this.gl.bindFramebuffer(import_constants14.default.FRAMEBUFFER, this.handle);
3790
- for (let i = 0; i < this.colorAttachments.length; ++i) {
3791
- const attachment = this.colorAttachments[i];
3792
- const attachmentPoint = import_constants14.default.COLOR_ATTACHMENT0 + i;
3793
- if (attachment) {
3794
- this._attachOne(attachmentPoint, attachment);
3724
+ this.autoCreateAttachmentTextures();
3725
+ this.gl.bindFramebuffer(import_constants13.default.FRAMEBUFFER, this.handle);
3726
+ for (let i = 0; i < this.colorAttachments.length; ++i) {
3727
+ const attachment = this.colorAttachments[i];
3728
+ const attachmentPoint = import_constants13.default.COLOR_ATTACHMENT0 + i;
3729
+ if (attachment) {
3730
+ this._attachOne(attachmentPoint, attachment);
3731
+ }
3795
3732
  }
3733
+ if (this.depthStencilAttachment) {
3734
+ this._attachOne(
3735
+ getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),
3736
+ this.depthStencilAttachment
3737
+ );
3738
+ }
3739
+ this.gl.bindFramebuffer(import_constants13.default.FRAMEBUFFER, null);
3796
3740
  }
3797
- if (this.props.depthStencilAttachment) {
3798
- this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
3799
- }
3800
- this.gl.bindFramebuffer(import_constants14.default.FRAMEBUFFER, prevHandle || null);
3801
3741
  if (props.check !== false) {
3802
3742
  this._checkStatus();
3803
3743
  }
@@ -3805,98 +3745,40 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3805
3745
  get texture() {
3806
3746
  return this.colorAttachments[0];
3807
3747
  }
3748
+ /** destroys any auto created resources etc. */
3808
3749
  destroy() {
3809
- if (this.handle !== null) {
3810
- for (const resource of this._ownResources) {
3811
- resource.destroy();
3812
- }
3750
+ super.destroy();
3751
+ if (!this.destroyed && this.handle !== null) {
3813
3752
  this.gl.deleteFramebuffer(this.handle);
3814
- this.destroyed = true;
3815
3753
  }
3816
3754
  }
3817
3755
  // PRIVATE
3818
3756
  /** Check the status */
3819
3757
  _checkStatus() {
3820
3758
  const { gl } = this;
3821
- const prevHandle = gl.bindFramebuffer(import_constants14.default.FRAMEBUFFER, this.handle);
3822
- const status = gl.checkFramebufferStatus(import_constants14.default.FRAMEBUFFER);
3823
- gl.bindFramebuffer(import_constants14.default.FRAMEBUFFER, prevHandle || null);
3759
+ const prevHandle2 = gl.bindFramebuffer(import_constants13.default.FRAMEBUFFER, this.handle);
3760
+ const status = gl.checkFramebufferStatus(import_constants13.default.FRAMEBUFFER);
3761
+ gl.bindFramebuffer(import_constants13.default.FRAMEBUFFER, prevHandle2 || null);
3824
3762
  if (status !== gl.FRAMEBUFFER_COMPLETE) {
3825
3763
  throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
3826
3764
  }
3827
3765
  }
3828
- _createColorAttachments() {
3829
- return this.props.colorAttachments.map((colorAttachment) => {
3830
- if (!colorAttachment) {
3831
- return void 0;
3832
- }
3833
- if (colorAttachment instanceof WEBGLTexture) {
3834
- return colorAttachment;
3835
- }
3836
- return this._createColorAttachment(colorAttachment, this.width, this.height);
3837
- });
3838
- }
3839
- /** Create a color attachment */
3840
- _createColorAttachment(format, width, height) {
3841
- const texture = this.device._createTexture({
3842
- id: `${this.id}-color`,
3843
- data: null,
3844
- // reserves texture memory, but texels are undefined
3845
- format,
3846
- // type: GL.UNSIGNED_BYTE,
3847
- width,
3848
- height,
3849
- // Note: Mipmapping can be disabled by texture resource when we resize the texture
3850
- // to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
3851
- // behavior we always disable mipmaps.
3852
- mipmaps: false,
3853
- // Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
3854
- // Use LINEAR so subpixel algos like fxaa work.
3855
- // Set WRAP modes that support NPOT textures too.
3856
- sampler: {
3857
- minFilter: "linear",
3858
- magFilter: "linear",
3859
- addressModeU: "clamp-to-edge",
3860
- addressModeV: "clamp-to-edge"
3861
- }
3862
- // parameters: {
3863
- // [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
3864
- // [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
3865
- // [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
3866
- // [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
3867
- // }
3868
- });
3869
- this._ownResources.push(texture);
3870
- return texture;
3871
- }
3872
- /** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */
3873
- _createDepthStencilAttachment() {
3874
- if (!this.props.depthStencilAttachment) {
3875
- return void 0;
3876
- }
3877
- if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {
3878
- return this.props.depthStencilAttachment;
3879
- }
3880
- if (this.props.depthStencilAttachment instanceof import_api14.Texture) {
3881
- return this.props.depthStencilAttachment;
3882
- }
3883
- const format = this.props.depthStencilAttachment;
3884
- const webglFormat = getWebGLTextureFormat(this.gl, format);
3885
- const texture = new WEBGLRenderbuffer(this.device, {
3766
+ /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
3767
+ createDepthStencilTexture(format) {
3768
+ return new WEBGLRenderbuffer(this.device, {
3886
3769
  id: `${this.id}-depth-stencil`,
3887
3770
  // TODO misleading if not depth and stencil?
3888
- format: webglFormat,
3771
+ format,
3889
3772
  // dataFormat: GL.DEPTH_STENCIL,
3890
3773
  // type: GL.UNSIGNED_INT_24_8,
3891
3774
  width: this.width,
3892
3775
  height: this.height
3893
3776
  });
3894
- this._ownResources.push(texture);
3895
- return texture;
3896
3777
  }
3897
- /** Attachment resize is expected to be a noop if size is same */
3898
- _resizeAttachments(width, height) {
3899
- var _a;
3778
+ /**
3779
+ * Attachment resize is expected to be a noop if size is same
3780
+ */
3781
+ resizeAttachments(width, height) {
3900
3782
  if (this.handle === null) {
3901
3783
  this.width = this.gl.drawingBufferWidth;
3902
3784
  this.height = this.gl.drawingBufferHeight;
@@ -3908,13 +3790,12 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3908
3790
  if (height === void 0) {
3909
3791
  height = this.gl.drawingBufferHeight;
3910
3792
  }
3911
- if (width !== this.width && height !== this.height) {
3912
- import_api14.log.log(2, `Resizing framebuffer ${this.id} to ${width}x${height}`)();
3913
- }
3914
3793
  for (const colorAttachment of this.colorAttachments) {
3915
3794
  colorAttachment.resize({ width, height });
3916
3795
  }
3917
- (_a = this.depthStencilAttachment) == null ? void 0 : _a.resize({ width, height });
3796
+ if (this.depthStencilAttachment) {
3797
+ this.depthStencilAttachment.resize({ width, height });
3798
+ }
3918
3799
  return this;
3919
3800
  }
3920
3801
  /** Attach one attachment */
@@ -3934,9 +3815,9 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3934
3815
  }
3935
3816
  _attachWEBGLRenderbuffer(attachment, renderbuffer) {
3936
3817
  this.gl.framebufferRenderbuffer(
3937
- import_constants14.default.FRAMEBUFFER,
3818
+ import_constants13.default.FRAMEBUFFER,
3938
3819
  attachment,
3939
- import_constants14.default.RENDERBUFFER,
3820
+ import_constants13.default.RENDERBUFFER,
3940
3821
  renderbuffer.handle
3941
3822
  );
3942
3823
  }
@@ -3950,17 +3831,17 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3950
3831
  const { gl, gl2 } = this.device;
3951
3832
  gl.bindTexture(texture.target, texture.handle);
3952
3833
  switch (texture.target) {
3953
- case import_constants14.default.TEXTURE_2D_ARRAY:
3954
- case import_constants14.default.TEXTURE_3D:
3834
+ case import_constants13.default.TEXTURE_2D_ARRAY:
3835
+ case import_constants13.default.TEXTURE_3D:
3955
3836
  this.device.assertWebGL2();
3956
- gl2 == null ? void 0 : gl2.framebufferTextureLayer(import_constants14.default.FRAMEBUFFER, attachment, texture.target, level, layer);
3837
+ gl2 == null ? void 0 : gl2.framebufferTextureLayer(import_constants13.default.FRAMEBUFFER, attachment, texture.target, level, layer);
3957
3838
  break;
3958
- case import_constants14.default.TEXTURE_CUBE_MAP:
3839
+ case import_constants13.default.TEXTURE_CUBE_MAP:
3959
3840
  const face = mapIndexToCubeMapFace(layer);
3960
- gl.framebufferTexture2D(import_constants14.default.FRAMEBUFFER, attachment, face, texture.handle, level);
3841
+ gl.framebufferTexture2D(import_constants13.default.FRAMEBUFFER, attachment, face, texture.handle, level);
3961
3842
  break;
3962
- case import_constants14.default.TEXTURE_2D:
3963
- gl.framebufferTexture2D(import_constants14.default.FRAMEBUFFER, attachment, import_constants14.default.TEXTURE_2D, texture.handle, level);
3843
+ case import_constants13.default.TEXTURE_2D:
3844
+ gl.framebufferTexture2D(import_constants13.default.FRAMEBUFFER, attachment, import_constants13.default.TEXTURE_2D, texture.handle, level);
3964
3845
  break;
3965
3846
  default:
3966
3847
  (0, import_api14.assert)(false, "Illegal texture type");
@@ -3969,21 +3850,21 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
3969
3850
  }
3970
3851
  };
3971
3852
  function mapIndexToCubeMapFace(layer) {
3972
- return layer < import_constants14.default.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants14.default.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
3853
+ return layer < import_constants13.default.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants13.default.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
3973
3854
  }
3974
3855
  function _getFrameBufferStatus(status) {
3975
3856
  switch (status) {
3976
- case import_constants14.default.FRAMEBUFFER_COMPLETE:
3857
+ case import_constants13.default.FRAMEBUFFER_COMPLETE:
3977
3858
  return "success";
3978
- case import_constants14.default.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
3859
+ case import_constants13.default.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
3979
3860
  return "Mismatched attachments";
3980
- case import_constants14.default.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
3861
+ case import_constants13.default.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
3981
3862
  return "No attachments";
3982
- case import_constants14.default.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
3863
+ case import_constants13.default.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
3983
3864
  return "Height/width mismatch";
3984
- case import_constants14.default.FRAMEBUFFER_UNSUPPORTED:
3865
+ case import_constants13.default.FRAMEBUFFER_UNSUPPORTED:
3985
3866
  return "Unsupported or split attachments";
3986
- case import_constants14.default.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
3867
+ case import_constants13.default.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
3987
3868
  return "Samples mismatch";
3988
3869
  default:
3989
3870
  return `${status}`;
@@ -4100,7 +3981,7 @@ function initializeSpectorJS(props) {
4100
3981
 
4101
3982
  // src/context/debug/webgl-developer-tools.ts
4102
3983
  var import_api17 = require("@luma.gl/api");
4103
- var import_constants15 = __toESM(require("@luma.gl/constants"), 1);
3984
+ var import_constants14 = __toESM(require("@luma.gl/constants"), 1);
4104
3985
  var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
4105
3986
  function getContextData2(gl) {
4106
3987
  gl.luma = gl.luma || {};
@@ -4134,15 +4015,15 @@ function getDebugContext(gl, props) {
4134
4015
  if (data.debugContext) {
4135
4016
  return data.debugContext;
4136
4017
  }
4137
- globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants15.default), gl));
4018
+ globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants14.default), gl));
4138
4019
  const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
4139
4020
  gl,
4140
4021
  onGLError.bind(null, props),
4141
4022
  onValidateGLFunc.bind(null, props)
4142
4023
  );
4143
- for (const key in import_constants15.default) {
4144
- if (!(key in glDebug) && typeof import_constants15.default[key] === "number") {
4145
- glDebug[key] = import_constants15.default[key];
4024
+ for (const key in import_constants14.default) {
4025
+ if (!(key in glDebug) && typeof import_constants14.default[key] === "number") {
4026
+ glDebug[key] = import_constants14.default[key];
4146
4027
  }
4147
4028
  }
4148
4029
  class WebGLDebugContext {
@@ -4201,34 +4082,34 @@ function onValidateGLFunc(props, functionName, functionArgs) {
4201
4082
 
4202
4083
  // src/classic/buffer.ts
4203
4084
  var import_api19 = require("@luma.gl/api");
4204
- var import_constants18 = __toESM(require("@luma.gl/constants"), 1);
4085
+ var import_constants17 = __toESM(require("@luma.gl/constants"), 1);
4205
4086
 
4206
4087
  // src/classic/accessor.ts
4207
4088
  var import_api18 = require("@luma.gl/api");
4208
- var import_constants17 = __toESM(require("@luma.gl/constants"), 1);
4089
+ var import_constants16 = __toESM(require("@luma.gl/constants"), 1);
4209
4090
 
4210
4091
  // src/classic/typed-array-utils.ts
4211
- var import_constants16 = __toESM(require("@luma.gl/constants"), 1);
4092
+ var import_constants15 = require("@luma.gl/constants");
4212
4093
  var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
4213
4094
  function getGLTypeFromTypedArray(arrayOrType) {
4214
4095
  const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
4215
4096
  switch (type) {
4216
4097
  case Float32Array:
4217
- return import_constants16.default.FLOAT;
4098
+ return import_constants15.GL.FLOAT;
4218
4099
  case Uint16Array:
4219
- return import_constants16.default.UNSIGNED_SHORT;
4100
+ return import_constants15.GL.UNSIGNED_SHORT;
4220
4101
  case Uint32Array:
4221
- return import_constants16.default.UNSIGNED_INT;
4102
+ return import_constants15.GL.UNSIGNED_INT;
4222
4103
  case Uint8Array:
4223
- return import_constants16.default.UNSIGNED_BYTE;
4104
+ return import_constants15.GL.UNSIGNED_BYTE;
4224
4105
  case Uint8ClampedArray:
4225
- return import_constants16.default.UNSIGNED_BYTE;
4106
+ return import_constants15.GL.UNSIGNED_BYTE;
4226
4107
  case Int8Array:
4227
- return import_constants16.default.BYTE;
4108
+ return import_constants15.GL.BYTE;
4228
4109
  case Int16Array:
4229
- return import_constants16.default.SHORT;
4110
+ return import_constants15.GL.SHORT;
4230
4111
  case Int32Array:
4231
- return import_constants16.default.INT;
4112
+ return import_constants15.GL.INT;
4232
4113
  default:
4233
4114
  throw new Error(ERR_TYPE_DEDUCTION);
4234
4115
  }
@@ -4236,22 +4117,22 @@ function getGLTypeFromTypedArray(arrayOrType) {
4236
4117
  function getTypedArrayFromGLType(glType, options) {
4237
4118
  const { clamped = true } = options || {};
4238
4119
  switch (glType) {
4239
- case import_constants16.default.FLOAT:
4120
+ case import_constants15.GL.FLOAT:
4240
4121
  return Float32Array;
4241
- case import_constants16.default.UNSIGNED_SHORT:
4242
- case import_constants16.default.UNSIGNED_SHORT_5_6_5:
4243
- case import_constants16.default.UNSIGNED_SHORT_4_4_4_4:
4244
- case import_constants16.default.UNSIGNED_SHORT_5_5_5_1:
4122
+ case import_constants15.GL.UNSIGNED_SHORT:
4123
+ case import_constants15.GL.UNSIGNED_SHORT_5_6_5:
4124
+ case import_constants15.GL.UNSIGNED_SHORT_4_4_4_4:
4125
+ case import_constants15.GL.UNSIGNED_SHORT_5_5_5_1:
4245
4126
  return Uint16Array;
4246
- case import_constants16.default.UNSIGNED_INT:
4127
+ case import_constants15.GL.UNSIGNED_INT:
4247
4128
  return Uint32Array;
4248
- case import_constants16.default.UNSIGNED_BYTE:
4129
+ case import_constants15.GL.UNSIGNED_BYTE:
4249
4130
  return clamped ? Uint8ClampedArray : Uint8Array;
4250
- case import_constants16.default.BYTE:
4131
+ case import_constants15.GL.BYTE:
4251
4132
  return Int8Array;
4252
- case import_constants16.default.SHORT:
4133
+ case import_constants15.GL.SHORT:
4253
4134
  return Int16Array;
4254
- case import_constants16.default.INT:
4135
+ case import_constants15.GL.INT:
4255
4136
  return Int32Array;
4256
4137
  default:
4257
4138
  throw new Error("Failed to deduce typed array type from GL constant");
@@ -4262,7 +4143,7 @@ function getTypedArrayFromGLType(glType, options) {
4262
4143
  var DEFAULT_ACCESSOR_VALUES = {
4263
4144
  offset: 0,
4264
4145
  stride: 0,
4265
- type: import_constants17.default.FLOAT,
4146
+ type: import_constants16.default.FLOAT,
4266
4147
  size: 1,
4267
4148
  divisor: 0,
4268
4149
  normalized: false,
@@ -4276,12 +4157,12 @@ var PROP_CHECKS = {
4276
4157
  };
4277
4158
  var Accessor = class {
4278
4159
  static getBytesPerElement(accessor) {
4279
- const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants17.default.FLOAT);
4160
+ const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.default.FLOAT);
4280
4161
  return ArrayType.BYTES_PER_ELEMENT;
4281
4162
  }
4282
4163
  static getBytesPerVertex(accessor) {
4283
4164
  (0, import_api18.assert)(accessor.size);
4284
- const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants17.default.FLOAT);
4165
+ const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.default.FLOAT);
4285
4166
  return ArrayType.BYTES_PER_ELEMENT * accessor.size;
4286
4167
  }
4287
4168
  // Combines (merges) a list of accessors. On top of default values
@@ -4312,7 +4193,7 @@ var Accessor = class {
4312
4193
  props = (0, import_api18.checkProps)("Accessor", props, PROP_CHECKS);
4313
4194
  if (props.type !== void 0) {
4314
4195
  this.type = props.type;
4315
- if (props.type === import_constants17.default.INT || props.type === import_constants17.default.UNSIGNED_INT) {
4196
+ if (props.type === import_constants16.default.INT || props.type === import_constants16.default.UNSIGNED_INT) {
4316
4197
  this.integer = true;
4317
4198
  }
4318
4199
  }
@@ -4424,9 +4305,9 @@ var ClassicBuffer = class extends WEBGLBuffer {
4424
4305
  }
4425
4306
  Object.seal(this);
4426
4307
  }
4427
- write(data, byteOffset) {
4428
- this.subData({ data, offset: byteOffset });
4429
- }
4308
+ // override write(data: TypedArray, byteOffset: number = 0): void {
4309
+ // this.subData({data, offset: byteOffset});
4310
+ // }
4430
4311
  // returns number of elements in the buffer (assuming that the full buffer is used)
4431
4312
  getElementCount(accessor = this.accessor) {
4432
4313
  return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));
@@ -4447,7 +4328,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4447
4328
  props = { byteLength: props };
4448
4329
  }
4449
4330
  props = (0, import_api19.checkProps)("Buffer", props, PROP_CHECKS_INITIALIZE);
4450
- this.webglUsage = props.webglUsage || import_constants18.default.STATIC_DRAW;
4331
+ this.webglUsage = props.webglUsage || import_constants17.default.STATIC_DRAW;
4451
4332
  this.debugData = null;
4452
4333
  this.setAccessor(Object.assign({}, props, props.accessor));
4453
4334
  if (props.data) {
@@ -4501,7 +4382,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4501
4382
  const { data, offset = 0, srcOffset = 0 } = options;
4502
4383
  const byteLength = options.byteLength || options.length;
4503
4384
  (0, import_api19.assert)(data);
4504
- const target = this.gl.webgl2 ? import_constants18.default.COPY_WRITE_BUFFER : this.target;
4385
+ const target = this.gl.webgl2 ? import_constants17.default.COPY_WRITE_BUFFER : this.target;
4505
4386
  this.gl.bindBuffer(target, this.handle);
4506
4387
  if (srcOffset !== 0 || byteLength !== void 0) {
4507
4388
  assertWebGL2Context(this.gl);
@@ -4522,11 +4403,11 @@ var ClassicBuffer = class extends WEBGLBuffer {
4522
4403
  const { sourceBuffer, readOffset = 0, writeOffset = 0, size } = options;
4523
4404
  const { gl, gl2 } = this;
4524
4405
  assertWebGL2Context(gl);
4525
- gl.bindBuffer(import_constants18.default.COPY_READ_BUFFER, sourceBuffer.handle);
4526
- gl.bindBuffer(import_constants18.default.COPY_WRITE_BUFFER, this.handle);
4527
- gl2 == null ? void 0 : gl2.copyBufferSubData(import_constants18.default.COPY_READ_BUFFER, import_constants18.default.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
4528
- gl.bindBuffer(import_constants18.default.COPY_READ_BUFFER, null);
4529
- gl.bindBuffer(import_constants18.default.COPY_WRITE_BUFFER, null);
4406
+ gl.bindBuffer(import_constants17.default.COPY_READ_BUFFER, sourceBuffer.handle);
4407
+ gl.bindBuffer(import_constants17.default.COPY_WRITE_BUFFER, this.handle);
4408
+ gl2 == null ? void 0 : gl2.copyBufferSubData(import_constants17.default.COPY_READ_BUFFER, import_constants17.default.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
4409
+ gl.bindBuffer(import_constants17.default.COPY_READ_BUFFER, null);
4410
+ gl.bindBuffer(import_constants17.default.COPY_WRITE_BUFFER, null);
4530
4411
  this.debugData = null;
4531
4412
  return this;
4532
4413
  }
@@ -4539,7 +4420,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4539
4420
  let { dstData = null, length = 0 } = options || {};
4540
4421
  const { srcByteOffset = 0, dstOffset = 0 } = options || {};
4541
4422
  assertWebGL2Context(this.gl);
4542
- const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants18.default.FLOAT, { clamped: false });
4423
+ const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.default.FLOAT, { clamped: false });
4543
4424
  const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);
4544
4425
  const dstElementOffset = dstOffset;
4545
4426
  let dstAvailableElementCount;
@@ -4558,9 +4439,9 @@ var ClassicBuffer = class extends WEBGLBuffer {
4558
4439
  length = length || copyElementCount;
4559
4440
  (0, import_api19.assert)(length <= copyElementCount);
4560
4441
  dstData = dstData || new ArrayType(dstElementCount);
4561
- this.gl.bindBuffer(import_constants18.default.COPY_READ_BUFFER, this.handle);
4562
- (_a = this.gl2) == null ? void 0 : _a.getBufferSubData(import_constants18.default.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
4563
- this.gl.bindBuffer(import_constants18.default.COPY_READ_BUFFER, null);
4442
+ this.gl.bindBuffer(import_constants17.default.COPY_READ_BUFFER, this.handle);
4443
+ (_a = this.gl2) == null ? void 0 : _a.getBufferSubData(import_constants17.default.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
4444
+ this.gl.bindBuffer(import_constants17.default.COPY_READ_BUFFER, null);
4564
4445
  return dstData;
4565
4446
  }
4566
4447
  /**
@@ -4580,7 +4461,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4580
4461
  offset = 0,
4581
4462
  size
4582
4463
  } = options || {};
4583
- if (target === import_constants18.default.UNIFORM_BUFFER || target === import_constants18.default.TRANSFORM_FEEDBACK_BUFFER) {
4464
+ if (target === import_constants17.default.UNIFORM_BUFFER || target === import_constants17.default.TRANSFORM_FEEDBACK_BUFFER) {
4584
4465
  if (size !== void 0) {
4585
4466
  (_a = this.gl2) == null ? void 0 : _a.bindBufferRange(target, index, this.handle, offset, size);
4586
4467
  } else {
@@ -4595,7 +4476,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4595
4476
  unbind(options) {
4596
4477
  var _a;
4597
4478
  const { target = this.target, index = this.accessor && this.accessor.index } = options || {};
4598
- const isIndexedBuffer = target === import_constants18.default.UNIFORM_BUFFER || target === import_constants18.default.TRANSFORM_FEEDBACK_BUFFER;
4479
+ const isIndexedBuffer = target === import_constants17.default.UNIFORM_BUFFER || target === import_constants17.default.TRANSFORM_FEEDBACK_BUFFER;
4599
4480
  if (isIndexedBuffer) {
4600
4481
  (_a = this.gl2) == null ? void 0 : _a.bindBufferBase(target, index, null);
4601
4482
  } else {
@@ -4656,10 +4537,10 @@ var ClassicBuffer = class extends WEBGLBuffer {
4656
4537
  // Binding a buffer for the first time locks the type
4657
4538
  // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
4658
4539
  _getTarget() {
4659
- return this.gl.webgl2 ? import_constants18.default.COPY_WRITE_BUFFER : this.target;
4540
+ return this.gl.webgl2 ? import_constants17.default.COPY_WRITE_BUFFER : this.target;
4660
4541
  }
4661
4542
  _getAvailableElementCount(srcByteOffset) {
4662
- const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants18.default.FLOAT, { clamped: false });
4543
+ const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.default.FLOAT, { clamped: false });
4663
4544
  const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;
4664
4545
  return this.getElementCount() - sourceElementOffset;
4665
4546
  }
@@ -4686,7 +4567,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
4686
4567
 
4687
4568
  // src/adapter/resources/webgl-shader.ts
4688
4569
  var import_api20 = require("@luma.gl/api");
4689
- var import_constants19 = __toESM(require("@luma.gl/constants"), 1);
4570
+ var import_constants18 = __toESM(require("@luma.gl/constants"), 1);
4690
4571
 
4691
4572
  // src/adapter/helpers/get-shader-info.ts
4692
4573
  function getShaderInfo(source, defaultName) {
@@ -4752,10 +4633,10 @@ var WEBGLShader = class extends import_api20.Shader {
4752
4633
  this.device = device;
4753
4634
  switch (this.props.stage) {
4754
4635
  case "vertex":
4755
- this.handle = this.props.handle || this.device.gl.createShader(import_constants19.default.VERTEX_SHADER);
4636
+ this.handle = this.props.handle || this.device.gl.createShader(import_constants18.default.VERTEX_SHADER);
4756
4637
  break;
4757
4638
  case "fragment":
4758
- this.handle = this.props.handle || this.device.gl.createShader(import_constants19.default.FRAGMENT_SHADER);
4639
+ this.handle = this.props.handle || this.device.gl.createShader(import_constants18.default.FRAGMENT_SHADER);
4759
4640
  break;
4760
4641
  default:
4761
4642
  throw new Error(this.props.stage);
@@ -4771,8 +4652,8 @@ var WEBGLShader = class extends import_api20.Shader {
4771
4652
  }
4772
4653
  compilationInfo() {
4773
4654
  return __async(this, null, function* () {
4774
- const log10 = this.device.gl.getShaderInfoLog(this.handle);
4775
- return log10 ? parseShaderCompilerLog(log10) : [];
4655
+ const log9 = this.device.gl.getShaderInfoLog(this.handle);
4656
+ return log9 ? parseShaderCompilerLog(log9) : [];
4776
4657
  });
4777
4658
  }
4778
4659
  // PRIVATE METHODS
@@ -4783,7 +4664,7 @@ ${source2}`;
4783
4664
  const { gl } = this.device;
4784
4665
  gl.shaderSource(this.handle, source);
4785
4666
  gl.compileShader(this.handle);
4786
- const compileStatus = gl.getShaderParameter(this.handle, import_constants19.default.COMPILE_STATUS);
4667
+ const compileStatus = gl.getShaderParameter(this.handle, import_constants18.default.COMPILE_STATUS);
4787
4668
  if (!compileStatus) {
4788
4669
  const shaderLog = gl.getShaderInfoLog(this.handle);
4789
4670
  const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
@@ -4803,10 +4684,17 @@ function getShaderIdFromProps(props) {
4803
4684
 
4804
4685
  // src/adapter/resources/webgl-render-pass.ts
4805
4686
  var import_api21 = require("@luma.gl/api");
4687
+ var import_constants19 = require("@luma.gl/constants");
4688
+ var GL_DEPTH_BUFFER_BIT = 256;
4689
+ var GL_STENCIL_BUFFER_BIT = 1024;
4690
+ var GL_COLOR_BUFFER_BIT = 16384;
4691
+ var GL_COLOR = 6144;
4806
4692
  var WEBGLRenderPass = class extends import_api21.RenderPass {
4807
4693
  constructor(device, props) {
4808
4694
  super(device, props);
4809
4695
  this.device = device;
4696
+ this.setParameters(this.props.parameters);
4697
+ this.clear();
4810
4698
  }
4811
4699
  end() {
4812
4700
  }
@@ -4820,6 +4708,98 @@ var WEBGLRenderPass = class extends import_api21.RenderPass {
4820
4708
  // beginOcclusionQuery(queryIndex: number): void;
4821
4709
  // endOcclusionQuery(): void;
4822
4710
  // executeBundles(bundles: Iterable<GPURenderBundle>): void;
4711
+ /**
4712
+ * Maps RenderPass parameters to GL parameters
4713
+ */
4714
+ setParameters(parameters = {}) {
4715
+ const glParameters = {};
4716
+ if (this.props.framebuffer) {
4717
+ glParameters.framebuffer = this.props.framebuffer;
4718
+ }
4719
+ if (this.props.depthReadOnly) {
4720
+ glParameters.depthMask = !this.props.depthReadOnly;
4721
+ }
4722
+ glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
4723
+ glParameters[import_constants19.GL.RASTERIZER_DISCARD] = this.props.discard;
4724
+ if (parameters.viewport) {
4725
+ glParameters.viewport = parameters.viewport;
4726
+ glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];
4727
+ }
4728
+ glParameters.scissorTest = Boolean(parameters.scissorRect);
4729
+ if (parameters.scissorRect) {
4730
+ glParameters.scissor = parameters.scissorRect;
4731
+ }
4732
+ if (parameters.blendConstant) {
4733
+ glParameters.blendColor = parameters.blendConstant;
4734
+ }
4735
+ if (parameters.stencilReference) {
4736
+ console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
4737
+ parameters[import_constants19.GL.STENCIL_REF] = parameters.stencilReference;
4738
+ }
4739
+ this.glParameters = glParameters;
4740
+ }
4741
+ // Internal
4742
+ /**
4743
+ * Optionally clears depth, color and stencil buffers based on parameters
4744
+ */
4745
+ clear() {
4746
+ const glParameters = __spreadValues({}, this.glParameters);
4747
+ let clearMask = 0;
4748
+ if (this.props.clearColor !== false) {
4749
+ clearMask |= GL_COLOR_BUFFER_BIT;
4750
+ glParameters.clearColor = this.props.clearColor;
4751
+ }
4752
+ if (this.props.clearDepth !== false) {
4753
+ clearMask |= GL_DEPTH_BUFFER_BIT;
4754
+ glParameters.clearDepth = this.props.clearDepth;
4755
+ }
4756
+ if (this.props.clearStencil !== false) {
4757
+ clearMask |= GL_STENCIL_BUFFER_BIT;
4758
+ glParameters.clearStencil = this.props.clearStencil;
4759
+ }
4760
+ if (clearMask !== 0) {
4761
+ withParameters(this.device, glParameters, () => {
4762
+ this.device.gl.clear(clearMask);
4763
+ });
4764
+ }
4765
+ }
4766
+ /**
4767
+ * WebGL2 - clear a specific color buffer
4768
+ */
4769
+ clearColorBuffer(drawBuffer = 0, value = [0, 0, 0, 0]) {
4770
+ withParameters(this.device.gl2, { framebuffer: this.props.framebuffer }, () => {
4771
+ switch (value.constructor) {
4772
+ case Int32Array:
4773
+ this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);
4774
+ break;
4775
+ case Uint32Array:
4776
+ this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);
4777
+ break;
4778
+ case Float32Array:
4779
+ default:
4780
+ this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);
4781
+ break;
4782
+ }
4783
+ });
4784
+ }
4785
+ // clearDepthStencil() {
4786
+ // const GL_DEPTH = 0x1801;
4787
+ // const GL_STENCIL = 0x1802;
4788
+ // const GL_DEPTH_STENCIL = 0x84f9;
4789
+ // case GL_DEPTH:
4790
+ // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);
4791
+ // break;
4792
+ // case GL_STENCIL:
4793
+ // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);
4794
+ // break;
4795
+ // case GL_DEPTH_STENCIL:
4796
+ // const [depth, stencil] = value;
4797
+ // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
4798
+ // break;
4799
+ // default:
4800
+ // assert(false, ERR_ARGUMENTS);
4801
+ // }
4802
+ // });
4823
4803
  };
4824
4804
 
4825
4805
  // src/adapter/resources/webgl-render-pipeline.ts
@@ -4830,61 +4810,61 @@ var import_constants25 = __toESM(require("@luma.gl/constants"), 1);
4830
4810
  var import_constants22 = __toESM(require("@luma.gl/constants"), 1);
4831
4811
 
4832
4812
  // src/adapter/helpers/uniforms.ts
4833
- var import_constants20 = __toESM(require("@luma.gl/constants"), 1);
4813
+ var import_constants20 = require("@luma.gl/constants");
4834
4814
  function isSamplerUniform(type) {
4835
4815
  return SAMPLER_TYPES.includes(type);
4836
4816
  }
4837
4817
  var SAMPLER_TYPES = [
4838
- import_constants20.default.SAMPLER_2D,
4839
- import_constants20.default.SAMPLER_CUBE,
4840
- import_constants20.default.SAMPLER_3D,
4841
- import_constants20.default.SAMPLER_2D_SHADOW,
4842
- import_constants20.default.SAMPLER_2D_ARRAY,
4843
- import_constants20.default.SAMPLER_2D_ARRAY_SHADOW,
4844
- import_constants20.default.SAMPLER_CUBE_SHADOW,
4845
- import_constants20.default.INT_SAMPLER_2D,
4846
- import_constants20.default.INT_SAMPLER_3D,
4847
- import_constants20.default.INT_SAMPLER_CUBE,
4848
- import_constants20.default.INT_SAMPLER_2D_ARRAY,
4849
- import_constants20.default.UNSIGNED_INT_SAMPLER_2D,
4850
- import_constants20.default.UNSIGNED_INT_SAMPLER_3D,
4851
- import_constants20.default.UNSIGNED_INT_SAMPLER_CUBE,
4852
- import_constants20.default.UNSIGNED_INT_SAMPLER_2D_ARRAY
4818
+ import_constants20.GL.SAMPLER_2D,
4819
+ import_constants20.GL.SAMPLER_CUBE,
4820
+ import_constants20.GL.SAMPLER_3D,
4821
+ import_constants20.GL.SAMPLER_2D_SHADOW,
4822
+ import_constants20.GL.SAMPLER_2D_ARRAY,
4823
+ import_constants20.GL.SAMPLER_2D_ARRAY_SHADOW,
4824
+ import_constants20.GL.SAMPLER_CUBE_SHADOW,
4825
+ import_constants20.GL.INT_SAMPLER_2D,
4826
+ import_constants20.GL.INT_SAMPLER_3D,
4827
+ import_constants20.GL.INT_SAMPLER_CUBE,
4828
+ import_constants20.GL.INT_SAMPLER_2D_ARRAY,
4829
+ import_constants20.GL.UNSIGNED_INT_SAMPLER_2D,
4830
+ import_constants20.GL.UNSIGNED_INT_SAMPLER_3D,
4831
+ import_constants20.GL.UNSIGNED_INT_SAMPLER_CUBE,
4832
+ import_constants20.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
4853
4833
  ];
4854
4834
  var COMPOSITE_GL_TYPES = {
4855
- [import_constants20.default.FLOAT]: [import_constants20.default.FLOAT, 1, "float", "f32", "float32"],
4856
- [import_constants20.default.FLOAT_VEC2]: [import_constants20.default.FLOAT, 2, "vec2", "vec2<f32>", "float32x2"],
4857
- [import_constants20.default.FLOAT_VEC3]: [import_constants20.default.FLOAT, 3, "vec3", "vec3<f32>", "float32x3"],
4858
- [import_constants20.default.FLOAT_VEC4]: [import_constants20.default.FLOAT, 4, "vec4", "vec4<f32>", "float32x4"],
4859
- [import_constants20.default.INT]: [import_constants20.default.INT, 1, "int", "i32", "sint32"],
4860
- [import_constants20.default.INT_VEC2]: [import_constants20.default.INT, 2, "ivec2", "vec2<i32>", "sint32x2"],
4861
- [import_constants20.default.INT_VEC3]: [import_constants20.default.INT, 3, "ivec3", "vec3<i32>", "sint32x3"],
4862
- [import_constants20.default.INT_VEC4]: [import_constants20.default.INT, 4, "ivec4", "vec4<i32>", "sint32x4"],
4863
- [import_constants20.default.UNSIGNED_INT]: [import_constants20.default.UNSIGNED_INT, 1, "uint", "u32", "uint32"],
4864
- [import_constants20.default.UNSIGNED_INT_VEC2]: [import_constants20.default.UNSIGNED_INT, 2, "uvec2", "vec2<u32>", "uint32x2"],
4865
- [import_constants20.default.UNSIGNED_INT_VEC3]: [import_constants20.default.UNSIGNED_INT, 3, "uvec3", "vec3<u32>", "uint32x3"],
4866
- [import_constants20.default.UNSIGNED_INT_VEC4]: [import_constants20.default.UNSIGNED_INT, 4, "uvec4", "vec4<u32>", "uint32x4"],
4867
- [import_constants20.default.BOOL]: [import_constants20.default.FLOAT, 1, "bool", "f32", "float32x2"],
4868
- [import_constants20.default.BOOL_VEC2]: [import_constants20.default.FLOAT, 2, "bvec2", "vec2<f32>"],
4869
- [import_constants20.default.BOOL_VEC3]: [import_constants20.default.FLOAT, 3, "bvec3", "vec3<f32>"],
4870
- [import_constants20.default.BOOL_VEC4]: [import_constants20.default.FLOAT, 4, "bvec4", "vec4<f32>"],
4871
- [import_constants20.default.FLOAT_MAT2]: [import_constants20.default.FLOAT, 8, "mat2", "mat2x2<f32>"],
4835
+ [import_constants20.GL.FLOAT]: [import_constants20.GL.FLOAT, 1, "float", "f32", "float32"],
4836
+ [import_constants20.GL.FLOAT_VEC2]: [import_constants20.GL.FLOAT, 2, "vec2", "vec2<f32>", "float32x2"],
4837
+ [import_constants20.GL.FLOAT_VEC3]: [import_constants20.GL.FLOAT, 3, "vec3", "vec3<f32>", "float32x3"],
4838
+ [import_constants20.GL.FLOAT_VEC4]: [import_constants20.GL.FLOAT, 4, "vec4", "vec4<f32>", "float32x4"],
4839
+ [import_constants20.GL.INT]: [import_constants20.GL.INT, 1, "int", "i32", "sint32"],
4840
+ [import_constants20.GL.INT_VEC2]: [import_constants20.GL.INT, 2, "ivec2", "vec2<i32>", "sint32x2"],
4841
+ [import_constants20.GL.INT_VEC3]: [import_constants20.GL.INT, 3, "ivec3", "vec3<i32>", "sint32x3"],
4842
+ [import_constants20.GL.INT_VEC4]: [import_constants20.GL.INT, 4, "ivec4", "vec4<i32>", "sint32x4"],
4843
+ [import_constants20.GL.UNSIGNED_INT]: [import_constants20.GL.UNSIGNED_INT, 1, "uint", "u32", "uint32"],
4844
+ [import_constants20.GL.UNSIGNED_INT_VEC2]: [import_constants20.GL.UNSIGNED_INT, 2, "uvec2", "vec2<u32>", "uint32x2"],
4845
+ [import_constants20.GL.UNSIGNED_INT_VEC3]: [import_constants20.GL.UNSIGNED_INT, 3, "uvec3", "vec3<u32>", "uint32x3"],
4846
+ [import_constants20.GL.UNSIGNED_INT_VEC4]: [import_constants20.GL.UNSIGNED_INT, 4, "uvec4", "vec4<u32>", "uint32x4"],
4847
+ [import_constants20.GL.BOOL]: [import_constants20.GL.FLOAT, 1, "bool", "f32", "float32x2"],
4848
+ [import_constants20.GL.BOOL_VEC2]: [import_constants20.GL.FLOAT, 2, "bvec2", "vec2<f32>"],
4849
+ [import_constants20.GL.BOOL_VEC3]: [import_constants20.GL.FLOAT, 3, "bvec3", "vec3<f32>"],
4850
+ [import_constants20.GL.BOOL_VEC4]: [import_constants20.GL.FLOAT, 4, "bvec4", "vec4<f32>"],
4851
+ [import_constants20.GL.FLOAT_MAT2]: [import_constants20.GL.FLOAT, 8, "mat2", "mat2x2<f32>"],
4872
4852
  // 4
4873
- [import_constants20.default.FLOAT_MAT2x3]: [import_constants20.default.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
4853
+ [import_constants20.GL.FLOAT_MAT2x3]: [import_constants20.GL.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
4874
4854
  // 6
4875
- [import_constants20.default.FLOAT_MAT2x4]: [import_constants20.default.FLOAT, 8, "mat2x4", "mat2x4<f32>"],
4855
+ [import_constants20.GL.FLOAT_MAT2x4]: [import_constants20.GL.FLOAT, 8, "mat2x4", "mat2x4<f32>"],
4876
4856
  // 8
4877
- [import_constants20.default.FLOAT_MAT3x2]: [import_constants20.default.FLOAT, 12, "mat3x2", "mat3x2<f32>"],
4857
+ [import_constants20.GL.FLOAT_MAT3x2]: [import_constants20.GL.FLOAT, 12, "mat3x2", "mat3x2<f32>"],
4878
4858
  // 6
4879
- [import_constants20.default.FLOAT_MAT3]: [import_constants20.default.FLOAT, 12, "mat3", "mat3x3<f32>"],
4859
+ [import_constants20.GL.FLOAT_MAT3]: [import_constants20.GL.FLOAT, 12, "mat3", "mat3x3<f32>"],
4880
4860
  // 9
4881
- [import_constants20.default.FLOAT_MAT3x4]: [import_constants20.default.FLOAT, 12, "mat3x4", "mat3x4<f32>"],
4861
+ [import_constants20.GL.FLOAT_MAT3x4]: [import_constants20.GL.FLOAT, 12, "mat3x4", "mat3x4<f32>"],
4882
4862
  // 12
4883
- [import_constants20.default.FLOAT_MAT4x2]: [import_constants20.default.FLOAT, 16, "mat4x2", "mat4x2<f32>"],
4863
+ [import_constants20.GL.FLOAT_MAT4x2]: [import_constants20.GL.FLOAT, 16, "mat4x2", "mat4x2<f32>"],
4884
4864
  // 8
4885
- [import_constants20.default.FLOAT_MAT4x3]: [import_constants20.default.FLOAT, 16, "mat4x3", "mat4x3<f32>"],
4865
+ [import_constants20.GL.FLOAT_MAT4x3]: [import_constants20.GL.FLOAT, 16, "mat4x3", "mat4x3<f32>"],
4886
4866
  // 12
4887
- [import_constants20.default.FLOAT_MAT4]: [import_constants20.default.FLOAT, 16, "mat4", "mat4x4<f32>"]
4867
+ [import_constants20.GL.FLOAT_MAT4]: [import_constants20.GL.FLOAT, 16, "mat4", "mat4x4<f32>"]
4888
4868
  // 16
4889
4869
  };
4890
4870
  function decodeUniformType(uniformType) {
@@ -5437,7 +5417,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
5437
5417
  draw(options) {
5438
5418
  var _a;
5439
5419
  const {
5440
- renderPass = this.device.getDefaultRenderPass(),
5420
+ renderPass,
5441
5421
  vertexCount,
5442
5422
  // indexCount,
5443
5423
  instanceCount,
@@ -5462,8 +5442,9 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
5462
5442
  }
5463
5443
  this._applyBindings();
5464
5444
  this._applyUniforms();
5445
+ const webglRenderPass = renderPass;
5465
5446
  withDeviceParameters(this.device, this.props.parameters, () => {
5466
- withGLParameters(this.device, { framebuffer: renderPass.props.framebuffer }, () => {
5447
+ withGLParameters(this.device, webglRenderPass.glParameters, () => {
5467
5448
  var _a2, _b;
5468
5449
  if (isIndexed && isInstanced) {
5469
5450
  (_a2 = this.device.gl2) == null ? void 0 : _a2.drawElementsInstanced(
@@ -5582,9 +5563,10 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
5582
5563
  }
5583
5564
  }
5584
5565
  _applyUniforms() {
5566
+ var _a;
5585
5567
  for (const uniformLayout of this.layout.uniforms || []) {
5586
5568
  const { name, location, type, textureUnit } = uniformLayout;
5587
- const value = this.uniforms[name] || textureUnit;
5569
+ const value = (_a = this.uniforms[name]) != null ? _a : textureUnit;
5588
5570
  if (value !== void 0) {
5589
5571
  setUniform(this.device.gl, location, type, value);
5590
5572
  }
@@ -5635,15 +5617,258 @@ function getAttributeLayout(layout, name) {
5635
5617
  return layout.attributes.find((binding) => binding.name === name) || null;
5636
5618
  }
5637
5619
 
5620
+ // src/adapter/resources/webgl-command-encoder.ts
5621
+ var import_api25 = require("@luma.gl/api");
5622
+
5623
+ // src/adapter/resources/webgl-command-buffer.ts
5624
+ var import_api24 = require("@luma.gl/api");
5625
+ var import_constants26 = __toESM(require("@luma.gl/constants"), 1);
5626
+ function cast3(value) {
5627
+ return value;
5628
+ }
5629
+ var WEBGLCommandBuffer = class extends import_api24.CommandBuffer {
5630
+ constructor(device) {
5631
+ super({});
5632
+ this.commands = [];
5633
+ this.device = device;
5634
+ }
5635
+ submitCommands(commands = this.commands) {
5636
+ for (const command of commands) {
5637
+ switch (command.name) {
5638
+ case "copy-buffer-to-buffer":
5639
+ _copyBufferToBuffer(this.device, command.options);
5640
+ break;
5641
+ case "copy-buffer-to-texture":
5642
+ _copyBufferToTexture(this.device, command.options);
5643
+ break;
5644
+ case "copy-texture-to-buffer":
5645
+ _copyTextureToBuffer(this.device, command.options);
5646
+ break;
5647
+ case "copy-texture-to-texture":
5648
+ _copyTextureToTexture(this.device, command.options);
5649
+ break;
5650
+ }
5651
+ }
5652
+ }
5653
+ };
5654
+ function _copyBufferToBuffer(device, options) {
5655
+ var _a, _b;
5656
+ const source = cast3(options.source);
5657
+ const destination = cast3(options.destination);
5658
+ const gl2 = device.assertWebGL2();
5659
+ if (gl2) {
5660
+ gl2.bindBuffer(import_constants26.default.COPY_READ_BUFFER, source.handle);
5661
+ gl2.bindBuffer(import_constants26.default.COPY_WRITE_BUFFER, destination.handle);
5662
+ gl2.copyBufferSubData(
5663
+ import_constants26.default.COPY_READ_BUFFER,
5664
+ import_constants26.default.COPY_WRITE_BUFFER,
5665
+ (_a = options.sourceOffset) != null ? _a : 0,
5666
+ (_b = options.destinationOffset) != null ? _b : 0,
5667
+ options.size
5668
+ );
5669
+ gl2.bindBuffer(import_constants26.default.COPY_READ_BUFFER, null);
5670
+ gl2.bindBuffer(import_constants26.default.COPY_WRITE_BUFFER, null);
5671
+ } else {
5672
+ throw new Error("copyBufferToBuffer not implemented in WebGL1");
5673
+ }
5674
+ }
5675
+ function _copyBufferToTexture(device, options) {
5676
+ throw new Error("Not implemented");
5677
+ }
5678
+ function _copyTextureToBuffer(device, options) {
5679
+ const {
5680
+ /** Texture to copy to/from. */
5681
+ source,
5682
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
5683
+ mipLevel = 0,
5684
+ /** Defines which aspects of the texture to copy to/from. */
5685
+ aspect = "all",
5686
+ /** Width to copy */
5687
+ width = options.source.width,
5688
+ /** Height to copy */
5689
+ height = options.source.height,
5690
+ depthOrArrayLayers = 0,
5691
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
5692
+ origin = [0, 0],
5693
+ /** Destination buffer */
5694
+ destination,
5695
+ /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
5696
+ byteOffset = 0,
5697
+ /**
5698
+ * The stride, in bytes, between the beginning of each block row and the subsequent block row.
5699
+ * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
5700
+ */
5701
+ bytesPerRow,
5702
+ /**
5703
+ * Number of block rows per single image of the texture.
5704
+ * rowsPerImage &times; bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
5705
+ * Required if there are multiple images (i.e. the copy depth is more than one).
5706
+ */
5707
+ rowsPerImage
5708
+ } = options;
5709
+ if (aspect !== "all") {
5710
+ throw new Error("not supported");
5711
+ }
5712
+ if (mipLevel !== 0 || depthOrArrayLayers !== void 0 || bytesPerRow || rowsPerImage) {
5713
+ throw new Error("not implemented");
5714
+ }
5715
+ const gl2 = device.assertWebGL2();
5716
+ const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
5717
+ try {
5718
+ const webglBuffer = destination;
5719
+ const sourceWidth = width || framebuffer.width;
5720
+ const sourceHeight = height || framebuffer.height;
5721
+ const sourceFormat = import_constants26.default.RGBA;
5722
+ const sourceType = import_constants26.default.UNSIGNED_BYTE;
5723
+ gl2.bindBuffer(import_constants26.default.PIXEL_PACK_BUFFER, webglBuffer.handle);
5724
+ gl2.bindFramebuffer(import_constants26.default.FRAMEBUFFER, framebuffer.handle);
5725
+ gl2.readPixels(
5726
+ origin[0],
5727
+ origin[1],
5728
+ sourceWidth,
5729
+ sourceHeight,
5730
+ sourceFormat,
5731
+ sourceType,
5732
+ byteOffset
5733
+ );
5734
+ } finally {
5735
+ gl2.bindBuffer(import_constants26.default.PIXEL_PACK_BUFFER, null);
5736
+ gl2.bindFramebuffer(import_constants26.default.FRAMEBUFFER, null);
5737
+ if (destroyFramebuffer) {
5738
+ framebuffer.destroy();
5739
+ }
5740
+ }
5741
+ }
5742
+ function _copyTextureToTexture(device, options) {
5743
+ const {
5744
+ /** Texture to copy to/from. */
5745
+ source,
5746
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
5747
+ // mipLevel = 0,
5748
+ /** Defines which aspects of the texture to copy to/from. */
5749
+ // aspect = 'all',
5750
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
5751
+ origin = [0, 0],
5752
+ /** Texture to copy to/from. */
5753
+ destination
5754
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
5755
+ // destinationMipLevel = options.mipLevel,
5756
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
5757
+ // destinationOrigin = [0, 0],
5758
+ /** Defines which aspects of the texture to copy to/from. */
5759
+ // destinationAspect = options.aspect,
5760
+ } = options;
5761
+ let {
5762
+ width = options.destination.width,
5763
+ height = options.destination.width
5764
+ // depthOrArrayLayers = 0
5765
+ } = options;
5766
+ const destinationMipmaplevel = 0;
5767
+ const destinationInternalFormat = import_constants26.default.RGBA;
5768
+ const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
5769
+ const [sourceX, sourceY] = origin;
5770
+ const isSubCopy = false;
5771
+ device.gl.bindFramebuffer(import_constants26.default.FRAMEBUFFER, framebuffer.handle);
5772
+ let texture = null;
5773
+ let textureTarget;
5774
+ if (destination instanceof WEBGLTexture) {
5775
+ texture = destination;
5776
+ width = Number.isFinite(width) ? width : texture.width;
5777
+ height = Number.isFinite(height) ? height : texture.height;
5778
+ texture.bind(0);
5779
+ textureTarget = texture.destination;
5780
+ } else {
5781
+ throw new Error("whoops");
5782
+ }
5783
+ if (!isSubCopy) {
5784
+ device.gl.copyTexImage2D(
5785
+ textureTarget,
5786
+ destinationMipmaplevel,
5787
+ destinationInternalFormat,
5788
+ sourceX,
5789
+ sourceY,
5790
+ width,
5791
+ height,
5792
+ 0
5793
+ /* border must be 0 */
5794
+ );
5795
+ } else {
5796
+ }
5797
+ if (texture) {
5798
+ texture.unbind();
5799
+ }
5800
+ device.gl.bindFramebuffer(import_constants26.default.FRAMEBUFFER, prevHandle || null);
5801
+ if (destroyFramebuffer) {
5802
+ framebuffer.destroy();
5803
+ }
5804
+ return texture;
5805
+ }
5806
+ function getFramebuffer(source) {
5807
+ if (source instanceof import_api24.Texture) {
5808
+ const { width, height, id } = source;
5809
+ const framebuffer = source.device.createFramebuffer({
5810
+ id: `framebuffer-for-${id}`,
5811
+ width,
5812
+ height,
5813
+ colorAttachments: [source]
5814
+ });
5815
+ return { framebuffer, destroyFramebuffer: true };
5816
+ }
5817
+ return { framebuffer: source, destroyFramebuffer: false };
5818
+ }
5819
+
5820
+ // src/adapter/resources/webgl-command-encoder.ts
5821
+ var WEBGLCommandEncoder = class extends import_api25.CommandEncoder {
5822
+ constructor(device, props) {
5823
+ super(props);
5824
+ this.device = device;
5825
+ this.commandBuffer = new WEBGLCommandBuffer(device);
5826
+ }
5827
+ destroy() {
5828
+ }
5829
+ finish() {
5830
+ this.commandBuffer.submitCommands();
5831
+ }
5832
+ // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
5833
+ // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
5834
+ // finish(options?: {id?: string}): GPUCommandBuffer;
5835
+ copyBufferToBuffer(options) {
5836
+ this.commandBuffer.commands.push({ name: "copy-buffer-to-buffer", options });
5837
+ }
5838
+ copyBufferToTexture(options) {
5839
+ this.commandBuffer.commands.push({ name: "copy-buffer-to-texture", options });
5840
+ }
5841
+ copyTextureToBuffer(options) {
5842
+ this.commandBuffer.commands.push({ name: "copy-texture-to-buffer", options });
5843
+ }
5844
+ copyTextureToTexture(options) {
5845
+ this.commandBuffer.commands.push({ name: "copy-texture-to-texture", options });
5846
+ }
5847
+ pushDebugGroup(groupLabel) {
5848
+ }
5849
+ popDebugGroup() {
5850
+ }
5851
+ insertDebugMarker(markerLabel) {
5852
+ }
5853
+ // writeTimestamp(querySet: Query, queryIndex: number): void {}
5854
+ // resolveQuerySet(options: {
5855
+ // querySet: GPUQuerySet,
5856
+ // firstQuery: number,
5857
+ // queryCount: number,
5858
+ // destination: Buffer,
5859
+ // destinationOffset?: number;
5860
+ // }): void;
5861
+ };
5862
+
5638
5863
  // src/adapter/webgl-device.ts
5639
5864
  var LOG_LEVEL2 = 1;
5640
- var _WebGLDevice = class extends import_api24.Device {
5865
+ var _WebGLDevice = class extends import_api26.Device {
5641
5866
  //
5642
5867
  // Public API
5643
5868
  //
5644
5869
  constructor(props) {
5645
5870
  var _a;
5646
- super(__spreadProps(__spreadValues({}, props), { id: props.id || (0, import_api24.uid)("webgl-device") }));
5871
+ super(__spreadProps(__spreadValues({}, props), { id: props.id || (0, import_api26.uid)("webgl-device") }));
5647
5872
  this.renderPass = null;
5648
5873
  /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
5649
5874
  this.gl2 = null;
@@ -5687,22 +5912,22 @@ var _WebGLDevice = class extends import_api24.Device {
5687
5912
  trackContextState(this.gl, {
5688
5913
  enable: enable2,
5689
5914
  copyState,
5690
- log: (...args) => import_api24.log.log(1, ...args)()
5915
+ log: (...args) => import_api26.log.log(1, ...args)()
5691
5916
  });
5692
5917
  if ((0, import_env2.isBrowser)() && props.debug) {
5693
5918
  this.gl = makeDebugContext(this.gl, __spreadProps(__spreadValues({}, props), { webgl2: this.isWebGL2, throwOnError: true }));
5694
5919
  this.gl2 = this.gl;
5695
5920
  this.debug = true;
5696
- import_api24.log.level = Math.max(import_api24.log.level, 1);
5697
- import_api24.log.warn("WebGL debug mode activated. Performance reduced.")();
5921
+ import_api26.log.level = Math.max(import_api26.log.level, 1);
5922
+ import_api26.log.warn("WebGL debug mode activated. Performance reduced.")();
5698
5923
  }
5699
5924
  if ((0, import_env2.isBrowser)() && props.spector) {
5700
5925
  const canvas = this.handle.canvas || props.canvas;
5701
5926
  this.spector = initializeSpectorJS(__spreadProps(__spreadValues({}, this.props), { canvas }));
5702
5927
  }
5703
5928
  const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
5704
- import_api24.log.probe(LOG_LEVEL2, message2)();
5705
- import_api24.log.groupEnd(LOG_LEVEL2)();
5929
+ import_api26.log.probe(LOG_LEVEL2, message2)();
5930
+ import_api26.log.groupEnd(LOG_LEVEL2)();
5706
5931
  }
5707
5932
  static isSupported() {
5708
5933
  return typeof WebGLRenderingContext !== "undefined" || isHeadlessGLRegistered();
@@ -5728,7 +5953,7 @@ var _WebGLDevice = class extends import_api24.Device {
5728
5953
  if (gl instanceof _WebGLDevice) {
5729
5954
  return gl;
5730
5955
  }
5731
- if ((gl == null ? void 0 : gl.device) instanceof import_api24.Device) {
5956
+ if ((gl == null ? void 0 : gl.device) instanceof import_api26.Device) {
5732
5957
  return gl.device;
5733
5958
  }
5734
5959
  if (!isWebGL3(gl)) {
@@ -5738,9 +5963,9 @@ var _WebGLDevice = class extends import_api24.Device {
5738
5963
  }
5739
5964
  static create() {
5740
5965
  return __async(this, arguments, function* (props = {}) {
5741
- import_api24.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
5966
+ import_api26.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
5742
5967
  if (typeof props.canvas === "string") {
5743
- yield import_api24.CanvasContext.pageLoaded;
5968
+ yield import_api26.CanvasContext.pageLoaded;
5744
5969
  }
5745
5970
  if (props.debug) {
5746
5971
  yield loadWebGLDeveloperTools();
@@ -5748,7 +5973,7 @@ var _WebGLDevice = class extends import_api24.Device {
5748
5973
  if (props.spector) {
5749
5974
  yield loadSpectorJS();
5750
5975
  }
5751
- import_api24.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
5976
+ import_api26.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
5752
5977
  if (props.gl && props.gl.device) {
5753
5978
  return _WebGLDevice.attach(props.gl);
5754
5979
  }
@@ -5792,8 +6017,9 @@ var _WebGLDevice = class extends import_api24.Device {
5792
6017
  createCanvasContext(props) {
5793
6018
  throw new Error("WebGL only supports a single canvas");
5794
6019
  }
5795
- _createBuffer(props) {
5796
- return new ClassicBuffer(this, props);
6020
+ createBuffer(props) {
6021
+ const newProps = this._getBufferProps(props);
6022
+ return new ClassicBuffer(this, newProps);
5797
6023
  }
5798
6024
  _createTexture(props) {
5799
6025
  return new WEBGLTexture(this, props);
@@ -5828,6 +6054,9 @@ var _WebGLDevice = class extends import_api24.Device {
5828
6054
  });
5829
6055
  return this.renderPass;
5830
6056
  }
6057
+ createCommandEncoder(props) {
6058
+ return new WEBGLCommandEncoder(this, props);
6059
+ }
5831
6060
  /**
5832
6061
  * Offscreen Canvas Support: Commit the frame
5833
6062
  * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit
@@ -5844,20 +6073,22 @@ var _WebGLDevice = class extends import_api24.Device {
5844
6073
  return this._webglLimits;
5845
6074
  }
5846
6075
  /**
5847
- * Loses the context
5848
- * @note Triggers context loss, mainly for testing
5849
- * @todo Promote to `Device` API?
6076
+ * Triggers device (or WebGL context) loss.
6077
+ * @note primarily intended for testing how application reacts to device loss
5850
6078
  */
5851
6079
  loseDevice() {
5852
6080
  var _a;
6081
+ let deviceLossTriggered = false;
5853
6082
  const ext = this.gl.getExtension("WEBGL_lose_context");
5854
6083
  if (ext) {
6084
+ deviceLossTriggered = true;
5855
6085
  ext.loseContext();
5856
6086
  }
5857
6087
  (_a = this._resolveContextLost) == null ? void 0 : _a.call(this, {
5858
6088
  reason: "destroyed",
5859
6089
  message: "Application triggered context loss"
5860
6090
  });
6091
+ return deviceLossTriggered;
5861
6092
  }
5862
6093
  /** Save current WebGL context state onto an internal stack */
5863
6094
  pushState() {
@@ -5874,6 +6105,21 @@ var _WebGLDevice = class extends import_api24.Device {
5874
6105
  setSpectorMetadata(handle, props) {
5875
6106
  handle.__SPECTOR_Metadata = props;
5876
6107
  }
6108
+ /**
6109
+ * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
6110
+ * Be aware that there are some duplicates especially for constants that are 0,
6111
+ * so this isn't guaranteed to return the right key in all cases.
6112
+ */
6113
+ getGLKey(value, gl) {
6114
+ gl = gl || this.gl2 || this.gl;
6115
+ const number = Number(value);
6116
+ for (const key in gl) {
6117
+ if (gl[key] === number) {
6118
+ return `GL.${key}`;
6119
+ }
6120
+ }
6121
+ return String(value);
6122
+ }
5877
6123
  };
5878
6124
  var WebGLDevice = _WebGLDevice;
5879
6125
  //
@@ -5896,53 +6142,179 @@ function isWebGL22(gl) {
5896
6142
  return Boolean(gl && gl._version === 2);
5897
6143
  }
5898
6144
 
5899
- // src/adapter/resources/webgl-command-encoder.ts
5900
- var import_api25 = require("@luma.gl/api");
6145
+ // src/classic/clear.ts
6146
+ var import_api27 = require("@luma.gl/api");
6147
+ var GL_DEPTH_BUFFER_BIT2 = 256;
6148
+ var GL_STENCIL_BUFFER_BIT2 = 1024;
6149
+ var GL_COLOR_BUFFER_BIT2 = 16384;
6150
+ var ERR_ARGUMENTS = "clear: bad arguments";
6151
+ function clear(gl, options) {
6152
+ const device = WebGLDevice.attach(gl);
6153
+ const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
6154
+ const parameters = {};
6155
+ if (framebuffer) {
6156
+ parameters.framebuffer = framebuffer;
6157
+ }
6158
+ let clearFlags = 0;
6159
+ if (color) {
6160
+ clearFlags |= GL_COLOR_BUFFER_BIT2;
6161
+ if (color !== true) {
6162
+ parameters.clearColor = color;
6163
+ }
6164
+ }
6165
+ if (depth) {
6166
+ clearFlags |= GL_DEPTH_BUFFER_BIT2;
6167
+ if (depth !== true) {
6168
+ parameters.clearDepth = depth;
6169
+ }
6170
+ }
6171
+ if (stencil) {
6172
+ clearFlags |= GL_STENCIL_BUFFER_BIT2;
6173
+ if (depth !== true) {
6174
+ parameters.clearStencil = depth;
6175
+ }
6176
+ }
6177
+ (0, import_api27.assert)(clearFlags !== 0, ERR_ARGUMENTS);
6178
+ withParameters(device.gl, parameters, () => {
6179
+ device.gl.clear(clearFlags);
6180
+ });
6181
+ }
5901
6182
 
5902
- // src/adapter/resources/webgl-command-buffer.ts
5903
- var import_constants26 = __toESM(require("@luma.gl/constants"), 1);
5904
- var CommandBuffer = class {
5905
- constructor() {
5906
- this.commands = [];
5907
- }
5908
- };
6183
+ // src/classic/copy-and-blit.ts
6184
+ var import_api29 = require("@luma.gl/api");
6185
+ var import_constants28 = __toESM(require("@luma.gl/constants"), 1);
5909
6186
 
5910
- // src/adapter/resources/webgl-command-encoder.ts
5911
- var WEBGLCommandEncoder = class extends import_api25.CommandEncoder {
5912
- constructor(device, props) {
5913
- super(props);
5914
- this.commandBuffer = new CommandBuffer();
5915
- this.device = device;
5916
- }
5917
- destroy() {
5918
- }
5919
- // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
5920
- // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
5921
- // finish(options?: {id?: string}): GPUCommandBuffer;
5922
- copyBufferToBuffer(options) {
5923
- this.commandBuffer.commands.push({ name: "copy-buffer-to-buffer", options });
5924
- }
5925
- copyBufferToTexture(options) {
5926
- this.commandBuffer.commands.push({ name: "copy-buffer-to-texture", options });
5927
- }
5928
- copyTextureToBuffer(options) {
5929
- this.commandBuffer.commands.push({ name: "copy-texture-to-buffer", options });
5930
- }
5931
- copyTextureToTexture(options) {
5932
- this.commandBuffer.commands.push({ name: "copy-texture-to-texture", options });
6187
+ // src/classic/format-utils.ts
6188
+ var import_api28 = require("@luma.gl/api");
6189
+ var import_constants27 = __toESM(require("@luma.gl/constants"), 1);
6190
+ function glFormatToComponents(format) {
6191
+ switch (format) {
6192
+ case import_constants27.default.ALPHA:
6193
+ case import_constants27.default.R32F:
6194
+ case import_constants27.default.RED:
6195
+ return 1;
6196
+ case import_constants27.default.RG32F:
6197
+ case import_constants27.default.RG:
6198
+ return 2;
6199
+ case import_constants27.default.RGB:
6200
+ case import_constants27.default.RGB32F:
6201
+ return 3;
6202
+ case import_constants27.default.RGBA:
6203
+ case import_constants27.default.RGBA32F:
6204
+ return 4;
6205
+ default:
6206
+ (0, import_api28.assert)(false);
6207
+ return 0;
5933
6208
  }
5934
- pushDebugGroup(groupLabel) {
6209
+ }
6210
+ function glTypeToBytes(type) {
6211
+ switch (type) {
6212
+ case import_constants27.default.UNSIGNED_BYTE:
6213
+ return 1;
6214
+ case import_constants27.default.UNSIGNED_SHORT_5_6_5:
6215
+ case import_constants27.default.UNSIGNED_SHORT_4_4_4_4:
6216
+ case import_constants27.default.UNSIGNED_SHORT_5_5_5_1:
6217
+ return 2;
6218
+ case import_constants27.default.FLOAT:
6219
+ return 4;
6220
+ default:
6221
+ (0, import_api28.assert)(false);
6222
+ return 0;
5935
6223
  }
5936
- popDebugGroup() {
6224
+ }
6225
+
6226
+ // src/classic/copy-and-blit.ts
6227
+ function readPixelsToArray(source, options) {
6228
+ const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.default.RGBA } = options || {};
6229
+ let {
6230
+ sourceAttachment = import_constants28.default.COLOR_ATTACHMENT0,
6231
+ // TODO - support gl.readBuffer
6232
+ target = null,
6233
+ // following parameters are auto deduced if not provided
6234
+ sourceWidth,
6235
+ sourceHeight,
6236
+ sourceType
6237
+ } = options || {};
6238
+ const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
6239
+ (0, import_api29.assert)(framebuffer);
6240
+ const { gl, handle } = framebuffer;
6241
+ sourceWidth = sourceWidth || framebuffer.width;
6242
+ sourceHeight = sourceHeight || framebuffer.height;
6243
+ if (sourceAttachment === import_constants28.default.COLOR_ATTACHMENT0 && handle === null) {
6244
+ sourceAttachment = import_constants28.default.FRONT;
6245
+ }
6246
+ const attachment = sourceAttachment - import_constants28.default.COLOR_ATTACHMENT0;
6247
+ sourceType = sourceType || framebuffer.colorAttachments[attachment].type;
6248
+ target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
6249
+ sourceType = sourceType || getGLTypeFromTypedArray(target);
6250
+ const prevHandle2 = gl.bindFramebuffer(import_constants28.default.FRAMEBUFFER, handle);
6251
+ gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
6252
+ gl.bindFramebuffer(import_constants28.default.FRAMEBUFFER, prevHandle2 || null);
6253
+ if (deleteFramebuffer) {
6254
+ framebuffer.destroy();
6255
+ }
6256
+ return target;
6257
+ }
6258
+ function readPixelsToBuffer(source, options) {
6259
+ const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.default.RGBA, targetByteOffset = 0 } = options || {};
6260
+ let { target, sourceWidth, sourceHeight, sourceType } = options || {};
6261
+ const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
6262
+ (0, import_api29.assert)(framebuffer);
6263
+ sourceWidth = sourceWidth || framebuffer.width;
6264
+ sourceHeight = sourceHeight || framebuffer.height;
6265
+ const webglFramebuffer = framebuffer;
6266
+ const gl2 = webglFramebuffer.device.assertWebGL2();
6267
+ sourceType = sourceType || (target ? target.type : import_constants28.default.UNSIGNED_BYTE);
6268
+ if (!target) {
6269
+ const components = glFormatToComponents(sourceFormat);
6270
+ const byteCount = glTypeToBytes(sourceType);
6271
+ const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
6272
+ target = new ClassicBuffer(gl2, { byteLength, accessor: { type: sourceType, size: components } });
6273
+ }
6274
+ target.bind({ target: import_constants28.default.PIXEL_PACK_BUFFER });
6275
+ withParameters(gl2, { framebuffer }, () => {
6276
+ gl2.readPixels(
6277
+ sourceX,
6278
+ sourceY,
6279
+ sourceWidth,
6280
+ sourceHeight,
6281
+ sourceFormat,
6282
+ sourceType,
6283
+ targetByteOffset
6284
+ );
6285
+ });
6286
+ target.unbind({ target: import_constants28.default.PIXEL_PACK_BUFFER });
6287
+ if (deleteFramebuffer) {
6288
+ framebuffer.destroy();
5937
6289
  }
5938
- insertDebugMarker(markerLabel) {
6290
+ return target;
6291
+ }
6292
+ function getFramebuffer2(source) {
6293
+ if (!(source instanceof import_api29.Framebuffer)) {
6294
+ return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
5939
6295
  }
5940
- // writeTimestamp(querySet: Query, queryIndex: number): void {}
5941
- // resolveQuerySet(options: {
5942
- // querySet: GPUQuerySet,
5943
- // firstQuery: number,
5944
- // queryCount: number,
5945
- // destination: Buffer,
5946
- // destinationOffset?: number;
5947
- // }): void;
5948
- };
6296
+ return { framebuffer: source, deleteFramebuffer: false };
6297
+ }
6298
+ function toFramebuffer(texture, props) {
6299
+ const { device, width, height, id } = texture;
6300
+ const framebuffer = device.createFramebuffer(
6301
+ __spreadProps(__spreadValues({}, props), {
6302
+ id: `framebuffer-for-${id}`,
6303
+ width,
6304
+ height,
6305
+ colorAttachments: [
6306
+ texture
6307
+ ]
6308
+ })
6309
+ );
6310
+ return framebuffer;
6311
+ }
6312
+ function getPixelArray(pixelArray, type, format, width, height) {
6313
+ if (pixelArray) {
6314
+ return pixelArray;
6315
+ }
6316
+ type = type || import_constants28.default.UNSIGNED_BYTE;
6317
+ const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
6318
+ const components = glFormatToComponents(format);
6319
+ return new ArrayType(width * height * components);
6320
+ }