@gjsify/webgl 0.3.16 → 0.3.18

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 (55) hide show
  1. package/lib/esm/conformance/attribs.spec.js +3 -315
  2. package/lib/esm/conformance/buffers.spec.js +1 -220
  3. package/lib/esm/conformance/context.spec.js +3 -302
  4. package/lib/esm/conformance/programs.spec.js +3 -477
  5. package/lib/esm/conformance/rendering-basic.spec.js +3 -141
  6. package/lib/esm/conformance/rendering.spec.js +7 -514
  7. package/lib/esm/conformance/setup.js +1 -47
  8. package/lib/esm/conformance/state.spec.js +1 -365
  9. package/lib/esm/conformance/textures.spec.js +3 -337
  10. package/lib/esm/conformance/uniforms.spec.js +1 -484
  11. package/lib/esm/conformance-test.js +1 -25
  12. package/lib/esm/extensions/ext-blend-minmax.js +1 -18
  13. package/lib/esm/extensions/ext-color-buffer-float.js +1 -12
  14. package/lib/esm/extensions/ext-color-buffer-half-float.js +1 -12
  15. package/lib/esm/extensions/ext-texture-filter-anisotropic.js +1 -18
  16. package/lib/esm/extensions/oes-element-index-unit.js +1 -13
  17. package/lib/esm/extensions/oes-standard-derivatives.js +1 -17
  18. package/lib/esm/extensions/oes-texture-float-linear.js +1 -13
  19. package/lib/esm/extensions/oes-texture-float.js +1 -13
  20. package/lib/esm/extensions/oes-texture-half-float.js +1 -19
  21. package/lib/esm/extensions/stackgl-destroy-context.js +1 -12
  22. package/lib/esm/extensions/stackgl-resize-drawing-buffer.js +1 -12
  23. package/lib/esm/html-canvas-element.js +1 -65
  24. package/lib/esm/index.js +1 -33
  25. package/lib/esm/linkable.js +1 -50
  26. package/lib/esm/test-utils.js +4 -186
  27. package/lib/esm/test.js +1 -11
  28. package/lib/esm/types/index.js +1 -5
  29. package/lib/esm/utils.js +1 -201
  30. package/lib/esm/webgl-active-info.js +1 -11
  31. package/lib/esm/webgl-bridge.js +1 -167
  32. package/lib/esm/webgl-buffer.js +1 -19
  33. package/lib/esm/webgl-context-attributes.js +1 -24
  34. package/lib/esm/webgl-context-base.js +8 -3069
  35. package/lib/esm/webgl-drawing-buffer-wrapper.js +1 -11
  36. package/lib/esm/webgl-framebuffer.js +1 -110
  37. package/lib/esm/webgl-program.js +1 -27
  38. package/lib/esm/webgl-query.js +1 -17
  39. package/lib/esm/webgl-renderbuffer.js +1 -25
  40. package/lib/esm/webgl-rendering-context.js +1 -175
  41. package/lib/esm/webgl-sampler.js +1 -17
  42. package/lib/esm/webgl-shader-precision-format.js +1 -11
  43. package/lib/esm/webgl-shader.js +1 -25
  44. package/lib/esm/webgl-sync.js +1 -17
  45. package/lib/esm/webgl-texture-unit.js +1 -13
  46. package/lib/esm/webgl-texture.js +1 -23
  47. package/lib/esm/webgl-transform-feedback.js +1 -17
  48. package/lib/esm/webgl-uniform-location.js +1 -15
  49. package/lib/esm/webgl-vertex-array-object.js +1 -23
  50. package/lib/esm/webgl-vertex-attribute.js +1 -151
  51. package/lib/esm/webgl1.spec.js +10 -1044
  52. package/lib/esm/webgl2-rendering-context.js +1 -1218
  53. package/lib/esm/webgl2.spec.js +45 -1288
  54. package/lib/types/webgl-bridge.d.ts +9 -9
  55. package/package.json +9 -9
