@gjsify/webgl 0.0.4 → 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.
- package/README.md +78 -6
- package/lib/esm/canvas-webgl-widget.js +116 -0
- package/lib/esm/html-canvas-element.js +31 -50
- package/lib/esm/index.js +7 -0
- package/lib/esm/index.spec.js +629 -120
- package/lib/esm/test-utils.js +87 -0
- package/lib/esm/test.js +5 -1
- package/lib/esm/utils.js +1 -1
- package/lib/esm/webgl-active-info.js +2 -2
- package/lib/esm/webgl-buffer.js +2 -3
- package/lib/esm/webgl-context-attributes.js +2 -3
- package/lib/esm/webgl-framebuffer.js +3 -4
- package/lib/esm/webgl-program.js +2 -3
- package/lib/esm/webgl-query.js +15 -0
- package/lib/esm/webgl-renderbuffer.js +2 -3
- package/lib/esm/webgl-rendering-context.js +105 -101
- package/lib/esm/webgl-sampler.js +15 -0
- package/lib/esm/webgl-shader-precision-format.js +2 -3
- package/lib/esm/webgl-shader.js +2 -3
- package/lib/esm/webgl-sync.js +15 -0
- package/lib/esm/webgl-texture.js +2 -3
- package/lib/esm/webgl-transform-feedback.js +15 -0
- package/lib/esm/webgl-uniform-location.js +2 -3
- package/lib/esm/webgl-vertex-array-object.js +21 -0
- package/lib/esm/webgl2-rendering-context.js +591 -0
- package/lib/esm/webgl2.spec.js +578 -0
- package/lib/types/canvas-webgl-widget.d.ts +509 -0
- package/lib/types/extensions/ext-blend-minmax.d.ts +2 -2
- package/lib/types/extensions/ext-texture-filter-anisotropic.d.ts +2 -2
- package/lib/types/extensions/oes-element-index-unit.d.ts +2 -2
- package/lib/types/extensions/oes-standard-derivatives.d.ts +2 -2
- package/lib/types/extensions/oes-texture-float-linear.d.ts +2 -2
- package/lib/types/extensions/oes-texture-float.d.ts +2 -2
- package/lib/types/extensions/stackgl-destroy-context.d.ts +3 -3
- package/lib/types/extensions/stackgl-resize-drawing-buffer.d.ts +3 -3
- package/lib/types/html-canvas-element.d.ts +19 -31
- package/lib/types/index.d.ts +7 -0
- package/lib/types/test-utils.d.ts +45 -0
- package/lib/types/types/extension.d.ts +2 -2
- package/lib/types/utils.d.ts +14 -15
- package/lib/types/webgl-active-info.d.ts +1 -2
- package/lib/types/webgl-buffer.d.ts +5 -6
- package/lib/types/webgl-context-attributes.d.ts +1 -2
- package/lib/types/webgl-framebuffer.d.ts +4 -5
- package/lib/types/webgl-program.d.ts +4 -5
- package/lib/types/webgl-query.d.ts +7 -0
- package/lib/types/webgl-renderbuffer.d.ts +4 -5
- package/lib/types/webgl-rendering-context.d.ts +15 -13
- package/lib/types/webgl-sampler.d.ts +7 -0
- package/lib/types/webgl-shader-precision-format.d.ts +1 -2
- package/lib/types/webgl-shader.d.ts +4 -5
- package/lib/types/webgl-sync.d.ts +7 -0
- package/lib/types/webgl-texture-unit.d.ts +3 -3
- package/lib/types/webgl-texture.d.ts +6 -7
- package/lib/types/webgl-transform-feedback.d.ts +7 -0
- package/lib/types/webgl-uniform-location.d.ts +3 -4
- package/lib/types/webgl-vertex-array-object.d.ts +9 -0
- package/lib/types/webgl-vertex-attribute.d.ts +5 -5
- package/lib/types/webgl2-rendering-context.d.ts +124 -0
- package/package.json +27 -26
- package/prebuilds/linux-aarch64/Gwebgl-0.1.typelib +0 -0
- package/prebuilds/linux-aarch64/libgwebgl.so +0 -0
- package/prebuilds/linux-x86_64/Gwebgl-0.1.typelib +0 -0
- package/prebuilds/linux-x86_64/libgwebgl.so +0 -0
- package/lib/cjs/@types/glsl-tokenizer/index.d.js +0 -0
- package/lib/cjs/extensions/ext-blend-minmax.js +0 -18
- package/lib/cjs/extensions/ext-texture-filter-anisotropic.js +0 -18
- package/lib/cjs/extensions/oes-element-index-unit.js +0 -14
- package/lib/cjs/extensions/oes-standard-derivatives.js +0 -17
- package/lib/cjs/extensions/oes-texture-float-linear.js +0 -14
- package/lib/cjs/extensions/oes-texture-float.js +0 -14
- package/lib/cjs/extensions/stackgl-destroy-context.js +0 -12
- package/lib/cjs/extensions/stackgl-resize-drawing-buffer.js +0 -12
- package/lib/cjs/html-canvas-element.js +0 -70
- package/lib/cjs/index.js +0 -18
- package/lib/cjs/index.spec.js +0 -146
- package/lib/cjs/linkable.js +0 -50
- package/lib/cjs/test.js +0 -3
- package/lib/cjs/types/constructor.js +0 -0
- package/lib/cjs/types/extension.js +0 -0
- package/lib/cjs/types/index.js +0 -5
- package/lib/cjs/types/typed-array.js +0 -0
- package/lib/cjs/types/webgl-constants.js +0 -0
- package/lib/cjs/types/webgl-context-attribute-options.js +0 -0
- package/lib/cjs/utils.js +0 -212
- package/lib/cjs/webgl-active-info.js +0 -10
- package/lib/cjs/webgl-buffer.js +0 -18
- package/lib/cjs/webgl-context-attributes.js +0 -24
- package/lib/cjs/webgl-drawing-buffer-wrapper.js +0 -10
- package/lib/cjs/webgl-framebuffer.js +0 -109
- package/lib/cjs/webgl-program.js +0 -26
- package/lib/cjs/webgl-renderbuffer.js +0 -24
- package/lib/cjs/webgl-rendering-context.js +0 -3343
- package/lib/cjs/webgl-shader-precision-format.js +0 -11
- package/lib/cjs/webgl-shader.js +0 -23
- package/lib/cjs/webgl-texture-unit.js +0 -12
- package/lib/cjs/webgl-texture.js +0 -22
- package/lib/cjs/webgl-uniform-location.js +0 -15
- package/lib/cjs/webgl-vertex-attribute.js +0 -147
- package/meson.build +0 -39
- package/src/test/app.vala +0 -60
- package/src/ts/@types/glsl-tokenizer/index.d.ts +0 -18
- package/src/ts/extensions/angle-instanced-arrays.ts.off +0 -232
- package/src/ts/extensions/ext-blend-minmax.ts +0 -18
- package/src/ts/extensions/ext-texture-filter-anisotropic.ts +0 -18
- package/src/ts/extensions/oes-element-index-unit.ts +0 -14
- package/src/ts/extensions/oes-standard-derivatives.ts +0 -17
- package/src/ts/extensions/oes-texture-float-linear.ts +0 -14
- package/src/ts/extensions/oes-texture-float.ts +0 -14
- package/src/ts/extensions/oes-vertex-array-object.ts.off +0 -128
- package/src/ts/extensions/stackgl-destroy-context.ts +0 -12
- package/src/ts/extensions/stackgl-resize-drawing-buffer.ts +0 -14
- package/src/ts/extensions/webgl-draw-buffers.ts.off +0 -107
- package/src/ts/html-canvas-element.ts +0 -98
- package/src/ts/index.spec.ts +0 -186
- package/src/ts/index.ts +0 -21
- package/src/ts/linkable.ts +0 -55
- package/src/ts/test.ts +0 -6
- package/src/ts/types/constructor.ts +0 -3
- package/src/ts/types/extension.ts +0 -3
- package/src/ts/types/index.ts +0 -26
- package/src/ts/types/typed-array.ts +0 -1
- package/src/ts/types/webgl-constants.ts +0 -300
- package/src/ts/types/webgl-context-attribute-options.ts +0 -12
- package/src/ts/utils.ts +0 -266
- package/src/ts/webgl-active-info.ts +0 -13
- package/src/ts/webgl-buffer.ts +0 -21
- package/src/ts/webgl-context-attributes.ts +0 -24
- package/src/ts/webgl-drawing-buffer-wrapper.ts +0 -10
- package/src/ts/webgl-framebuffer.ts +0 -133
- package/src/ts/webgl-program.ts +0 -30
- package/src/ts/webgl-renderbuffer.ts +0 -28
- package/src/ts/webgl-rendering-context.ts +0 -4050
- package/src/ts/webgl-shader-precision-format.ts +0 -12
- package/src/ts/webgl-shader.ts +0 -29
- package/src/ts/webgl-texture-unit.ts +0 -16
- package/src/ts/webgl-texture.ts +0 -27
- package/src/ts/webgl-uniform-location.ts +0 -18
- package/src/ts/webgl-vertex-attribute.ts +0 -169
- package/src/vala/handle-types.vala +0 -23
- package/src/vala/webgl-rendering-context-base.vala +0 -1265
- package/src/vala/webgl-rendering-context.vala +0 -265
- package/src/vapi/epoxy.vapi +0 -14558
- package/src/vapi/glesv2.vapi +0 -670
- package/test.gjs.js +0 -39937
- package/test.gjs.js.meta.json +0 -1
- package/tmp/.tsbuildinfo +0 -1
- package/tsconfig.json +0 -38
- package/tsconfig.types.json +0 -7
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { Linkable } from '../linkable.js'
|
|
2
|
-
import { gl } from '../native-gl.js'
|
|
3
|
-
import { checkObject } from '../utils.js'
|
|
4
|
-
import { WebGLVertexArrayObjectState } from '../webgl-vertex-attribute.js';
|
|
5
|
-
|
|
6
|
-
import type { GjsifyWebGLRenderingContext } from '../webgl-rendering-context.js';
|
|
7
|
-
|
|
8
|
-
export class WebGLVertexArrayObjectOES extends Linkable {
|
|
9
|
-
_ctx: GjsifyWebGLRenderingContext;
|
|
10
|
-
_ext: OESVertexArrayObject;
|
|
11
|
-
_vertexState?: WebGLVertexArrayObjectState;
|
|
12
|
-
constructor (_: number, ctx: GjsifyWebGLRenderingContext, ext: OESVertexArrayObject) {
|
|
13
|
-
super(_)
|
|
14
|
-
this._ctx = ctx
|
|
15
|
-
this._ext = ext
|
|
16
|
-
this._vertexState = new WebGLVertexArrayObjectState(ctx)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_performDelete () {
|
|
20
|
-
// Clean up the vertex state to release references to buffers.
|
|
21
|
-
this._vertexState?.cleanUp()
|
|
22
|
-
|
|
23
|
-
delete this._vertexState;
|
|
24
|
-
delete this._ext._vaos[this._]
|
|
25
|
-
gl.deleteVertexArrayOES.call(this._ctx, this._ | 0)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class OESVertexArrayObject {
|
|
30
|
-
VERTEX_ARRAY_BINDING_OES = 0x85B5;
|
|
31
|
-
_ctx: GjsifyWebGLRenderingContext;
|
|
32
|
-
_vaos: Record<number, WebGLVertexArrayObjectOES> = {}
|
|
33
|
-
_activeVertexArrayObject: WebGLVertexArrayObjectOES | null = null
|
|
34
|
-
|
|
35
|
-
constructor (ctx: GjsifyWebGLRenderingContext) {
|
|
36
|
-
this.VERTEX_ARRAY_BINDING_OES = 0x85B5
|
|
37
|
-
|
|
38
|
-
this._ctx = ctx
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
createVertexArrayOES () {
|
|
42
|
-
const { _ctx: ctx } = this
|
|
43
|
-
const arrayId = gl.createVertexArrayOES.call(ctx)
|
|
44
|
-
if (arrayId <= 0) return null
|
|
45
|
-
const array = new WebGLVertexArrayObjectOES(arrayId, ctx, this)
|
|
46
|
-
this._vaos[arrayId] = array
|
|
47
|
-
return array
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
deleteVertexArrayOES (array: WebGLVertexArrayObjectOES | null) {
|
|
51
|
-
const { _ctx: ctx } = this
|
|
52
|
-
if (!checkObject(array)) {
|
|
53
|
-
throw new TypeError('deleteVertexArrayOES(WebGLVertexArrayObjectOES)')
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!(array instanceof WebGLVertexArrayObjectOES &&
|
|
57
|
-
ctx._checkOwns(array))) {
|
|
58
|
-
ctx.setError(gl.INVALID_OPERATION)
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (array._pendingDelete) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (this._activeVertexArrayObject === array) {
|
|
67
|
-
this.bindVertexArrayOES(null)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
array._pendingDelete = true
|
|
71
|
-
array._checkDelete()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
bindVertexArrayOES (array: WebGLVertexArrayObjectOES | null) {
|
|
75
|
-
const { _ctx: ctx, _activeVertexArrayObject: activeVertexArrayObject } = this
|
|
76
|
-
if (!checkObject(array)) {
|
|
77
|
-
throw new TypeError('bindVertexArrayOES(WebGLVertexArrayObjectOES)')
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!array) {
|
|
81
|
-
array = null
|
|
82
|
-
gl.bindVertexArrayOES.call(ctx, null)
|
|
83
|
-
} else if (array instanceof WebGLVertexArrayObjectOES &&
|
|
84
|
-
array._pendingDelete) {
|
|
85
|
-
ctx.setError(gl.INVALID_OPERATION)
|
|
86
|
-
return
|
|
87
|
-
} else if (ctx._checkWrapper(array, WebGLVertexArrayObjectOES)) {
|
|
88
|
-
gl.bindVertexArrayOES.call(ctx, array._)
|
|
89
|
-
} else {
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (activeVertexArrayObject !== array) {
|
|
94
|
-
if (activeVertexArrayObject) {
|
|
95
|
-
activeVertexArrayObject._refCount -= 1
|
|
96
|
-
activeVertexArrayObject._checkDelete()
|
|
97
|
-
}
|
|
98
|
-
if (array) {
|
|
99
|
-
array._refCount += 1
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (array === null) {
|
|
104
|
-
ctx._vertexObjectState = ctx._defaultVertexObjectState
|
|
105
|
-
} else if(array._vertexState) {
|
|
106
|
-
ctx._vertexObjectState = array._vertexState
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Update the active vertex array object.
|
|
110
|
-
this._activeVertexArrayObject = array
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
isVertexArrayOES (object: WebGLVertexArrayObjectOES) {
|
|
114
|
-
const { _ctx: ctx } = this
|
|
115
|
-
if (!ctx._isObject(object, 'isVertexArrayOES', WebGLVertexArrayObjectOES)) return false
|
|
116
|
-
return gl.isVertexArrayOES.call(ctx, object._ | 0)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function getOESVertexArrayObject (ctx: GjsifyWebGLRenderingContext) {
|
|
121
|
-
const exts = ctx.getSupportedExtensions()
|
|
122
|
-
|
|
123
|
-
if (exts && exts.indexOf('OES_vertex_array_object') >= 0) {
|
|
124
|
-
return new OESVertexArrayObject(ctx)
|
|
125
|
-
} else {
|
|
126
|
-
return null
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { GjsifyWebGLRenderingContext } from '../webgl-rendering-context.js';
|
|
2
|
-
|
|
3
|
-
export class STACKGLDestroyContext {
|
|
4
|
-
destroy: () => void;
|
|
5
|
-
constructor (ctx: GjsifyWebGLRenderingContext) {
|
|
6
|
-
this.destroy = ctx.destroy.bind(ctx)
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getSTACKGLDestroyContext (ctx: GjsifyWebGLRenderingContext) {
|
|
11
|
-
return new STACKGLDestroyContext(ctx)
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GjsifyWebGLRenderingContext } from '../webgl-rendering-context.js';
|
|
2
|
-
|
|
3
|
-
export class STACKGLResizeDrawingBuffer {
|
|
4
|
-
|
|
5
|
-
resize: (width: number, height: number) => void;
|
|
6
|
-
|
|
7
|
-
constructor (ctx: GjsifyWebGLRenderingContext) {
|
|
8
|
-
this.resize = ctx.resize.bind(ctx)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getSTACKGLResizeDrawingBuffer (ctx: GjsifyWebGLRenderingContext) {
|
|
13
|
-
return new STACKGLResizeDrawingBuffer(ctx)
|
|
14
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { gl } from '../native-gl.js';
|
|
2
|
-
import type { GjsifyWebGLRenderingContext } from '../webgl-rendering-context.js';
|
|
3
|
-
|
|
4
|
-
export class WebGLDrawBuffers {
|
|
5
|
-
ctx: GjsifyWebGLRenderingContext;
|
|
6
|
-
_buffersState: number[] = [];
|
|
7
|
-
_maxDrawBuffers = 0;
|
|
8
|
-
_ALL_ATTACHMENTS: GLenum[] = []
|
|
9
|
-
_ALL_COLOR_ATTACHMENTS: GLenum[] = []
|
|
10
|
-
|
|
11
|
-
MAX_DRAW_BUFFERS_WEBGL = 0;
|
|
12
|
-
COLOR_ATTACHMENT0_WEBGL = 0;
|
|
13
|
-
COLOR_ATTACHMENT1_WEBGL = 0;
|
|
14
|
-
COLOR_ATTACHMENT2_WEBGL = 0;
|
|
15
|
-
COLOR_ATTACHMENT3_WEBGL = 0;
|
|
16
|
-
COLOR_ATTACHMENT4_WEBGL = 0;
|
|
17
|
-
COLOR_ATTACHMENT5_WEBGL = 0;
|
|
18
|
-
COLOR_ATTACHMENT6_WEBGL = 0;
|
|
19
|
-
COLOR_ATTACHMENT7_WEBGL = 0;
|
|
20
|
-
COLOR_ATTACHMENT8_WEBGL = 0;
|
|
21
|
-
COLOR_ATTACHMENT9_WEBGL = 0;
|
|
22
|
-
COLOR_ATTACHMENT10_WEBGL = 0;
|
|
23
|
-
COLOR_ATTACHMENT11_WEBGL = 0;
|
|
24
|
-
COLOR_ATTACHMENT12_WEBGL = 0;
|
|
25
|
-
COLOR_ATTACHMENT13_WEBGL = 0;
|
|
26
|
-
COLOR_ATTACHMENT14_WEBGL = 0;
|
|
27
|
-
COLOR_ATTACHMENT15_WEBGL = 0;
|
|
28
|
-
|
|
29
|
-
constructor (ctx: GjsifyWebGLRenderingContext) {
|
|
30
|
-
this.ctx = ctx
|
|
31
|
-
const exts = ctx.getSupportedExtensions()
|
|
32
|
-
|
|
33
|
-
if (exts && exts.indexOf('WEBGL_draw_buffers') >= 0) {
|
|
34
|
-
Object.assign(this, ctx.extWEBGL_draw_buffers())
|
|
35
|
-
this._buffersState = [ctx.BACK]
|
|
36
|
-
this._maxDrawBuffers = ctx._getParameterDirect(this.MAX_DRAW_BUFFERS_WEBGL) as number;
|
|
37
|
-
this._ALL_ATTACHMENTS = []
|
|
38
|
-
this._ALL_COLOR_ATTACHMENTS = []
|
|
39
|
-
const allColorAttachments = [
|
|
40
|
-
this.COLOR_ATTACHMENT0_WEBGL,
|
|
41
|
-
this.COLOR_ATTACHMENT1_WEBGL,
|
|
42
|
-
this.COLOR_ATTACHMENT2_WEBGL,
|
|
43
|
-
this.COLOR_ATTACHMENT3_WEBGL,
|
|
44
|
-
this.COLOR_ATTACHMENT4_WEBGL,
|
|
45
|
-
this.COLOR_ATTACHMENT5_WEBGL,
|
|
46
|
-
this.COLOR_ATTACHMENT6_WEBGL,
|
|
47
|
-
this.COLOR_ATTACHMENT7_WEBGL,
|
|
48
|
-
this.COLOR_ATTACHMENT8_WEBGL,
|
|
49
|
-
this.COLOR_ATTACHMENT9_WEBGL,
|
|
50
|
-
this.COLOR_ATTACHMENT10_WEBGL,
|
|
51
|
-
this.COLOR_ATTACHMENT11_WEBGL,
|
|
52
|
-
this.COLOR_ATTACHMENT12_WEBGL,
|
|
53
|
-
this.COLOR_ATTACHMENT13_WEBGL,
|
|
54
|
-
this.COLOR_ATTACHMENT14_WEBGL,
|
|
55
|
-
this.COLOR_ATTACHMENT15_WEBGL
|
|
56
|
-
]
|
|
57
|
-
while (this._ALL_ATTACHMENTS.length < this._maxDrawBuffers) {
|
|
58
|
-
const colorAttachment = allColorAttachments.shift()
|
|
59
|
-
if(colorAttachment) {
|
|
60
|
-
this._ALL_ATTACHMENTS.push(colorAttachment)
|
|
61
|
-
this._ALL_COLOR_ATTACHMENTS.push(colorAttachment)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
this._ALL_ATTACHMENTS.push(
|
|
65
|
-
gl.DEPTH_ATTACHMENT,
|
|
66
|
-
gl.STENCIL_ATTACHMENT,
|
|
67
|
-
gl.DEPTH_STENCIL_ATTACHMENT
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
drawBuffersWEBGL (buffers: GLenum[]) {
|
|
73
|
-
const { ctx } = this
|
|
74
|
-
if (buffers.length < 1) {
|
|
75
|
-
ctx.setError(gl.INVALID_OPERATION)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
if (buffers.length === 1 && buffers[0] === gl.BACK) {
|
|
79
|
-
this._buffersState = buffers
|
|
80
|
-
ctx.drawBuffersWEBGL([this.COLOR_ATTACHMENT0_WEBGL])
|
|
81
|
-
return
|
|
82
|
-
} else if (!ctx._activeFramebuffer) {
|
|
83
|
-
if (buffers.length > 1) {
|
|
84
|
-
ctx.setError(gl.INVALID_OPERATION)
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
for (let i = 0; i < buffers.length; i++) {
|
|
88
|
-
if (buffers[i] > gl.NONE) {
|
|
89
|
-
ctx.setError(gl.INVALID_OPERATION)
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
this._buffersState = buffers
|
|
95
|
-
ctx.drawBuffersWEBGL(buffers)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function getWebGLDrawBuffers (ctx: GjsifyWebGLRenderingContext) {
|
|
100
|
-
const exts = ctx.getSupportedExtensions()
|
|
101
|
-
|
|
102
|
-
if (exts && exts.indexOf('WEBGL_draw_buffers') >= 0) {
|
|
103
|
-
return new WebGLDrawBuffers(ctx)
|
|
104
|
-
} else {
|
|
105
|
-
return null
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { warnNotImplemented, notImplemented } from '@gjsify/utils'
|
|
2
|
-
import Gtk from 'gi://Gtk?version=4.0';
|
|
3
|
-
import { GjsifyWebGLRenderingContext } from './webgl-rendering-context.js';
|
|
4
|
-
|
|
5
|
-
// TODO this fakes the implementation of HTMLCanvasElement, create a new package for a real implementation based on https://github.com/capricorn86/happy-dom/tree/master/packages/happy-dom/src/nodes/html-element
|
|
6
|
-
export interface GjsifyHTMLCanvasElement extends HTMLCanvasElement {}
|
|
7
|
-
|
|
8
|
-
export class GjsifyHTMLCanvasElement implements HTMLCanvasElement {
|
|
9
|
-
|
|
10
|
-
_webgl?: WebGLRenderingContext & GjsifyWebGLRenderingContext
|
|
11
|
-
|
|
12
|
-
_getGlArea() {
|
|
13
|
-
return this.gtkGlArea;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
constructor(protected readonly gtkGlArea: Gtk.GLArea) {
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Gets the height of a canvas element on a document. */
|
|
21
|
-
get height() {
|
|
22
|
-
return this.gtkGlArea.get_allocated_height()
|
|
23
|
-
// return this.gtkGlArea.get_height()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get clientHeight() {
|
|
27
|
-
return this.height;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Sets the height of a canvas element on a document. */
|
|
31
|
-
set height(_height: number) {
|
|
32
|
-
warnNotImplemented('GjsifyHTMLCanvasElement.set_height');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Gets the width of a canvas element on a document. */
|
|
36
|
-
get width() {
|
|
37
|
-
return this.gtkGlArea.get_allocated_width()
|
|
38
|
-
// return this.gtkGlArea.get_width()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Sets the width of a canvas element on a document. */
|
|
42
|
-
set width(_width: number) {
|
|
43
|
-
warnNotImplemented('GjsifyHTMLCanvasElement.set_width');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get clientWidth() {
|
|
47
|
-
return this.width;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
captureStream(_frameRequestRate?: number): MediaStream {
|
|
51
|
-
notImplemented('HTMLCanvasElement.captureStream');
|
|
52
|
-
return new MediaStream();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
|
|
57
|
-
* @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl");
|
|
58
|
-
*/
|
|
59
|
-
getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null;
|
|
60
|
-
getContext(contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null;
|
|
61
|
-
getContext(contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext & GjsifyWebGLRenderingContext | null;
|
|
62
|
-
getContext(contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null;
|
|
63
|
-
getContext(contextId: string, options?: any): RenderingContext | null {
|
|
64
|
-
switch (contextId) {
|
|
65
|
-
case "webgl":
|
|
66
|
-
if(this._webgl) {
|
|
67
|
-
return this._webgl;
|
|
68
|
-
}
|
|
69
|
-
this._webgl = new GjsifyWebGLRenderingContext(this, options) as WebGLRenderingContext & GjsifyWebGLRenderingContext;
|
|
70
|
-
return this._webgl;
|
|
71
|
-
default:
|
|
72
|
-
warnNotImplemented(`GjsifyHTMLCanvasElement.getContext("${contextId}")`);
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
toBlob(_callback: BlobCallback, _type?: string, _quality?: any): void {
|
|
78
|
-
notImplemented('HTMLCanvasElement.toBlob');
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element.
|
|
82
|
-
* @param _type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
|
|
83
|
-
*/
|
|
84
|
-
toDataURL(_type?: string, _quality?: any): string {
|
|
85
|
-
notImplemented('HTMLCanvasElement.toDataURL');
|
|
86
|
-
return '';
|
|
87
|
-
}
|
|
88
|
-
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
89
|
-
addEventListener(_type: string, _listener: EventListenerOrEventListenerObject, _options?: boolean | AddEventListenerOptions): void {
|
|
90
|
-
notImplemented('HTMLCanvasElement.addEventListener');
|
|
91
|
-
}
|
|
92
|
-
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
93
|
-
removeEventListener(_type: string, _listener: EventListenerOrEventListenerObject, _options?: boolean | EventListenerOptions): void {
|
|
94
|
-
notImplemented('HTMLCanvasElement.removeEventListener');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { GjsifyHTMLCanvasElement as HTMLCanvasElement }
|
package/src/ts/index.spec.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@gjsify/unit';
|
|
2
|
-
|
|
3
|
-
import { GjsifyWebGLRenderingContext, HTMLCanvasElement } from '@gjsify/webgl';
|
|
4
|
-
import GLib from '@girs/glib-2.0';
|
|
5
|
-
import Gtk from '@girs/gtk-4.0';
|
|
6
|
-
import Gio from '@girs/gio-2.0';
|
|
7
|
-
|
|
8
|
-
const GL_CONSTANT_NAMES = ['ACTIVE_ATTRIBUTES', 'ACTIVE_TEXTURE', 'ACTIVE_UNIFORMS', 'ALIASED_LINE_WIDTH_RANGE', 'ALIASED_POINT_SIZE_RANGE', 'ALPHA', 'ALPHA_BITS', 'ALWAYS', 'ARRAY_BUFFER', 'ARRAY_BUFFER_BINDING', 'ATTACHED_SHADERS', 'BACK', 'BLEND', 'BLEND_COLOR', 'BLEND_DST_ALPHA', 'BLEND_DST_RGB', 'BLEND_EQUATION', 'BLEND_EQUATION_ALPHA', 'BLEND_EQUATION_RGB', 'BLEND_SRC_ALPHA', 'BLEND_SRC_RGB', 'BLUE_BITS', 'BOOL', 'BOOL_VEC2', 'BOOL_VEC3', 'BOOL_VEC4', 'BROWSER_DEFAULT_WEBGL', 'BUFFER_SIZE', 'BUFFER_USAGE', 'BYTE', 'CCW', 'CLAMP_TO_EDGE', 'COLOR_ATTACHMENT0', 'COLOR_BUFFER_BIT', 'COLOR_CLEAR_VALUE', 'COLOR_WRITEMASK', 'COMPILE_STATUS', 'COMPRESSED_TEXTURE_FORMATS', 'CONSTANT_ALPHA', 'CONSTANT_COLOR', 'CONTEXT_LOST_WEBGL', 'CULL_FACE', 'CULL_FACE_MODE', 'CURRENT_PROGRAM', 'CURRENT_VERTEX_ATTRIB', 'CW', 'DECR', 'DECR_WRAP', 'DELETE_STATUS', 'DEPTH_ATTACHMENT', 'DEPTH_BITS', 'DEPTH_BUFFER_BIT', 'DEPTH_CLEAR_VALUE', 'DEPTH_COMPONENT', 'DEPTH_COMPONENT16', 'DEPTH_FUNC', 'DEPTH_RANGE', 'DEPTH_STENCIL', 'DEPTH_STENCIL_ATTACHMENT', 'DEPTH_TEST', 'DEPTH_WRITEMASK', 'DITHER', 'DONT_CARE', 'DST_ALPHA', 'DST_COLOR', 'DYNAMIC_DRAW', 'ELEMENT_ARRAY_BUFFER', 'ELEMENT_ARRAY_BUFFER_BINDING', 'EQUAL', 'FASTEST', 'FLOAT', 'FLOAT_MAT2', 'FLOAT_MAT3', 'FLOAT_MAT4', 'FLOAT_VEC2', 'FLOAT_VEC3', 'FLOAT_VEC4', 'FRAGMENT_SHADER', 'FRAMEBUFFER', 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', 'FRAMEBUFFER_BINDING', 'FRAMEBUFFER_COMPLETE', 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', 'FRAMEBUFFER_UNSUPPORTED', 'FRONT', 'FRONT_AND_BACK', 'FRONT_FACE', 'FUNC_ADD', 'FUNC_REVERSE_SUBTRACT', 'FUNC_SUBTRACT', 'GENERATE_MIPMAP_HINT', 'GEQUAL', 'GREATER', 'GREEN_BITS', 'HIGH_FLOAT', 'HIGH_INT', 'IMPLEMENTATION_COLOR_READ_FORMAT', 'IMPLEMENTATION_COLOR_READ_TYPE', 'INCR', 'INCR_WRAP', 'INT', 'INT_VEC2', 'INT_VEC3', 'INT_VEC4', 'INVALID_ENUM', 'INVALID_FRAMEBUFFER_OPERATION', 'INVALID_OPERATION', 'INVALID_VALUE', 'INVERT', 'KEEP', 'LEQUAL', 'LESS', 'LINEAR', 'LINEAR_MIPMAP_LINEAR', 'LINEAR_MIPMAP_NEAREST', 'LINES', 'LINE_LOOP', 'LINE_STRIP', 'LINE_WIDTH', 'LINK_STATUS', 'LOW_FLOAT', 'LOW_INT', 'LUMINANCE', 'LUMINANCE_ALPHA', 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', 'MAX_CUBE_MAP_TEXTURE_SIZE', 'MAX_FRAGMENT_UNIFORM_VECTORS', 'MAX_RENDERBUFFER_SIZE', 'MAX_TEXTURE_IMAGE_UNITS', 'MAX_TEXTURE_SIZE', 'MAX_VARYING_VECTORS', 'MAX_VERTEX_ATTRIBS', 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', 'MAX_VERTEX_UNIFORM_VECTORS', 'MAX_VIEWPORT_DIMS', 'MEDIUM_FLOAT', 'MEDIUM_INT', 'MIRRORED_REPEAT', 'NEAREST', 'NEAREST_MIPMAP_LINEAR', 'NEAREST_MIPMAP_NEAREST', 'NEVER', 'NICEST', 'NONE', 'NOTEQUAL', 'NO_ERROR', 'ONE', 'ONE_MINUS_CONSTANT_ALPHA', 'ONE_MINUS_CONSTANT_COLOR', 'ONE_MINUS_DST_ALPHA', 'ONE_MINUS_DST_COLOR', 'ONE_MINUS_SRC_ALPHA', 'ONE_MINUS_SRC_COLOR', 'OUT_OF_MEMORY', 'PACK_ALIGNMENT', 'POINTS', 'POLYGON_OFFSET_FACTOR', 'POLYGON_OFFSET_FILL', 'POLYGON_OFFSET_UNITS', 'RED_BITS', 'RENDERBUFFER', 'RENDERBUFFER_ALPHA_SIZE', 'RENDERBUFFER_BINDING', 'RENDERBUFFER_BLUE_SIZE', 'RENDERBUFFER_DEPTH_SIZE', 'RENDERBUFFER_GREEN_SIZE', 'RENDERBUFFER_HEIGHT', 'RENDERBUFFER_INTERNAL_FORMAT', 'RENDERBUFFER_RED_SIZE', 'RENDERBUFFER_STENCIL_SIZE', 'RENDERBUFFER_WIDTH', 'RENDERER', 'REPEAT', 'REPLACE', 'RGB', 'RGB565', 'RGB5_A1', 'RGBA', 'RGBA4', 'SAMPLER_2D', 'SAMPLER_CUBE', 'SAMPLES', 'SAMPLE_ALPHA_TO_COVERAGE', 'SAMPLE_BUFFERS', 'SAMPLE_COVERAGE', 'SAMPLE_COVERAGE_INVERT', 'SAMPLE_COVERAGE_VALUE', 'SCISSOR_BOX', 'SCISSOR_TEST', 'SHADER_TYPE', 'SHADING_LANGUAGE_VERSION', 'SHORT', 'SRC_ALPHA', 'SRC_ALPHA_SATURATE', 'SRC_COLOR', 'STATIC_DRAW', 'STENCIL_ATTACHMENT', 'STENCIL_BACK_FAIL', 'STENCIL_BACK_FUNC', 'STENCIL_BACK_PASS_DEPTH_FAIL', 'STENCIL_BACK_PASS_DEPTH_PASS', 'STENCIL_BACK_REF', 'STENCIL_BACK_VALUE_MASK', 'STENCIL_BACK_WRITEMASK', 'STENCIL_BITS', 'STENCIL_BUFFER_BIT', 'STENCIL_CLEAR_VALUE', 'STENCIL_FAIL', 'STENCIL_FUNC', 'STENCIL_INDEX8', 'STENCIL_PASS_DEPTH_FAIL', 'STENCIL_PASS_DEPTH_PASS', 'STENCIL_REF', 'STENCIL_TEST', 'STENCIL_VALUE_MASK', 'STENCIL_WRITEMASK', 'STREAM_DRAW', 'SUBPIXEL_BITS', 'TEXTURE', 'TEXTURE0', 'TEXTURE1', 'TEXTURE10', 'TEXTURE11', 'TEXTURE12', 'TEXTURE13', 'TEXTURE14', 'TEXTURE15', 'TEXTURE16', 'TEXTURE17', 'TEXTURE18', 'TEXTURE19', 'TEXTURE2', 'TEXTURE20', 'TEXTURE21', 'TEXTURE22', 'TEXTURE23', 'TEXTURE24', 'TEXTURE25', 'TEXTURE26', 'TEXTURE27', 'TEXTURE28', 'TEXTURE29', 'TEXTURE3', 'TEXTURE30', 'TEXTURE31', 'TEXTURE4', 'TEXTURE5', 'TEXTURE6', 'TEXTURE7', 'TEXTURE8', 'TEXTURE9', 'TEXTURE_2D', 'TEXTURE_BINDING_2D', 'TEXTURE_BINDING_CUBE_MAP', 'TEXTURE_CUBE_MAP', 'TEXTURE_CUBE_MAP_NEGATIVE_X', 'TEXTURE_CUBE_MAP_NEGATIVE_Y', 'TEXTURE_CUBE_MAP_NEGATIVE_Z', 'TEXTURE_CUBE_MAP_POSITIVE_X', 'TEXTURE_CUBE_MAP_POSITIVE_Y', 'TEXTURE_CUBE_MAP_POSITIVE_Z', 'TEXTURE_MAG_FILTER', 'TEXTURE_MIN_FILTER', 'TEXTURE_WRAP_S', 'TEXTURE_WRAP_T', 'TRIANGLES', 'TRIANGLE_FAN', 'TRIANGLE_STRIP', 'UNPACK_ALIGNMENT', 'UNPACK_COLORSPACE_CONVERSION_WEBGL', 'UNPACK_FLIP_Y_WEBGL', 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', 'UNSIGNED_BYTE', 'UNSIGNED_INT', 'UNSIGNED_SHORT', 'UNSIGNED_SHORT_4_4_4_4', 'UNSIGNED_SHORT_5_5_5_1', 'UNSIGNED_SHORT_5_6_5', 'VALIDATE_STATUS', 'VENDOR', 'VERSION', 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', 'VERTEX_ATTRIB_ARRAY_ENABLED', 'VERTEX_ATTRIB_ARRAY_NORMALIZED', 'VERTEX_ATTRIB_ARRAY_POINTER', 'VERTEX_ATTRIB_ARRAY_SIZE', 'VERTEX_ATTRIB_ARRAY_STRIDE', 'VERTEX_ATTRIB_ARRAY_TYPE', 'VERTEX_SHADER', 'VIEWPORT', 'ZERO'];
|
|
9
|
-
|
|
10
|
-
export default async () => {
|
|
11
|
-
|
|
12
|
-
let app: Gtk.Application;
|
|
13
|
-
let win: Gtk.ApplicationWindow;
|
|
14
|
-
let glArea: Gtk.GLArea;
|
|
15
|
-
let canvas: HTMLCanvasElement;
|
|
16
|
-
let ctx: GjsifyWebGLRenderingContext | null;
|
|
17
|
-
|
|
18
|
-
// Skip tests on CI
|
|
19
|
-
if(GLib.getenv('CI') || GLib.getenv('GITHUB_ACTIONS') || GLib.getenv('TRAVIS') || GLib.getenv('CIRCLECI') || GLib.getenv('GITLAB_CI')) {
|
|
20
|
-
console.info('Skipping webgl tests on CI');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const initApp = async () => {
|
|
25
|
-
Gtk.init();
|
|
26
|
-
|
|
27
|
-
app = new Gtk.Application({
|
|
28
|
-
application_id: 'gjsify.webgl.index.spec.ts',
|
|
29
|
-
flags: Gio.ApplicationFlags.FLAGS_NONE,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const p = new Promise<Gtk.Application>((resolve) => {
|
|
33
|
-
app.connect('activate', () => {
|
|
34
|
-
resolve(app);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
win = new Gtk.ApplicationWindow(app);
|
|
39
|
-
win.set_default_size(800, 600);
|
|
40
|
-
|
|
41
|
-
app.run([]);
|
|
42
|
-
|
|
43
|
-
return p;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const initGLArea = async () => {
|
|
47
|
-
glArea = new Gtk.GLArea({});
|
|
48
|
-
|
|
49
|
-
const p = new Promise<Gtk.GLArea>((resolve, reject) => {
|
|
50
|
-
glArea.connect('realize', () => {
|
|
51
|
-
glArea.make_current();
|
|
52
|
-
const error = glArea.get_error();
|
|
53
|
-
if (error) {
|
|
54
|
-
reject(error);
|
|
55
|
-
}
|
|
56
|
-
resolve(glArea);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
glArea.set_use_es(true);
|
|
61
|
-
glArea.set_has_depth_buffer(true);
|
|
62
|
-
glArea.set_has_stencil_buffer(true);
|
|
63
|
-
glArea.set_required_version(3, 2);
|
|
64
|
-
|
|
65
|
-
win.set_child(glArea);
|
|
66
|
-
win.present();
|
|
67
|
-
|
|
68
|
-
return p;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await describe('Gtk.ApplicationWindow', async () => {
|
|
72
|
-
await it('should be able to create a new instance', async () => {
|
|
73
|
-
app = await initApp();
|
|
74
|
-
expect(app).toBeDefined();
|
|
75
|
-
});
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
await describe('Gtk.GLArea', async () => {
|
|
79
|
-
await it('should be able to create a new instance', async () => {
|
|
80
|
-
glArea = await initGLArea();
|
|
81
|
-
expect(glArea).toBeDefined();
|
|
82
|
-
});
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
await describe('HTMLCanvasElement', async () => {
|
|
86
|
-
await it('should be defined', async () => {
|
|
87
|
-
expect(HTMLCanvasElement).toBeDefined();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
await it('should be able to create a new instance', async () => {
|
|
91
|
-
|
|
92
|
-
expect(() => {
|
|
93
|
-
canvas = new HTMLCanvasElement(glArea);
|
|
94
|
-
}).not.toThrow();
|
|
95
|
-
|
|
96
|
-
expect(canvas).toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
await it('should be able to get a webgl context', async () => {
|
|
100
|
-
expect(() => {
|
|
101
|
-
ctx = canvas.getContext("webgl");
|
|
102
|
-
}).not.toThrow();
|
|
103
|
-
|
|
104
|
-
expect(ctx).toBeDefined();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
await describe('WebGLRenderingContext', async () => {
|
|
109
|
-
await it('should have defined WebGL constants', async () => {
|
|
110
|
-
|
|
111
|
-
for (const GL_CONSTANT_NAME of GL_CONSTANT_NAMES) {
|
|
112
|
-
const constant = ctx?.[GL_CONSTANT_NAME];
|
|
113
|
-
console.log(GL_CONSTANT_NAME, constant)
|
|
114
|
-
expect(typeof constant).toBe("number");
|
|
115
|
-
if(GL_CONSTANT_NAME === 'NONE' || GL_CONSTANT_NAME === 'ZERO' || GL_CONSTANT_NAME === 'NO_ERROR' || GL_CONSTANT_NAME === 'POINTS') {
|
|
116
|
-
expect(constant === 0).toBeTruthy();
|
|
117
|
-
} else {
|
|
118
|
-
expect(constant > 0).toBeTruthy();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await describe('Gwebgl.WebGLRenderingContext', async () => {
|
|
125
|
-
await it('getParameterb should return a boolean', async () => {
|
|
126
|
-
const res = ctx?._native.getParameterb(ctx?.BLEND)
|
|
127
|
-
console.log("res", res);
|
|
128
|
-
expect(typeof res).toBe("boolean");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await it('getParameterbv should return an array of boolean', async () => {
|
|
132
|
-
const results = ctx?._native.getParameterbv(ctx?.COLOR_WRITEMASK, 16)
|
|
133
|
-
console.log("results", results);
|
|
134
|
-
|
|
135
|
-
expect(Array.isArray(results)).toBeTruthy();
|
|
136
|
-
|
|
137
|
-
if(Array.isArray(results)) {
|
|
138
|
-
for (const res of results) {
|
|
139
|
-
expect(typeof res).toBe("boolean");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
await it('getParameterf should return a float number', async () => {
|
|
145
|
-
const result = ctx?._native.getParameterf(ctx?.SAMPLE_COVERAGE_VALUE)
|
|
146
|
-
console.log("result", result);
|
|
147
|
-
|
|
148
|
-
expect(typeof result).toBe("number");
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await it('getParameterfv should return an array of float numbers', async () => {
|
|
152
|
-
const results = ctx?._native.getParameterfv(ctx?.DEPTH_RANGE, 8)
|
|
153
|
-
console.log("results", results);
|
|
154
|
-
|
|
155
|
-
expect(Array.isArray(results)).toBeTruthy();
|
|
156
|
-
|
|
157
|
-
if(Array.isArray(results)) {
|
|
158
|
-
for (const res of results) {
|
|
159
|
-
expect(typeof res).toBe("number");
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
await it('getParameteri should return a integer number', async () => {
|
|
165
|
-
const result = ctx?._native.getParameteri(ctx?.ARRAY_BUFFER_BINDING)
|
|
166
|
-
console.log("result", result);
|
|
167
|
-
|
|
168
|
-
expect(typeof result).toBe("number");
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
await it('getParameteriv should return an array of integer numbers', async () => {
|
|
172
|
-
const results = ctx?._native.getParameteriv(ctx?.MAX_VIEWPORT_DIMS, 8)
|
|
173
|
-
console.log("results", results, typeof (results));
|
|
174
|
-
|
|
175
|
-
expect(Array.isArray(results)).toBeTruthy();
|
|
176
|
-
|
|
177
|
-
if(Array.isArray(results)) {
|
|
178
|
-
for (const res of results) {
|
|
179
|
-
expect(typeof res).toBe("number");
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
package/src/ts/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '@girs/gjs';
|
|
2
|
-
import '@girs/gio-2.0';
|
|
3
|
-
import '@girs/gtk-4.0';
|
|
4
|
-
|
|
5
|
-
export * from './html-canvas-element.js';
|
|
6
|
-
// export * from './linkable.js';
|
|
7
|
-
// export * from './utils.js';
|
|
8
|
-
export * from './webgl-active-info.js';
|
|
9
|
-
export * from './webgl-buffer.js';
|
|
10
|
-
export * from './webgl-context-attributes.js';
|
|
11
|
-
export * from './webgl-drawing-buffer-wrapper.js';
|
|
12
|
-
export * from './webgl-framebuffer.js';
|
|
13
|
-
export * from './webgl-program.js';
|
|
14
|
-
export * from './webgl-renderbuffer.js';
|
|
15
|
-
export * from './webgl-rendering-context.js';
|
|
16
|
-
export * from './webgl-shader-precision-format.js';
|
|
17
|
-
export * from './webgl-shader.js';
|
|
18
|
-
export * from './webgl-texture-unit.js';
|
|
19
|
-
export * from './webgl-texture.js';
|
|
20
|
-
export * from './webgl-uniform-location.js';
|
|
21
|
-
export * from './webgl-vertex-attribute.js';
|
package/src/ts/linkable.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export class Linkable {
|
|
2
|
-
|
|
3
|
-
_: number = 0;
|
|
4
|
-
_references: any[] = []
|
|
5
|
-
_refCount = 0
|
|
6
|
-
_pendingDelete = false
|
|
7
|
-
_binding = 0
|
|
8
|
-
|
|
9
|
-
constructor(_: number ) {
|
|
10
|
-
this._ = _
|
|
11
|
-
this._references = []
|
|
12
|
-
this._refCount = 0
|
|
13
|
-
this._pendingDelete = false
|
|
14
|
-
this._binding = 0
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
_link(b: any) {
|
|
18
|
-
this._references.push(b)
|
|
19
|
-
b._refCount += 1
|
|
20
|
-
return true
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_unlink(b: any) {
|
|
24
|
-
let idx = this._references.indexOf(b)
|
|
25
|
-
if (idx < 0) {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
while (idx >= 0) {
|
|
29
|
-
this._references[idx] = this._references[this._references.length - 1]
|
|
30
|
-
this._references.pop()
|
|
31
|
-
b._refCount -= 1
|
|
32
|
-
b._checkDelete()
|
|
33
|
-
idx = this._references.indexOf(b)
|
|
34
|
-
}
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
_linked(b: any) {
|
|
39
|
-
return this._references.indexOf(b) >= 0
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_checkDelete() {
|
|
43
|
-
if (this._refCount <= 0 &&
|
|
44
|
-
this._pendingDelete &&
|
|
45
|
-
this._ !== 0) {
|
|
46
|
-
while (this._references.length > 0) {
|
|
47
|
-
this._unlink(this._references[0])
|
|
48
|
-
}
|
|
49
|
-
this._performDelete()
|
|
50
|
-
this._ = 0
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_performDelete() { }
|
|
55
|
-
}
|
package/src/ts/test.ts
DELETED
package/src/ts/types/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export * from './constructor.js';
|
|
2
|
-
export * from './extension.js';
|
|
3
|
-
export * from './typed-array.js';
|
|
4
|
-
export * from './webgl-constants.js';
|
|
5
|
-
export * from './webgl-context-attribute-options.js';
|
|
6
|
-
|
|
7
|
-
// type GjsifyWebGLProgram = Gwebgl.WebGLProgram & WebGLProgram & number;
|
|
8
|
-
// type GjsifyWebGLShader = Gwebgl.WebGLShader & WebGLShader & number;
|
|
9
|
-
// type GjsifyWebGLBuffer = Gwebgl.WebGLBuffer & WebGLBuffer & number;
|
|
10
|
-
// type GjsifyWebGLRenderbuffer = Gwebgl.WebGLRenderbuffer & WebGLRenderbuffer & number;
|
|
11
|
-
// type GjsifyWebGLTexture = Gwebgl.WebGLTexture & WebGLTexture & number;
|
|
12
|
-
// type GjsifyWebGLUniformLocation = Gwebgl.WebGLUniformLocation & WebGLUniformLocation & number;
|
|
13
|
-
|
|
14
|
-
// type GjsifyWebGLActiveInfo = Gwebgl.WebGLActiveInfo & WebGLActiveInfo;
|
|
15
|
-
// type GjsifyWebGLShaderPrecisionFormat = Gwebgl.WebGLShaderPrecisionFormat & WebGLShaderPrecisionFormat;
|
|
16
|
-
|
|
17
|
-
// export {
|
|
18
|
-
// GjsifyWebGLProgram as WebGLProgram,
|
|
19
|
-
// GjsifyWebGLShader as WebGLShader,
|
|
20
|
-
// GjsifyWebGLBuffer as WebGLBuffer,
|
|
21
|
-
// GjsifyWebGLRenderbuffer as WebGLRenderbuffer,
|
|
22
|
-
// GjsifyWebGLTexture as WebGLTexture,
|
|
23
|
-
// GjsifyWebGLUniformLocation as WebGLUniformLocation,
|
|
24
|
-
// GjsifyWebGLActiveInfo as WebGLActiveInfo,
|
|
25
|
-
// GjsifyWebGLShaderPrecisionFormat as WebGLShaderPrecisionFormat
|
|
26
|
-
// }
|