@flighthq/render-gl 0.3.1-next.887.9f59a84 → 0.3.1-next.970.9691e7b
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/package.json +11 -11
- package/src/glTestHelper.test.ts +51 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render-gl",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.970.9691e7b",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.3.1-next.
|
|
42
|
-
"@flighthq/entity": "0.3.1-next.
|
|
43
|
-
"@flighthq/log": "0.3.1-next.
|
|
44
|
-
"@flighthq/scene2d": "0.3.1-next.
|
|
45
|
-
"@flighthq/geometry": "0.3.1-next.
|
|
46
|
-
"@flighthq/render": "0.3.1-next.
|
|
47
|
-
"@flighthq/registry": "0.3.1-next.
|
|
48
|
-
"@flighthq/signals": "0.3.1-next.
|
|
49
|
-
"@flighthq/texture": "0.3.1-next.
|
|
50
|
-
"@flighthq/types": "0.3.1-next.
|
|
41
|
+
"@flighthq/color": "0.3.1-next.970.9691e7b",
|
|
42
|
+
"@flighthq/entity": "0.3.1-next.970.9691e7b",
|
|
43
|
+
"@flighthq/log": "0.3.1-next.970.9691e7b",
|
|
44
|
+
"@flighthq/scene2d": "0.3.1-next.970.9691e7b",
|
|
45
|
+
"@flighthq/geometry": "0.3.1-next.970.9691e7b",
|
|
46
|
+
"@flighthq/render": "0.3.1-next.970.9691e7b",
|
|
47
|
+
"@flighthq/registry": "0.3.1-next.970.9691e7b",
|
|
48
|
+
"@flighthq/signals": "0.3.1-next.970.9691e7b",
|
|
49
|
+
"@flighthq/texture": "0.3.1-next.970.9691e7b",
|
|
50
|
+
"@flighthq/types": "0.3.1-next.970.9691e7b"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typescript": "^5.3.0"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { makeGL } from './glTestHelper';
|
|
2
|
+
|
|
3
|
+
describe('makeGL', () => {
|
|
4
|
+
it('keeps draw validation outside a test-installed mock implementation', () => {
|
|
5
|
+
const gl = makeGL();
|
|
6
|
+
const draw = vi.fn();
|
|
7
|
+
(gl.drawElements as ReturnType<typeof vi.fn>).mockImplementation(draw);
|
|
8
|
+
|
|
9
|
+
gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 1);
|
|
10
|
+
|
|
11
|
+
expect(draw).not.toHaveBeenCalled();
|
|
12
|
+
expect(gl.getError()).toBe(gl.INVALID_OPERATION);
|
|
13
|
+
|
|
14
|
+
gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 0);
|
|
15
|
+
expect(draw).toHaveBeenCalledOnce();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('sets and consumes the first GL draw error without throwing', () => {
|
|
19
|
+
const gl = makeGL();
|
|
20
|
+
|
|
21
|
+
expect(() => gl.drawElements(gl.TRIANGLES, -1, gl.UNSIGNED_SHORT, 0)).not.toThrow();
|
|
22
|
+
gl.drawElements(0xffff, 1, gl.UNSIGNED_SHORT, 0);
|
|
23
|
+
|
|
24
|
+
expect(gl.drawElements).not.toHaveBeenCalled();
|
|
25
|
+
expect(gl.getError()).toBe(gl.INVALID_VALUE);
|
|
26
|
+
expect(gl.getError()).toBe(gl.NO_ERROR);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('reports a type-misaligned index offset as INVALID_OPERATION', () => {
|
|
30
|
+
const gl = makeGL();
|
|
31
|
+
|
|
32
|
+
gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 1);
|
|
33
|
+
|
|
34
|
+
expect(gl.getError()).toBe(gl.INVALID_OPERATION);
|
|
35
|
+
expect(gl.getError()).toBe(gl.NO_ERROR);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('validates non-indexed and instanced draw entry points', () => {
|
|
39
|
+
const gl = makeGL();
|
|
40
|
+
|
|
41
|
+
gl.drawArrays(0xffff, 0, 1);
|
|
42
|
+
expect(gl.getError()).toBe(gl.INVALID_ENUM);
|
|
43
|
+
|
|
44
|
+
gl.drawArraysInstanced(gl.TRIANGLES, 0, 1, -1);
|
|
45
|
+
expect(gl.getError()).toBe(gl.INVALID_VALUE);
|
|
46
|
+
|
|
47
|
+
gl.drawElementsInstanced(gl.TRIANGLES, 1, gl.FLOAT, 0, 1);
|
|
48
|
+
expect(gl.getError()).toBe(gl.INVALID_ENUM);
|
|
49
|
+
expect(gl.getError()).toBe(gl.NO_ERROR);
|
|
50
|
+
});
|
|
51
|
+
});
|