@gjsify/webgl 0.0.3 → 0.1.0

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 (149) hide show
  1. package/README.md +78 -6
  2. package/lib/esm/canvas-webgl-widget.js +116 -0
  3. package/lib/esm/html-canvas-element.js +31 -50
  4. package/lib/esm/index.js +7 -0
  5. package/lib/esm/index.spec.js +629 -120
  6. package/lib/esm/test-utils.js +87 -0
  7. package/lib/esm/test.js +5 -1
  8. package/lib/esm/utils.js +1 -1
  9. package/lib/esm/webgl-active-info.js +2 -2
  10. package/lib/esm/webgl-buffer.js +2 -3
  11. package/lib/esm/webgl-context-attributes.js +2 -3
  12. package/lib/esm/webgl-framebuffer.js +3 -4
  13. package/lib/esm/webgl-program.js +2 -3
  14. package/lib/esm/webgl-query.js +15 -0
  15. package/lib/esm/webgl-renderbuffer.js +2 -3
  16. package/lib/esm/webgl-rendering-context.js +105 -101
  17. package/lib/esm/webgl-sampler.js +15 -0
  18. package/lib/esm/webgl-shader-precision-format.js +2 -3
  19. package/lib/esm/webgl-shader.js +2 -3
  20. package/lib/esm/webgl-sync.js +15 -0
  21. package/lib/esm/webgl-texture.js +2 -3
  22. package/lib/esm/webgl-transform-feedback.js +15 -0
  23. package/lib/esm/webgl-uniform-location.js +2 -3
  24. package/lib/esm/webgl-vertex-array-object.js +21 -0
  25. package/lib/esm/webgl2-rendering-context.js +591 -0
  26. package/lib/esm/webgl2.spec.js +578 -0
  27. package/lib/types/canvas-webgl-widget.d.ts +509 -0
  28. package/lib/types/extensions/ext-blend-minmax.d.ts +2 -2
  29. package/lib/types/extensions/ext-texture-filter-anisotropic.d.ts +2 -2
  30. package/lib/types/extensions/oes-element-index-unit.d.ts +2 -2
  31. package/lib/types/extensions/oes-standard-derivatives.d.ts +2 -2
  32. package/lib/types/extensions/oes-texture-float-linear.d.ts +2 -2
  33. package/lib/types/extensions/oes-texture-float.d.ts +2 -2
  34. package/lib/types/extensions/stackgl-destroy-context.d.ts +3 -3
  35. package/lib/types/extensions/stackgl-resize-drawing-buffer.d.ts +3 -3
  36. package/lib/types/html-canvas-element.d.ts +19 -30
  37. package/lib/types/index.d.ts +7 -0
  38. package/lib/types/test-utils.d.ts +45 -0
  39. package/lib/types/types/extension.d.ts +2 -2
  40. package/lib/types/utils.d.ts +14 -15
  41. package/lib/types/webgl-active-info.d.ts +1 -2
  42. package/lib/types/webgl-buffer.d.ts +5 -6
  43. package/lib/types/webgl-context-attributes.d.ts +1 -2
  44. package/lib/types/webgl-framebuffer.d.ts +4 -5
  45. package/lib/types/webgl-program.d.ts +4 -5
  46. package/lib/types/webgl-query.d.ts +7 -0
  47. package/lib/types/webgl-renderbuffer.d.ts +4 -5
  48. package/lib/types/webgl-rendering-context.d.ts +15 -12
  49. package/lib/types/webgl-sampler.d.ts +7 -0
  50. package/lib/types/webgl-shader-precision-format.d.ts +1 -2
  51. package/lib/types/webgl-shader.d.ts +4 -5
  52. package/lib/types/webgl-sync.d.ts +7 -0
  53. package/lib/types/webgl-texture-unit.d.ts +3 -3
  54. package/lib/types/webgl-texture.d.ts +6 -7
  55. package/lib/types/webgl-transform-feedback.d.ts +7 -0
  56. package/lib/types/webgl-uniform-location.d.ts +3 -4
  57. package/lib/types/webgl-vertex-array-object.d.ts +9 -0
  58. package/lib/types/webgl-vertex-attribute.d.ts +5 -5
  59. package/lib/types/webgl2-rendering-context.d.ts +124 -0
  60. package/package.json +27 -26
  61. package/prebuilds/linux-aarch64/Gwebgl-0.1.typelib +0 -0
  62. package/prebuilds/linux-aarch64/libgwebgl.so +0 -0
  63. package/prebuilds/linux-x86_64/Gwebgl-0.1.typelib +0 -0
  64. package/prebuilds/linux-x86_64/libgwebgl.so +0 -0
  65. package/lib/cjs/@types/glsl-tokenizer/index.d.js +0 -0
  66. package/lib/cjs/extensions/ext-blend-minmax.js +0 -18
  67. package/lib/cjs/extensions/ext-texture-filter-anisotropic.js +0 -18
  68. package/lib/cjs/extensions/oes-element-index-unit.js +0 -14
  69. package/lib/cjs/extensions/oes-standard-derivatives.js +0 -17
  70. package/lib/cjs/extensions/oes-texture-float-linear.js +0 -14
  71. package/lib/cjs/extensions/oes-texture-float.js +0 -14
  72. package/lib/cjs/extensions/stackgl-destroy-context.js +0 -12
  73. package/lib/cjs/extensions/stackgl-resize-drawing-buffer.js +0 -12
  74. package/lib/cjs/html-canvas-element.js +0 -70
  75. package/lib/cjs/index.js +0 -18
  76. package/lib/cjs/index.spec.js +0 -146
  77. package/lib/cjs/linkable.js +0 -50
  78. package/lib/cjs/test.js +0 -3
  79. package/lib/cjs/types/constructor.js +0 -0
  80. package/lib/cjs/types/extension.js +0 -0
  81. package/lib/cjs/types/index.js +0 -5
  82. package/lib/cjs/types/typed-array.js +0 -0
  83. package/lib/cjs/types/webgl-constants.js +0 -0
  84. package/lib/cjs/types/webgl-context-attribute-options.js +0 -0
  85. package/lib/cjs/utils.js +0 -212
  86. package/lib/cjs/webgl-active-info.js +0 -10
  87. package/lib/cjs/webgl-buffer.js +0 -18
  88. package/lib/cjs/webgl-context-attributes.js +0 -24
  89. package/lib/cjs/webgl-drawing-buffer-wrapper.js +0 -10
  90. package/lib/cjs/webgl-framebuffer.js +0 -109
  91. package/lib/cjs/webgl-program.js +0 -26
  92. package/lib/cjs/webgl-renderbuffer.js +0 -24
  93. package/lib/cjs/webgl-rendering-context.js +0 -3343
  94. package/lib/cjs/webgl-shader-precision-format.js +0 -11
  95. package/lib/cjs/webgl-shader.js +0 -23
  96. package/lib/cjs/webgl-texture-unit.js +0 -12
  97. package/lib/cjs/webgl-texture.js +0 -22
  98. package/lib/cjs/webgl-uniform-location.js +0 -15
  99. package/lib/cjs/webgl-vertex-attribute.js +0 -147
  100. package/meson.build +0 -39
  101. package/src/test/app.vala +0 -60
  102. package/src/ts/@types/glsl-tokenizer/index.d.ts +0 -18
  103. package/src/ts/extensions/angle-instanced-arrays.ts.off +0 -232
  104. package/src/ts/extensions/ext-blend-minmax.ts +0 -18
  105. package/src/ts/extensions/ext-texture-filter-anisotropic.ts +0 -18
  106. package/src/ts/extensions/oes-element-index-unit.ts +0 -14
  107. package/src/ts/extensions/oes-standard-derivatives.ts +0 -17
  108. package/src/ts/extensions/oes-texture-float-linear.ts +0 -14
  109. package/src/ts/extensions/oes-texture-float.ts +0 -14
  110. package/src/ts/extensions/oes-vertex-array-object.ts.off +0 -128
  111. package/src/ts/extensions/stackgl-destroy-context.ts +0 -12
  112. package/src/ts/extensions/stackgl-resize-drawing-buffer.ts +0 -14
  113. package/src/ts/extensions/webgl-draw-buffers.ts.off +0 -107
  114. package/src/ts/html-canvas-element.ts +0 -98
  115. package/src/ts/index.spec.ts +0 -186
  116. package/src/ts/index.ts +0 -21
  117. package/src/ts/linkable.ts +0 -55
  118. package/src/ts/test.ts +0 -6
  119. package/src/ts/types/constructor.ts +0 -3
  120. package/src/ts/types/extension.ts +0 -3
  121. package/src/ts/types/index.ts +0 -26
  122. package/src/ts/types/typed-array.ts +0 -1
  123. package/src/ts/types/webgl-constants.ts +0 -300
  124. package/src/ts/types/webgl-context-attribute-options.ts +0 -12
  125. package/src/ts/utils.ts +0 -266
  126. package/src/ts/webgl-active-info.ts +0 -13
  127. package/src/ts/webgl-buffer.ts +0 -21
  128. package/src/ts/webgl-context-attributes.ts +0 -24
  129. package/src/ts/webgl-drawing-buffer-wrapper.ts +0 -10
  130. package/src/ts/webgl-framebuffer.ts +0 -133
  131. package/src/ts/webgl-program.ts +0 -30
  132. package/src/ts/webgl-renderbuffer.ts +0 -28
  133. package/src/ts/webgl-rendering-context.ts +0 -4050
  134. package/src/ts/webgl-shader-precision-format.ts +0 -12
  135. package/src/ts/webgl-shader.ts +0 -29
  136. package/src/ts/webgl-texture-unit.ts +0 -16
  137. package/src/ts/webgl-texture.ts +0 -27
  138. package/src/ts/webgl-uniform-location.ts +0 -18
  139. package/src/ts/webgl-vertex-attribute.ts +0 -169
  140. package/src/vala/handle-types.vala +0 -23
  141. package/src/vala/webgl-rendering-context-base.vala +0 -1265
  142. package/src/vala/webgl-rendering-context.vala +0 -265
  143. package/src/vapi/epoxy.vapi +0 -14558
  144. package/src/vapi/glesv2.vapi +0 -670
  145. package/test.gjs.js +0 -39972
  146. package/test.gjs.js.meta.json +0 -1
  147. package/tmp/.tsbuildinfo +0 -1
  148. package/tsconfig.json +0 -38
  149. package/tsconfig.types.json +0 -7