@@ -1,11 +1 @@
1
- //#region src/ts/webgl-drawing-buffer-wrapper.ts
2
- var WebGLDrawingBufferWrapper = class {
3
- constructor(framebuffer, color, depthStencil) {
4
- this._framebuffer = framebuffer;
5
- this._color = color;
6
- this._depthStencil = depthStencil;
7
- }
8
- };
9
-
10
- //#endregion
11
- export { WebGLDrawingBufferWrapper };
1
+ var e=class{constructor(e,t,n){this._framebuffer=e,this._color=t,this._depthStencil=n}};export{e as WebGLDrawingBufferWrapper};
@@ -1,110 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-framebuffer.ts
4
- var WebGLFramebuffer = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._binding = 0;
8
- this._width = 0;
9
- this._height = 0;
10
- this._status = null;
11
- this._ctx = ctx;
12
- this._attachments = {};
13
- this._attachments[ctx.COLOR_ATTACHMENT0] = null;
14
- this._attachments[ctx.DEPTH_ATTACHMENT] = null;
15
- this._attachments[ctx.STENCIL_ATTACHMENT] = null;
16
- this._attachments[ctx.DEPTH_STENCIL_ATTACHMENT] = null;
17
- this._attachmentLevel = {};
18
- this._attachmentLevel[ctx.COLOR_ATTACHMENT0] = 0;
19
- this._attachmentLevel[ctx.DEPTH_ATTACHMENT] = 0;
20
- this._attachmentLevel[ctx.STENCIL_ATTACHMENT] = 0;
21
- this._attachmentLevel[ctx.DEPTH_STENCIL_ATTACHMENT] = 0;
22
- this._attachmentFace = {};
23
- this._attachmentFace[ctx.COLOR_ATTACHMENT0] = 0;
24
- this._attachmentFace[ctx.DEPTH_ATTACHMENT] = 0;
25
- this._attachmentFace[ctx.STENCIL_ATTACHMENT] = 0;
26
- this._attachmentFace[ctx.DEPTH_STENCIL_ATTACHMENT] = 0;
27
- if (ctx._extensions.webgl_draw_buffers) {
28
- const webGLDrawBuffers = ctx._extensions.webgl_draw_buffers;
29
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT1_WEBGL] = null;
30
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT2_WEBGL] = null;
31
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT3_WEBGL] = null;
32
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT4_WEBGL] = null;
33
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT5_WEBGL] = null;
34
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT6_WEBGL] = null;
35
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT7_WEBGL] = null;
36
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT8_WEBGL] = null;
37
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT9_WEBGL] = null;
38
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT10_WEBGL] = null;
39
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT11_WEBGL] = null;
40
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT12_WEBGL] = null;
41
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT13_WEBGL] = null;
42
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT14_WEBGL] = null;
43
- this._attachments[webGLDrawBuffers.COLOR_ATTACHMENT15_WEBGL] = null;
44
- this._attachments[ctx.NONE] = null;
45
- this._attachments[ctx.BACK] = null;
46
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT1_WEBGL] = 0;
47
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT2_WEBGL] = 0;
48
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT3_WEBGL] = 0;
49
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT4_WEBGL] = 0;
50
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT5_WEBGL] = 0;
51
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT6_WEBGL] = 0;
52
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT7_WEBGL] = 0;
53
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT8_WEBGL] = 0;
54
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT9_WEBGL] = 0;
55
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT10_WEBGL] = 0;
56
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT11_WEBGL] = 0;
57
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT12_WEBGL] = 0;
58
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT13_WEBGL] = 0;
59
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT14_WEBGL] = 0;
60
- this._attachmentLevel[webGLDrawBuffers.COLOR_ATTACHMENT15_WEBGL] = 0;
61
- this._attachmentLevel[ctx.NONE] = null;
62
- this._attachmentLevel[ctx.BACK] = null;
63
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT1_WEBGL] = 0;
64
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT2_WEBGL] = 0;
65
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT3_WEBGL] = 0;
66
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT4_WEBGL] = 0;
67
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT5_WEBGL] = 0;
68
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT6_WEBGL] = 0;
69
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT7_WEBGL] = 0;
70
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT8_WEBGL] = 0;
71
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT9_WEBGL] = 0;
72
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT10_WEBGL] = 0;
73
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT11_WEBGL] = 0;
74
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT12_WEBGL] = 0;
75
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT13_WEBGL] = 0;
76
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT14_WEBGL] = 0;
77
- this._attachmentFace[webGLDrawBuffers.COLOR_ATTACHMENT15_WEBGL] = 0;
78
- this._attachmentFace[ctx.NONE] = null;
79
- this._attachmentFace[ctx.BACK] = null;
80
- }
81
- }
82
- _clearAttachment(attachment) {
83
- const object = this._attachments[attachment];
84
- if (!object) {
85
- return;
86
- }
87
- this._attachments[attachment] = null;
88
- this._unlink(object);
89
- }
90
- _setAttachment(object, attachment) {
91
- const prevObject = this._attachments[attachment];
92
- if (prevObject === object) {
93
- return;
94
- }
95
- this._clearAttachment(attachment);
96
- if (!object) {
97
- return;
98
- }
99
- this._attachments[attachment] = object;
100
- this._link(object);
101
- }
102
- _performDelete() {
103
- const ctx = this._ctx;
104
- delete ctx._framebuffers[this._ | 0];
105
- ctx._gl.deleteFramebuffer(this._ | 0);
106
- }
107
- };
108
-
109
- //#endregion
110
- export { WebGLFramebuffer };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){if(super(e),this._binding=0,this._width=0,this._height=0,this._status=null,this._ctx=t,this._attachments={},this._attachments[t.COLOR_ATTACHMENT0]=null,this._attachments[t.DEPTH_ATTACHMENT]=null,this._attachments[t.STENCIL_ATTACHMENT]=null,this._attachments[t.DEPTH_STENCIL_ATTACHMENT]=null,this._attachmentLevel={},this._attachmentLevel[t.COLOR_ATTACHMENT0]=0,this._attachmentLevel[t.DEPTH_ATTACHMENT]=0,this._attachmentLevel[t.STENCIL_ATTACHMENT]=0,this._attachmentLevel[t.DEPTH_STENCIL_ATTACHMENT]=0,this._attachmentFace={},this._attachmentFace[t.COLOR_ATTACHMENT0]=0,this._attachmentFace[t.DEPTH_ATTACHMENT]=0,this._attachmentFace[t.STENCIL_ATTACHMENT]=0,this._attachmentFace[t.DEPTH_STENCIL_ATTACHMENT]=0,t._extensions.webgl_draw_buffers){let e=t._extensions.webgl_draw_buffers;this._attachments[e.COLOR_ATTACHMENT1_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT2_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT3_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT4_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT5_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT6_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT7_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT8_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT9_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT10_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT11_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT12_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT13_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT14_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT15_WEBGL]=null,this._attachments[t.NONE]=null,this._attachments[t.BACK]=null,this._attachmentLevel[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentLevel[t.NONE]=null,this._attachmentLevel[t.BACK]=null,this._attachmentFace[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentFace[t.NONE]=null,this._attachmentFace[t.BACK]=null}}_clearAttachment(e){let t=this._attachments[e];t&&(this._attachments[e]=null,this._unlink(t))}_setAttachment(e,t){this._attachments[t]!==e&&(this._clearAttachment(t),e&&(this._attachments[t]=e,this._link(e)))}_performDelete(){let e=this._ctx;delete e._framebuffers[this._|0],e._gl.deleteFramebuffer(this._|0)}};export{t as WebGLFramebuffer};
@@ -1,27 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-program.ts
4
- var WebGLProgram = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._linkCount = 0;
8
- this._linkStatus = false;
9
- this._linkInfoLog = "not linked";
10
- this._attributes = [];
11
- this._uniforms = [];
12
- this._ctx = ctx;
13
- this._linkCount = 0;
14
- this._linkStatus = false;
15
- this._linkInfoLog = "not linked";
16
- this._attributes = [];
17
- this._uniforms = [];
18
- }
19
- _performDelete() {
20
- const ctx = this._ctx;
21
- delete ctx._programs[this._ | 0];
22
- ctx._gl.deleteProgram(this._ | 0);
23
- }
24
- };
25
-
26
- //#endregion
27
- export { WebGLProgram };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[],this._ctx=t,this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[]}_performDelete(){let e=this._ctx;delete e._programs[this._|0],e._gl.deleteProgram(this._|0)}};export{t as WebGLProgram};
@@ -1,17 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-query.ts
4
- var WebGLQuery = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._ctx = ctx;
8
- }
9
- _performDelete() {
10
- const ctx = this._ctx;
11
- delete ctx._queries[this._ | 0];
12
- ctx._native2.deleteQuery(this._ | 0);
13
- }
14
- };
15
-
16
- //#endregion
17
- export { WebGLQuery };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._queries[this._|0],e._native2.deleteQuery(this._|0)}};export{t as WebGLQuery};
@@ -1,25 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-renderbuffer.ts
4
- var WebGLRenderbuffer = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._binding = 0;
8
- this._width = 0;
9
- this._height = 0;
10
- this._format = 0;
11
- this._ctx = ctx;
12
- this._binding = 0;
13
- this._width = 0;
14
- this._height = 0;
15
- this._format = 0;
16
- }
17
- _performDelete() {
18
- const ctx = this._ctx;
19
- delete ctx._renderbuffers[this._ | 0];
20
- ctx._gl.deleteRenderbuffer(this._);
21
- }
22
- };
23
-
24
- //#endregion
25
- export { WebGLRenderbuffer };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._binding=0,this._width=0,this._height=0,this._format=0,this._ctx=t,this._binding=0,this._width=0,this._height=0,this._format=0}_performDelete(){let e=this._ctx;delete e._renderbuffers[this._|0],e._gl.deleteRenderbuffer(this._)}};export{t as WebGLRenderbuffer};
@@ -1,175 +1 @@
1
- import { Uint8ArrayToVariant, vertexCount } from "./utils.js";
2
- import { WebGLContextBase } from "./webgl-context-base.js";
3
- import Gwebgl from "@girs/gwebgl-0.1";
4
-
5
- //#region src/ts/webgl-rendering-context.ts
6
- var WebGLRenderingContext = class extends WebGLContextBase {
7
- get _gl() {
8
- return this._native;
9
- }
10
- constructor(canvas, options = {}) {
11
- super(canvas, options);
12
- this._attrib0Buffer = null;
13
- this._native = new Gwebgl.WebGLRenderingContext({});
14
- this._init();
15
- const attrib0Buffer = this.createBuffer();
16
- this._attrib0Buffer = attrib0Buffer;
17
- }
18
- _beginAttrib0Hack() {
19
- this._native.bindBuffer(this.ARRAY_BUFFER, this._attrib0Buffer?._ || 0);
20
- const uInt8Data = new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);
21
- this._native.bufferData(this.ARRAY_BUFFER, Uint8ArrayToVariant(uInt8Data), this.STREAM_DRAW);
22
- this._native.enableVertexAttribArray(0);
23
- this._native.vertexAttribPointer(0, 4, this.FLOAT, false, 0, 0);
24
- this._native._vertexAttribDivisor(0, 1);
25
- }
26
- _endAttrib0Hack() {
27
- const attrib = this._vertexObjectState._attribs[0];
28
- if (attrib._pointerBuffer) {
29
- this._native.bindBuffer(this.ARRAY_BUFFER, attrib._pointerBuffer._);
30
- } else {
31
- this._native.bindBuffer(this.ARRAY_BUFFER, 0);
32
- }
33
- this._native.vertexAttribPointer(0, attrib._inputSize, attrib._pointerType, attrib._pointerNormal, attrib._inputStride, attrib._pointerOffset);
34
- this._native._vertexAttribDivisor(0, attrib._divisor);
35
- this._native.disableVertexAttribArray(0);
36
- if (this._vertexGlobalState._arrayBufferBinding) {
37
- this._native.bindBuffer(this.ARRAY_BUFFER, this._vertexGlobalState._arrayBufferBinding._);
38
- } else {
39
- this._native.bindBuffer(this.ARRAY_BUFFER, 0);
40
- }
41
- }
42
- drawArrays(mode = 0, first = 0, count = 0) {
43
- if (first < 0 || count < 0) {
44
- this.setError(this.INVALID_VALUE);
45
- return;
46
- }
47
- if (!this._checkStencilState()) {
48
- return;
49
- }
50
- const reducedCount = vertexCount(this, mode, count);
51
- if (reducedCount < 0) {
52
- this.setError(this.INVALID_ENUM);
53
- return;
54
- }
55
- if (!this._framebufferOk()) {
56
- return;
57
- }
58
- if (count === 0) {
59
- return;
60
- }
61
- let maxIndex = first;
62
- if (count > 0) {
63
- maxIndex = count + first - 1 >>> 0;
64
- }
65
- if (this._checkVertexAttribState(maxIndex)) {
66
- if (this._vertexObjectState._attribs[0]._isPointer || this._extensions.webgl_draw_buffers && this._extensions.webgl_draw_buffers._buffersState && this._extensions.webgl_draw_buffers._buffersState.length > 0) {
67
- return this._native.drawArrays(mode, first, reducedCount);
68
- } else {
69
- this._beginAttrib0Hack();
70
- this._native._drawArraysInstanced(mode, first, reducedCount, 1);
71
- this._endAttrib0Hack();
72
- }
73
- }
74
- }
75
- drawElements(mode = 0, count = 0, type = 0, ioffset = 0) {
76
- if (count < 0 || ioffset < 0) {
77
- this.setError(this.INVALID_VALUE);
78
- return;
79
- }
80
- if (!this._checkStencilState()) {
81
- return;
82
- }
83
- const elementBuffer = this._vertexObjectState._elementArrayBufferBinding;
84
- if (!elementBuffer) {
85
- this.setError(this.INVALID_OPERATION);
86
- return;
87
- }
88
- let elementData = null;
89
- let offset = ioffset;
90
- if (type === this.UNSIGNED_SHORT) {
91
- if (offset % 2) {
92
- this.setError(this.INVALID_OPERATION);
93
- return;
94
- }
95
- offset >>= 1;
96
- elementData = new Uint16Array(elementBuffer._elements.buffer);
97
- } else if (this._extensions.oes_element_index_uint && type === this.UNSIGNED_INT) {
98
- if (offset % 4) {
99
- this.setError(this.INVALID_OPERATION);
100
- return;
101
- }
102
- offset >>= 2;
103
- elementData = new Uint32Array(elementBuffer._elements.buffer);
104
- } else if (type === this.UNSIGNED_BYTE) {
105
- elementData = elementBuffer._elements;
106
- } else {
107
- this.setError(this.INVALID_ENUM);
108
- return;
109
- }
110
- let reducedCount = count;
111
- switch (mode) {
112
- case this.TRIANGLES:
113
- if (count % 3) {
114
- reducedCount -= count % 3;
115
- }
116
- break;
117
- case this.LINES:
118
- if (count % 2) {
119
- reducedCount -= count % 2;
120
- }
121
- break;
122
- case this.POINTS: break;
123
- case this.LINE_LOOP:
124
- case this.LINE_STRIP:
125
- if (count < 2) {
126
- this.setError(this.INVALID_OPERATION);
127
- return;
128
- }
129
- break;
130
- case this.TRIANGLE_FAN:
131
- case this.TRIANGLE_STRIP:
132
- if (count < 3) {
133
- this.setError(this.INVALID_OPERATION);
134
- return;
135
- }
136
- break;
137
- default:
138
- this.setError(this.INVALID_ENUM);
139
- return;
140
- }
141
- if (!this._framebufferOk()) {
142
- return;
143
- }
144
- if (count === 0) {
145
- this._checkVertexAttribState(0);
146
- return;
147
- }
148
- if (count + offset >>> 0 > elementData.length) {
149
- this.setError(this.INVALID_OPERATION);
150
- return;
151
- }
152
- let maxIndex = -1;
153
- for (let i = offset; i < offset + count; ++i) {
154
- maxIndex = Math.max(maxIndex, elementData[i]);
155
- }
156
- if (maxIndex < 0) {
157
- this._checkVertexAttribState(0);
158
- return;
159
- }
160
- if (this._checkVertexAttribState(maxIndex)) {
161
- if (reducedCount > 0) {
162
- if (this._vertexObjectState._attribs[0]._isPointer) {
163
- return this._native.drawElements(mode, reducedCount, type, ioffset);
164
- } else {
165
- this._beginAttrib0Hack();
166
- this._native._drawElementsInstanced(mode, reducedCount, type, ioffset, 1);
167
- this._endAttrib0Hack();
168
- }
169
- }
170
- }
171
- }
172
- };
173
-
174
- //#endregion
175
- export { WebGLContextBase, WebGLRenderingContext };
1
+ import{Uint8ArrayToVariant as e,vertexCount as t}from"./utils.js";import{WebGLContextBase as n}from"./webgl-context-base.js";import r from"@girs/gwebgl-0.1";var i=class extends n{get _gl(){return this._native}constructor(e,t={}){super(e,t),this._attrib0Buffer=null,this._native=new r.WebGLRenderingContext({}),this._init();let n=this.createBuffer();this._attrib0Buffer=n}_beginAttrib0Hack(){this._native.bindBuffer(this.ARRAY_BUFFER,this._attrib0Buffer?._||0);let t=new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);this._native.bufferData(this.ARRAY_BUFFER,e(t),this.STREAM_DRAW),this._native.enableVertexAttribArray(0),this._native.vertexAttribPointer(0,4,this.FLOAT,!1,0,0),this._native._vertexAttribDivisor(0,1)}_endAttrib0Hack(){let e=this._vertexObjectState._attribs[0];e._pointerBuffer?this._native.bindBuffer(this.ARRAY_BUFFER,e._pointerBuffer._):this._native.bindBuffer(this.ARRAY_BUFFER,0),this._native.vertexAttribPointer(0,e._inputSize,e._pointerType,e._pointerNormal,e._inputStride,e._pointerOffset),this._native._vertexAttribDivisor(0,e._divisor),this._native.disableVertexAttribArray(0),this._vertexGlobalState._arrayBufferBinding?this._native.bindBuffer(this.ARRAY_BUFFER,this._vertexGlobalState._arrayBufferBinding._):this._native.bindBuffer(this.ARRAY_BUFFER,0)}drawArrays(e=0,n=0,r=0){if(n<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=t(this,e,r);if(i<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||r===0)return;let a=n;if(r>0&&(a=r+n-1>>>0),this._checkVertexAttribState(a)){if(this._vertexObjectState._attribs[0]._isPointer||this._extensions.webgl_draw_buffers&&this._extensions.webgl_draw_buffers._buffersState&&this._extensions.webgl_draw_buffers._buffersState.length>0)return this._native.drawArrays(e,n,i);this._beginAttrib0Hack(),this._native._drawArraysInstanced(e,n,i,1),this._endAttrib0Hack()}}drawElements(e=0,t=0,n=0,r=0){if(t<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=this._vertexObjectState._elementArrayBufferBinding;if(!i){this.setError(this.INVALID_OPERATION);return}let a=null,o=r;if(n===this.UNSIGNED_SHORT){if(o%2){this.setError(this.INVALID_OPERATION);return}o>>=1,a=new Uint16Array(i._elements.buffer)}else if(this._extensions.oes_element_index_uint&&n===this.UNSIGNED_INT){if(o%4){this.setError(this.INVALID_OPERATION);return}o>>=2,a=new Uint32Array(i._elements.buffer)}else if(n===this.UNSIGNED_BYTE)a=i._elements;else{this.setError(this.INVALID_ENUM);return}let s=t;switch(e){case this.TRIANGLES:t%3&&(s-=t%3);break;case this.LINES:t%2&&(s-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(t===0){this._checkVertexAttribState(0);return}if(t+o>>>0>a.length){this.setError(this.INVALID_OPERATION);return}let c=-1;for(let e=o;e<o+t;++e)c=Math.max(c,a[e]);if(c<0){this._checkVertexAttribState(0);return}if(this._checkVertexAttribState(c)&&s>0){if(this._vertexObjectState._attribs[0]._isPointer)return this._native.drawElements(e,s,n,r);this._beginAttrib0Hack(),this._native._drawElementsInstanced(e,s,n,r,1),this._endAttrib0Hack()}}};export{n as WebGLContextBase,i as WebGLRenderingContext};
@@ -1,17 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-sampler.ts
4
- var WebGLSampler = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._ctx = ctx;
8
- }
9
- _performDelete() {
10
- const ctx = this._ctx;
11
- delete ctx._samplers[this._ | 0];
12
- ctx._native2.deleteSampler(this._ | 0);
13
- }
14
- };
15
-
16
- //#endregion
17
- export { WebGLSampler };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._samplers[this._|0],e._native2.deleteSampler(this._|0)}};export{t as WebGLSampler};
@@ -1,11 +1 @@
1
- //#region src/ts/webgl-shader-precision-format.ts
2
- var WebGLShaderPrecisionFormat = class {
3
- constructor(_) {
4
- this.rangeMin = _.rangeMin;
5
- this.rangeMax = _.rangeMax;
6
- this.precision = _.precision;
7
- }
8
- };
9
-
10
- //#endregion
11
- export { WebGLShaderPrecisionFormat };
1
+ var e=class{constructor(e){this.rangeMin=e.rangeMin,this.rangeMax=e.rangeMax,this.precision=e.precision}};export{e as WebGLShaderPrecisionFormat};
@@ -1,25 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-shader.ts
4
- var WebGLShader = class extends Linkable {
5
- constructor(_, ctx, type) {
6
- super(_);
7
- this._source = "";
8
- this._compileStatus = false;
9
- this._compileInfo = "";
10
- this._needsRecompile = false;
11
- this._type = type;
12
- this._ctx = ctx;
13
- this._source = "";
14
- this._compileStatus = false;
15
- this._compileInfo = "";
16
- }
17
- _performDelete() {
18
- const ctx = this._ctx;
19
- delete ctx._shaders[this._ | 0];
20
- ctx._gl.deleteShader(this._ | 0);
21
- }
22
- };
23
-
24
- //#endregion
25
- export { WebGLShader };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t,n){super(e),this._source=``,this._compileStatus=!1,this._compileInfo=``,this._needsRecompile=!1,this._type=n,this._ctx=t,this._source=``,this._compileStatus=!1,this._compileInfo=``}_performDelete(){let e=this._ctx;delete e._shaders[this._|0],e._gl.deleteShader(this._|0)}};export{t as WebGLShader};
@@ -1,17 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-sync.ts
4
- var WebGLSync = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._ctx = ctx;
8
- }
9
- _performDelete() {
10
- const ctx = this._ctx;
11
- delete ctx._syncs[this._ | 0];
12
- ctx._native2.deleteSync(this._ | 0);
13
- }
14
- };
15
-
16
- //#endregion
17
- export { WebGLSync };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._syncs[this._|0],e._native2.deleteSync(this._|0)}};export{t as WebGLSync};
@@ -1,13 +1 @@
1
- //#region src/ts/webgl-texture-unit.ts
2
- var WebGLTextureUnit = class {
3
- constructor(ctx, idx) {
4
- this._mode = 0;
5
- this._bind2D = null;
6
- this._bindCube = null;
7
- this._ctx = ctx;
8
- this._idx = idx;
9
- }
10
- };
11
-
12
- //#endregion
13
- export { WebGLTextureUnit };
1
+ var e=class{constructor(e,t){this._mode=0,this._bind2D=null,this._bindCube=null,this._ctx=e,this._idx=t}};export{e as WebGLTextureUnit};
@@ -1,23 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-texture.ts
4
- var WebGLTexture = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._binding = 0;
8
- this._levelWidth = new Int32Array(32);
9
- this._levelHeight = new Int32Array(32);
10
- this._format = 0;
11
- this._type = 0;
12
- this._complete = true;
13
- this._ctx = ctx;
14
- }
15
- _performDelete() {
16
- const ctx = this._ctx;
17
- delete ctx._textures[this._ | 0];
18
- ctx._gl.deleteTexture(this._ | 0);
19
- }
20
- };
21
-
22
- //#endregion
23
- export { WebGLTexture };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._binding=0,this._levelWidth=new Int32Array(32),this._levelHeight=new Int32Array(32),this._format=0,this._type=0,this._complete=!0,this._ctx=t}_performDelete(){let e=this._ctx;delete e._textures[this._|0],e._gl.deleteTexture(this._|0)}};export{t as WebGLTexture};
@@ -1,17 +1 @@
1
- import { Linkable } from "./linkable.js";
2
-
3
- //#region src/ts/webgl-transform-feedback.ts
4
- var WebGLTransformFeedback = class extends Linkable {
5
- constructor(_, ctx) {
6
- super(_);
7
- this._ctx = ctx;
8
- }
9
- _performDelete() {
10
- const ctx = this._ctx;
11
- delete ctx._transformFeedbacks[this._ | 0];
12
- ctx._native2.deleteTransformFeedback(this._ | 0);
13
- }
14
- };
15
-
16
- //#endregion
17
- export { WebGLTransformFeedback };
1
+ import{Linkable as e}from"./linkable.js";var t=class extends e{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._transformFeedbacks[this._|0],e._native2.deleteTransformFeedback(this._|0)}};export{t as WebGLTransformFeedback};
@@ -1,15 +1 @@
1
- //#region src/ts/webgl-uniform-location.ts
2
- var WebGLUniformLocation = class {
3
- constructor(_, program, info) {
4
- this._linkCount = 0;
5
- this._array = null;
6
- this._ = _;
7
- this._program = program;
8
- this._linkCount = program._linkCount;
9
- this._activeInfo = info;
10
- this._array = null;
11
- }
12
- };
13
-
14
- //#endregion
15
- export { WebGLUniformLocation };
1
+ var e=class{constructor(e,t,n){this._linkCount=0,this._array=null,this._=e,this._program=t,this._linkCount=t._linkCount,this._activeInfo=n,this._array=null}};export{e as WebGLUniformLocation};
@@ -1,23 +1 @@
1
- import { Linkable } from "./linkable.js";
2
- import { WebGLVertexArrayObjectState } from "./webgl-vertex-attribute.js";
3
-
4
- //#region src/ts/webgl-vertex-array-object.ts
5
- var WebGLVertexArrayObject = class extends Linkable {
6
- constructor(_, ctx) {
7
- super(_);
8
- this._ctx = ctx;
9
- this._objectState = new WebGLVertexArrayObjectState(ctx);
10
- }
11
- _performDelete() {
12
- const ctx = this._ctx;
13
- if (ctx._vertexObjectState === this._objectState) {
14
- ctx._vertexObjectState = ctx._defaultVertexObjectState;
15
- }
16
- this._objectState.cleanUp();
17
- delete ctx._vertexArrayObjects[this._ | 0];
18
- ctx._native2.deleteVertexArray(this._ | 0);
19
- }
20
- };
21
-
22
- //#endregion
23
- export { WebGLVertexArrayObject };
1
+ import{Linkable as e}from"./linkable.js";import{WebGLVertexArrayObjectState as t}from"./webgl-vertex-attribute.js";var n=class extends e{constructor(e,n){super(e),this._ctx=n,this._objectState=new t(n)}_performDelete(){let e=this._ctx;e._vertexObjectState===this._objectState&&(e._vertexObjectState=e._defaultVertexObjectState),this._objectState.cleanUp(),delete e._vertexArrayObjects[this._|0],e._native2.deleteVertexArray(this._|0)}};export{n as WebGLVertexArrayObject};