@@ -1,12 +0,0 @@
1
- export class GjsifyWebGLShaderPrecisionFormat implements WebGLShaderPrecisionFormat {
2
- rangeMin: number;
3
- rangeMax: number;
4
- precision: number;
5
- constructor (_: WebGLShaderPrecisionFormat) {
6
- this.rangeMin = _.rangeMin
7
- this.rangeMax = _.rangeMax
8
- this.precision = _.precision
9
- }
10
- }
11
-
12
- export { GjsifyWebGLShaderPrecisionFormat as WebGLShaderPrecisionFormat }
@@ -1,29 +0,0 @@
1
- import { Linkable } from './linkable.js'
2
-
3
- import type { GjsifyWebGLRenderingContext } from './webgl-rendering-context.js';
4
-
5
- export class GjsifyWebGLShader extends Linkable implements WebGLShader {
6
-
7
- _type: GLenum;
8
- _ctx: GjsifyWebGLRenderingContext;
9
- _source = ''
10
- _compileStatus = false
11
- _compileInfo = ''
12
-
13
- constructor (_: WebGLShader & number, ctx: GjsifyWebGLRenderingContext, type: GLenum) {
14
- super(_)
15
- this._type = type
16
- this._ctx = ctx
17
- this._source = ''
18
- this._compileStatus = false
19
- this._compileInfo = ''
20
- }
21
-
22
- _performDelete () {
23
- const ctx = this._ctx
24
- delete ctx._shaders[this._ | 0]
25
- ctx._native.deleteShader(this._ | 0)
26
- }
27
- }
28
-
29
- export { GjsifyWebGLShader as WebGLShader }
@@ -1,16 +0,0 @@
1
- import type { GjsifyWebGLRenderingContext } from './webgl-rendering-context.js';
2
- import type { WebGLTexture } from './webgl-texture.js';
3
-
4
- export class WebGLTextureUnit {
5
- _ctx: GjsifyWebGLRenderingContext;
6
- _idx: number;
7
- _mode = 0
8
- _bind2D: WebGLTexture | null = null
9
- _bindCube: WebGLTexture | null = null
10
-
11
- constructor(ctx: GjsifyWebGLRenderingContext, idx: number) {
12
- this._ctx = ctx
13
- this._idx = idx
14
- }
15
- }
16
-
@@ -1,27 +0,0 @@
1
-
2
- import { Linkable } from './linkable.js'
3
- // import { gl } from './native-gl.js'
4
-
5
- import type { GjsifyWebGLRenderingContext } from './webgl-rendering-context.js';
6
-
7
- export class GjsifyWebGLTexture extends Linkable implements WebGLTexture {
8
- _ctx: GjsifyWebGLRenderingContext;
9
- _binding = 0
10
- _levelWidth = new Int32Array(32)
11
- _levelHeight = new Int32Array(32)
12
- _format = 0
13
- _type = 0
14
- _complete = true
15
- constructor (_: WebGLTexture & number, ctx: GjsifyWebGLRenderingContext) {
16
- super(_)
17
- this._ctx = ctx
18
- }
19
-
20
- _performDelete () {
21
- const ctx = this._ctx
22
- delete ctx._textures[this._ | 0]
23
- ctx._native.deleteTexture(this._ | 0)
24
- }
25
- }
26
-
27
- export { GjsifyWebGLTexture as WebGLTexture }
@@ -1,18 +0,0 @@
1
- import type { WebGLProgram } from './webgl-program.js';
2
-
3
- export class GjsifyWebGLUniformLocation implements WebGLUniformLocation {
4
- _: WebGLUniformLocation & number;
5
- _program: WebGLProgram;
6
- _linkCount = 0;
7
- _activeInfo: {size: GLsizei, type: GLenum, name: string };
8
- _array: Array<number | null> | null = null
9
- constructor (_: WebGLUniformLocation & number, program: WebGLProgram, info: {size: GLsizei, type: GLenum, name: string }) {
10
- this._ = _
11
- this._program = program
12
- this._linkCount = program._linkCount
13
- this._activeInfo = info
14
- this._array = null
15
- }
16
- }
17
-
18
- export { GjsifyWebGLUniformLocation as WebGLUniformLocation }
@@ -1,169 +0,0 @@
1
- import { WebGLBuffer } from './webgl-buffer.js'
2
-
3
- import type { GjsifyWebGLRenderingContext } from './webgl-rendering-context.js';
4
-
5
- export class WebGLVertexArrayObjectAttribute {
6
- _ctx: GjsifyWebGLRenderingContext;
7
- _idx: number;
8
- _isPointer = false
9
- _pointerBuffer: WebGLBuffer | null = null;
10
- _pointerOffset = 0
11
- _pointerSize = 0
12
- _pointerStride = 0
13
- _pointerType = 0
14
- _pointerNormal = false
15
- _divisor = 0
16
- _inputSize = 4
17
- _inputStride = 0
18
-
19
- constructor(ctx: GjsifyWebGLRenderingContext, idx: number) {
20
- this._ctx = ctx
21
- this._idx = idx
22
- this._pointerType = ctx.FLOAT
23
- this._clear()
24
- }
25
-
26
- _clear() {
27
- this._isPointer = false
28
- this._pointerBuffer = null
29
- this._pointerOffset = 0
30
- this._pointerSize = 0
31
- this._pointerStride = 0
32
- this._pointerType = this._ctx.FLOAT
33
- this._pointerNormal = false
34
- this._divisor = 0
35
- this._inputSize = 4
36
- this._inputStride = 0
37
- }
38
- }
39
-
40
- export class WebGLVertexArrayGlobalAttribute {
41
- _idx = 0;
42
- _data: Float32Array;
43
- constructor(idx: number) {
44
- this._idx = idx
45
- this._data = new Float32Array([0, 0, 0, 1])
46
- }
47
- }
48
-
49
- export class WebGLVertexArrayObjectState {
50
- _attribs: WebGLVertexArrayObjectAttribute[];
51
- _elementArrayBufferBinding: WebGLBuffer | null = null;
52
- constructor(ctx: GjsifyWebGLRenderingContext) {
53
- const numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS) as number;
54
- this._attribs = new Array(numAttribs)
55
- for (let i = 0; i < numAttribs; ++i) {
56
- this._attribs[i] = new WebGLVertexArrayObjectAttribute(ctx, i)
57
- }
58
- this._elementArrayBufferBinding = null
59
- }
60
-
61
- setElementArrayBuffer(buffer: WebGLBuffer | null) {
62
- if (buffer !== null && !(buffer instanceof WebGLBuffer)) {
63
- throw new TypeError('setElementArrayBuffer(WebGLBuffer?)')
64
- }
65
- const current = this._elementArrayBufferBinding
66
- if (current !== buffer) {
67
- if (current) {
68
- current._refCount -= 1
69
- current._checkDelete()
70
- }
71
- if (buffer) {
72
- buffer._refCount += 1
73
- }
74
- this._elementArrayBufferBinding = buffer
75
- }
76
- }
77
-
78
- cleanUp() {
79
- const elementArrayBuffer = this._elementArrayBufferBinding
80
- if (elementArrayBuffer) {
81
- elementArrayBuffer._refCount -= 1
82
- elementArrayBuffer._checkDelete()
83
- this._elementArrayBufferBinding = null
84
- }
85
-
86
- for (let i = 0; i < this._attribs.length; ++i) {
87
- const attrib = this._attribs[i]
88
- if (attrib._pointerBuffer) {
89
- attrib._pointerBuffer._refCount -= 1
90
- attrib._pointerBuffer._checkDelete()
91
- }
92
- attrib._clear()
93
- }
94
- }
95
-
96
- releaseArrayBuffer(buffer: WebGLBuffer) {
97
- if (!buffer) {
98
- return
99
- }
100
- for (let i = 0; i < this._attribs.length; ++i) {
101
- const attrib = this._attribs[i]
102
- if (attrib._pointerBuffer === buffer) {
103
- attrib._pointerBuffer._refCount -= 1
104
- attrib._pointerBuffer._checkDelete()
105
- attrib._clear()
106
- }
107
- }
108
- }
109
-
110
- setVertexAttribPointer(
111
- buffer: WebGLBuffer,
112
- index: number,
113
- pointerSize: number,
114
- pointerOffset: number,
115
- pointerStride: number,
116
- pointerType: number,
117
- pointerNormal: boolean,
118
- inputStride: number,
119
- inputSize: number) {
120
- const attrib = this._attribs[index]
121
- if (buffer !== attrib._pointerBuffer) {
122
- if (attrib._pointerBuffer) {
123
- attrib._pointerBuffer._refCount -= 1
124
- attrib._pointerBuffer._checkDelete()
125
- }
126
- if (buffer) {
127
- buffer._refCount += 1
128
- }
129
- attrib._pointerBuffer = buffer
130
- }
131
- attrib._pointerSize = pointerSize
132
- attrib._pointerOffset = pointerOffset
133
- attrib._pointerStride = pointerStride
134
- attrib._pointerType = pointerType
135
- attrib._pointerNormal = pointerNormal
136
- attrib._inputStride = inputStride
137
- attrib._inputSize = inputSize
138
- }
139
- }
140
-
141
- export class WebGLVertexArrayGlobalState {
142
- _arrayBufferBinding: WebGLBuffer | null = null;
143
- _attribs: WebGLVertexArrayGlobalAttribute[];
144
- constructor(ctx: GjsifyWebGLRenderingContext) {
145
- const numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS)
146
- this._attribs = new Array(numAttribs)
147
- for (let i = 0; i < numAttribs; ++i) {
148
- this._attribs[i] = new WebGLVertexArrayGlobalAttribute(i)
149
- }
150
- this._arrayBufferBinding = null
151
- }
152
-
153
- setArrayBuffer(buffer: WebGLBuffer | null) {
154
- if (buffer !== null && !(buffer instanceof WebGLBuffer)) {
155
- throw new TypeError('setArrayBuffer(WebGLBuffer?)')
156
- }
157
- const current = this._arrayBufferBinding
158
- if (current !== buffer) {
159
- if (current) {
160
- current._refCount -= 1
161
- current._checkDelete()
162
- }
163
- if (buffer) {
164
- buffer._refCount += 1
165
- }
166
- this._arrayBufferBinding = buffer
167
- }
168
- }
169
- }
@@ -1,23 +0,0 @@
1
- namespace Gwebgl {
2
- using GL;
3
-
4
- // public struct WebGLProgram : uint {}
5
- // public struct WebGLShader : uint {}
6
- // public struct WebGLBuffer : uint {}
7
- // public struct WebGLFramebuffer : uint {}
8
- // public struct WebGLRenderbuffer : uint {}
9
- // public struct WebGLTexture : uint {}
10
- // public struct WebGLUniformLocation : int {}
11
-
12
- public struct WebGLActiveInfo {
13
- public string name;
14
- public int size;
15
- public int type;
16
- }
17
-
18
- public struct WebGLShaderPrecisionFormat {
19
- public int precision;
20
- public int rangeMax;
21
- public int rangeMin;
22
- }
23
- }