@flighthq/render-gl 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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 +2 -2
- package/dist/contract.d.ts +1 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -3
- package/dist/contract.js.map +1 -1
- package/dist/enableGlRenderStateGuards.js +2 -2
- package/dist/enableGlRenderStateGuards.js.map +1 -1
- package/dist/glCubeRenderTarget.d.ts +5 -5
- package/dist/glCubeRenderTarget.d.ts.map +1 -1
- package/dist/glCubeRenderTarget.js +16 -13
- package/dist/glCubeRenderTarget.js.map +1 -1
- package/dist/glFullscreenPass.d.ts +4 -3
- package/dist/glFullscreenPass.d.ts.map +1 -1
- package/dist/glFullscreenPass.js +152 -23
- package/dist/glFullscreenPass.js.map +1 -1
- package/dist/glLinearToSrgbPass.d.ts +2 -2
- package/dist/glLinearToSrgbPass.d.ts.map +1 -1
- package/dist/glLinearToSrgbPass.js.map +1 -1
- package/dist/glPresentRenderTarget.d.ts +2 -2
- package/dist/glPresentRenderTarget.d.ts.map +1 -1
- package/dist/glPresentRenderTarget.js.map +1 -1
- package/dist/glReadback.d.ts +2 -2
- package/dist/glReadback.d.ts.map +1 -1
- package/dist/glReadback.js +1 -1
- package/dist/glReadback.js.map +1 -1
- package/dist/glRenderPass.d.ts +6 -3
- package/dist/glRenderPass.d.ts.map +1 -1
- package/dist/glRenderPass.js +105 -86
- package/dist/glRenderPass.js.map +1 -1
- package/dist/glRenderState.d.ts +1 -2
- package/dist/glRenderState.d.ts.map +1 -1
- package/dist/glRenderState.js +53 -46
- package/dist/glRenderState.js.map +1 -1
- package/dist/glRenderTarget.d.ts +17 -16
- package/dist/glRenderTarget.d.ts.map +1 -1
- package/dist/glRenderTarget.js +38 -26
- package/dist/glRenderTarget.js.map +1 -1
- package/dist/glRenderTargetPool.d.ts +9 -9
- package/dist/glRenderTargetPool.d.ts.map +1 -1
- package/dist/glRenderTargetPool.js +10 -12
- package/dist/glRenderTargetPool.js.map +1 -1
- package/dist/glRenderTexture.d.ts +2 -2
- package/dist/glRenderTexture.d.ts.map +1 -1
- package/dist/glRenderTexture.js +11 -13
- package/dist/glRenderTexture.js.map +1 -1
- package/dist/glRenderTexturePool.js +3 -5
- package/dist/glRenderTexturePool.js.map +1 -1
- package/dist/glSkinPaletteTexture.js +8 -2
- package/dist/glSkinPaletteTexture.js.map +1 -1
- package/dist/glTestHelper.d.ts +0 -1
- package/dist/glTestHelper.d.ts.map +1 -1
- package/dist/glTestHelper.js +0 -1
- package/dist/glTestHelper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/enableGlRenderStateGuards.test.ts +2 -4
- package/src/glContext.test.ts +3 -52
- package/src/glCubeRenderTarget.test.ts +10 -8
- package/src/glDraw.test.ts +4 -16
- package/src/glFullscreenPass.test.ts +145 -41
- package/src/glLinearToSrgbPass.test.ts +8 -5
- package/src/glPresentRenderTarget.test.ts +3 -5
- package/src/glReadback.test.ts +3 -3
- package/src/glRenderPass.test.ts +228 -55
- package/src/glRenderState.test.ts +106 -165
- package/src/glRenderTarget.test.ts +134 -99
- package/src/glRenderTargetPool.test.ts +69 -76
- package/src/glRenderTexture.test.ts +58 -31
- package/src/glSkinPaletteTexture.test.ts +9 -0
- package/src/glTextureResolver.test.ts +5 -1
- package/dist/glBackground.d.ts +0 -3
- package/dist/glBackground.d.ts.map +0 -1
- package/dist/glBackground.js +0 -19
- package/dist/glBackground.js.map +0 -1
- package/dist/glContext.d.ts +0 -3
- package/dist/glContext.d.ts.map +0 -1
- package/dist/glContext.js +0 -16
- package/dist/glContext.js.map +0 -1
- package/src/glBackground.test.ts +0 -68
package/dist/glTestHelper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTestHelper.js","s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C3B,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,EAA0B;QACrC,QAAQ,EAAE,EAA0B;QACpC,aAAa,EAAE,EAA0B;QACzC,YAAY,EAAE,EAA0B;QACxC,oBAAoB,EAAE,EAA0B;QAChD,UAAU,EAAE,EAA0B;KACvC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { acquireGlRenderTexture, applyGlBlendMode, beginGlCubeRenderFace, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture,
|
|
1
|
+
export { acquireGlRenderTexture, applyGlBlendMode, beginGlCubeRenderFace, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTarget, clearGlRenderTargetAttachments, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture, createEmptyGlRegistries, createGlCubeRenderTarget, createGlPipeline, createGlRenderState, createGlRenderTexturePool, createGlScreenRenderTarget, createGlTextureRenderTarget, destroyGlCubeRenderTarget, destroyGlTextureRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, drawGlFullscreenPass, drawGlQuad, fillGlRect, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, endGlCubeRenderFace, explainGlRenderSurfaceAbsence, explainGlTextureRenderTarget, explainGlRenderTexture, explainGlTextureResolution, getGlCurrentRenderPass, getGlPipelineRegistries, isGlRenderTargetFormatSupported, popGlRenderState, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, presentGlRenderTarget, pushGlRenderState, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlTexture, setGlRenderTransform2D, standardGlBlendRealizations, standardGlTextureResolvers, uploadGlCompressedTextureContainer, withGlRenderState, withGlRenderTextures, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC7B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,gBAAgB,EAChB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { acquireGlRenderTexture, applyGlBlendMode, beginGlCubeRenderFace, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture,
|
|
1
|
+
export { acquireGlRenderTexture, applyGlBlendMode, beginGlCubeRenderFace, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTarget, clearGlRenderTargetAttachments, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture, createEmptyGlRegistries, createGlCubeRenderTarget, createGlPipeline, createGlRenderState, createGlRenderTexturePool, createGlScreenRenderTarget, createGlTextureRenderTarget, destroyGlCubeRenderTarget, destroyGlTextureRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, drawGlFullscreenPass, drawGlQuad, fillGlRect, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, endGlCubeRenderFace, explainGlRenderSurfaceAbsence, explainGlTextureRenderTarget, explainGlRenderTexture, explainGlTextureResolution, getGlCurrentRenderPass, getGlPipelineRegistries, isGlRenderTargetFormatSupported, popGlRenderState, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, presentGlRenderTarget, pushGlRenderState, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlTexture, setGlRenderTransform2D, standardGlBlendRealizations, standardGlTextureResolvers, uploadGlCompressedTextureContainer, withGlRenderState, withGlRenderTextures, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC7B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,gBAAgB,EAChB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render-gl",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1201.9b49dee",
|
|
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.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/log": "0.5.1-next.
|
|
44
|
-
"@flighthq/scene2d": "0.5.1-next.
|
|
45
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
46
|
-
"@flighthq/render": "0.5.1-next.
|
|
47
|
-
"@flighthq/registry": "0.5.1-next.
|
|
48
|
-
"@flighthq/signals": "0.5.1-next.
|
|
49
|
-
"@flighthq/texture": "0.5.1-next.
|
|
50
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/color": "0.5.1-next.1201.9b49dee",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.1201.9b49dee",
|
|
43
|
+
"@flighthq/log": "0.5.1-next.1201.9b49dee",
|
|
44
|
+
"@flighthq/scene2d": "0.5.1-next.1201.9b49dee",
|
|
45
|
+
"@flighthq/geometry": "0.5.1-next.1201.9b49dee",
|
|
46
|
+
"@flighthq/render": "0.5.1-next.1201.9b49dee",
|
|
47
|
+
"@flighthq/registry": "0.5.1-next.1201.9b49dee",
|
|
48
|
+
"@flighthq/signals": "0.5.1-next.1201.9b49dee",
|
|
49
|
+
"@flighthq/texture": "0.5.1-next.1201.9b49dee",
|
|
50
|
+
"@flighthq/types": "0.5.1-next.1201.9b49dee"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typescript": "^5.3.0"
|
|
@@ -4,17 +4,15 @@ import type { LogEntry } from '@flighthq/types/contract';
|
|
|
4
4
|
import { RegistryEntryState } from '@flighthq/types/contract';
|
|
5
5
|
|
|
6
6
|
import { areGlRenderStateGuardsEnabled, enableGlRenderStateGuards } from './enableGlRenderStateGuards';
|
|
7
|
-
import { createGlContextFromCanvasElement } from './glContext';
|
|
8
7
|
import { useGlProgram } from './glDraw';
|
|
9
8
|
import { createEmptyGlRegistries, createGlPipeline } from './glPipeline';
|
|
10
|
-
import {
|
|
9
|
+
import { createGlRenderState, getGlRenderStateRuntime } from './glRenderState';
|
|
11
10
|
import { makeGL } from './glTestHelper';
|
|
12
11
|
|
|
13
12
|
function createState() {
|
|
14
13
|
const canvas = document.createElement('canvas');
|
|
15
14
|
canvas.getContext = vi.fn().mockReturnValue(makeGL()) as typeof canvas.getContext;
|
|
16
|
-
|
|
17
|
-
return createGlRenderState(contextState, createGlPipeline(createEmptyGlRegistries()));
|
|
15
|
+
return createGlRenderState(makeGL(), createGlPipeline(createEmptyGlRegistries()));
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
beforeEach(() => clearLogOnceKeys());
|
package/src/glContext.test.ts
CHANGED
|
@@ -1,63 +1,14 @@
|
|
|
1
1
|
import { build } from 'esbuild';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { makeGL } from './glTestHelper';
|
|
5
|
-
|
|
6
|
-
function makeCanvas(context: WebGL2RenderingContext | null = makeGL()): HTMLCanvasElement {
|
|
7
|
-
const canvas = document.createElement('canvas');
|
|
8
|
-
canvas.getContext = vi.fn().mockReturnValue(context) as typeof canvas.getContext;
|
|
9
|
-
return canvas;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
describe('createGlContextFromCanvasElement', () => {
|
|
13
|
-
it('returns the canvas WebGL2 context', () => {
|
|
14
|
-
const gl = makeGL();
|
|
15
|
-
expect(createGlContextFromCanvasElement(makeCanvas(gl))).toBe(gl);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('requests the context defaults independently from render options', () => {
|
|
19
|
-
const canvas = makeCanvas();
|
|
20
|
-
createGlContextFromCanvasElement(canvas);
|
|
21
|
-
expect(canvas.getContext).toHaveBeenCalledWith('webgl2', {
|
|
22
|
-
alpha: true,
|
|
23
|
-
antialias: true,
|
|
24
|
-
powerPreference: 'default',
|
|
25
|
-
stencil: true,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('applies context options and lets explicit attributes override their convenience fields', () => {
|
|
30
|
-
const canvas = makeCanvas();
|
|
31
|
-
createGlContextFromCanvasElement(canvas, {
|
|
32
|
-
antialias: false,
|
|
33
|
-
contextAttributes: { alpha: false, antialias: true, preserveDrawingBuffer: true },
|
|
34
|
-
powerPreference: 'high-performance',
|
|
35
|
-
});
|
|
36
|
-
expect(canvas.getContext).toHaveBeenCalledWith('webgl2', {
|
|
37
|
-
alpha: false,
|
|
38
|
-
antialias: true,
|
|
39
|
-
powerPreference: 'high-performance',
|
|
40
|
-
preserveDrawingBuffer: true,
|
|
41
|
-
stencil: true,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('throws when the canvas has no WebGL2 context', () => {
|
|
46
|
-
expect(() => createGlContextFromCanvasElement(makeCanvas(null))).toThrow('Failed to get WebGL2 context.');
|
|
47
|
-
});
|
|
48
|
-
|
|
3
|
+
describe('createGlRenderState tree-shaking', () => {
|
|
49
4
|
it('tree-shakes canvas context acquisition out of a context-first state bundle', async () => {
|
|
50
5
|
const renderStateBundle = await bundleRenderGlExport('createGlRenderState');
|
|
51
6
|
expect(renderStateBundle).not.toContain('Failed to get WebGL2 context.');
|
|
52
7
|
expect(renderStateBundle).not.toMatch(/\.getContext\(["']webgl2["']/);
|
|
53
|
-
|
|
54
|
-
const contextBundle = await bundleRenderGlExport('createGlContextFromCanvasElement');
|
|
55
|
-
expect(contextBundle).toContain('Failed to get WebGL2 context.');
|
|
56
|
-
expect(contextBundle).toMatch(/\.getContext\(["']webgl2["']/);
|
|
57
8
|
});
|
|
58
9
|
});
|
|
59
10
|
|
|
60
|
-
async function bundleRenderGlExport(name: '
|
|
11
|
+
async function bundleRenderGlExport(name: 'createGlRenderState'): Promise<string> {
|
|
61
12
|
const result = await build({
|
|
62
13
|
bundle: true,
|
|
63
14
|
format: 'esm',
|
|
@@ -79,5 +30,5 @@ function getFileUrlDirectory(url: string): string {
|
|
|
79
30
|
const directory = new URL('.', url);
|
|
80
31
|
const pathname = decodeURIComponent(directory.pathname);
|
|
81
32
|
if (directory.hostname !== '') return `//${directory.hostname}${pathname}`;
|
|
82
|
-
return /^\/[A-Za-
|
|
33
|
+
return /^\/[A-Za-z0-9]:\//.test(pathname) ? pathname.slice(1) : pathname;
|
|
83
34
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GlRenderPass, GlRenderTarget } from '@flighthq/types/contract';
|
|
1
2
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -12,7 +13,7 @@ import { declareGlRenderTargetColorSpace } from './glRenderTarget';
|
|
|
12
13
|
import { createGlState } from './glTestHelper';
|
|
13
14
|
|
|
14
15
|
function makeState() {
|
|
15
|
-
const { state, gl: base } = createGlState(
|
|
16
|
+
const { state, gl: base } = createGlState();
|
|
16
17
|
const framebuffer = { name: 'cube-framebuffer' } as WebGLFramebuffer;
|
|
17
18
|
const texture = { name: 'cube-texture' } as WebGLTexture;
|
|
18
19
|
const renderbuffer = { name: 'cube-depth' } as WebGLRenderbuffer;
|
|
@@ -96,7 +97,7 @@ describe('beginGlCubeRenderFace', () => {
|
|
|
96
97
|
const target = createGlCubeRenderTarget(state, 32);
|
|
97
98
|
vi.clearAllMocks();
|
|
98
99
|
|
|
99
|
-
beginGlCubeRenderFace(state, target, 4);
|
|
100
|
+
const pass = beginGlCubeRenderFace(state, target, 4);
|
|
100
101
|
expect(declareGlRenderTargetColorSpace(state, 'srgb')).toBe(true);
|
|
101
102
|
|
|
102
103
|
expect(gl.bindFramebuffer).toHaveBeenCalledWith(gl.FRAMEBUFFER, framebuffer);
|
|
@@ -108,10 +109,10 @@ describe('beginGlCubeRenderFace', () => {
|
|
|
108
109
|
0,
|
|
109
110
|
);
|
|
110
111
|
expect(gl.viewport).toHaveBeenCalledWith(0, 0, 32, 32);
|
|
111
|
-
expect(gl.clearBufferfv).toHaveBeenCalledWith(gl.COLOR, 0, new Float32Array([0
|
|
112
|
+
expect(gl.clearBufferfv).toHaveBeenCalledWith(gl.COLOR, 0, new Float32Array([0, 0, 0, 0]));
|
|
112
113
|
expect(gl.clearBufferfi).toHaveBeenCalledWith(gl.DEPTH_STENCIL, 0, 1, 0);
|
|
113
114
|
expect(target.colorSpace).toBe('srgb');
|
|
114
|
-
endGlCubeRenderFace(
|
|
115
|
+
endGlCubeRenderFace(pass);
|
|
115
116
|
});
|
|
116
117
|
|
|
117
118
|
it('rejects a face outside the six-face cube range', () => {
|
|
@@ -170,7 +171,7 @@ describe('destroyGlCubeRenderTarget', () => {
|
|
|
170
171
|
const target = createGlCubeRenderTarget(state, 16);
|
|
171
172
|
vi.clearAllMocks();
|
|
172
173
|
|
|
173
|
-
destroyGlCubeRenderTarget(
|
|
174
|
+
destroyGlCubeRenderTarget(target);
|
|
174
175
|
|
|
175
176
|
expect(gl.deleteFramebuffer).toHaveBeenCalledWith(framebuffer);
|
|
176
177
|
expect(gl.deleteTexture).toHaveBeenCalledWith(texture);
|
|
@@ -187,9 +188,9 @@ describe('endGlCubeRenderFace', () => {
|
|
|
187
188
|
runtime.renderTargetViewport = { height: 60, width: 50, x: 3, y: 4 };
|
|
188
189
|
vi.clearAllMocks();
|
|
189
190
|
|
|
190
|
-
beginGlCubeRenderFace(state, target, 0);
|
|
191
|
+
const pass = beginGlCubeRenderFace(state, target, 0);
|
|
191
192
|
expect(runtime.currentRenderTarget).toBe(target);
|
|
192
|
-
endGlCubeRenderFace(
|
|
193
|
+
endGlCubeRenderFace(pass);
|
|
193
194
|
|
|
194
195
|
expect(vi.mocked(gl.bindFramebuffer).mock.lastCall).toEqual([gl.FRAMEBUFFER, previousFramebuffer]);
|
|
195
196
|
expect(vi.mocked(gl.viewport).mock.lastCall).toEqual([3, 4, 50, 60]);
|
|
@@ -201,7 +202,8 @@ describe('endGlCubeRenderFace', () => {
|
|
|
201
202
|
|
|
202
203
|
it('rejects an unmatched end', () => {
|
|
203
204
|
const { state } = makeState();
|
|
204
|
-
|
|
205
|
+
const mockPass = { gl: state.gl, state, target: {} as GlRenderTarget } as GlRenderPass;
|
|
206
|
+
expect(() => endGlCubeRenderFace(mockPass)).toThrow('without a matching beginGlCubeRenderFace');
|
|
205
207
|
});
|
|
206
208
|
});
|
|
207
209
|
|
package/src/glDraw.test.ts
CHANGED
|
@@ -32,20 +32,14 @@ import {
|
|
|
32
32
|
useGlProgram,
|
|
33
33
|
} from './glDraw';
|
|
34
34
|
import { createEmptyGlRegistries, createGlPipeline } from './glPipeline';
|
|
35
|
-
import {
|
|
36
|
-
createGlContextState,
|
|
37
|
-
createGlOffscreenRenderState,
|
|
38
|
-
createGlRenderState,
|
|
39
|
-
getGlRenderStateRuntime,
|
|
40
|
-
invalidateGlRenderStateCache,
|
|
41
|
-
} from './glRenderState';
|
|
35
|
+
import { createGlRenderState, getGlRenderStateRuntime, invalidateGlRenderStateCache } from './glRenderState';
|
|
42
36
|
import { registerGlBitmapShader } from './glShaderRegistry';
|
|
43
37
|
import { createGlState, makeGL } from './glTestHelper';
|
|
44
38
|
|
|
45
39
|
const testPipeline = createGlPipeline(createEmptyGlRegistries());
|
|
46
40
|
|
|
47
41
|
function createTestGlRenderState(gl: WebGL2RenderingContext) {
|
|
48
|
-
return createGlRenderState(
|
|
42
|
+
return createGlRenderState(gl, testPipeline);
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
// A single 4×4 bc3 level for exercising the opt-in compressed upload seam.
|
|
@@ -104,10 +98,7 @@ describe('applyGlBlendMode', () => {
|
|
|
104
98
|
const gl = makeGL();
|
|
105
99
|
const screen = createTestGlRenderState(gl);
|
|
106
100
|
registerGlBlendMode(screen, 'acme.Split', { dst: 'ONE', equation: 'MIN', src: 'ONE' });
|
|
107
|
-
const offscreen =
|
|
108
|
-
screen.contextState,
|
|
109
|
-
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
110
|
-
);
|
|
101
|
+
const offscreen = createGlRenderState(screen.gl, createGlPipeline(getGlRenderStateRuntime(screen).registries));
|
|
111
102
|
registerGlBlendMode(screen, 'acme.Split', { dst: 'ONE', src: 'ZERO' });
|
|
112
103
|
|
|
113
104
|
applyGlBlendMode(offscreen, 'acme.Split');
|
|
@@ -922,10 +913,7 @@ describe('registerGlBlendMode', () => {
|
|
|
922
913
|
const replacement = { src: 'ZERO', dst: 'ONE' } as const;
|
|
923
914
|
registerGlBlendMode(screen, 'acme.Foo', initial);
|
|
924
915
|
const snapshot = getGlRenderStateRuntime(screen).registries.blendRealizations;
|
|
925
|
-
const offscreen =
|
|
926
|
-
screen.contextState,
|
|
927
|
-
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
928
|
-
);
|
|
916
|
+
const offscreen = createGlRenderState(screen.gl, createGlPipeline(getGlRenderStateRuntime(screen).registries));
|
|
929
917
|
|
|
930
918
|
registerGlBlendMode(screen, 'acme.Foo', replacement);
|
|
931
919
|
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import {
|
|
2
|
+
import type { GlRenderPass, GlRenderState, GlTextureRenderTarget } from '@flighthq/types/contract';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
clearGlRenderTarget,
|
|
6
|
+
clearGlRenderTargetAttachments,
|
|
7
|
+
compileGlFullscreenProgram,
|
|
8
|
+
drawGlFullscreenPass,
|
|
9
|
+
fillGlRect,
|
|
10
|
+
} from './glFullscreenPass';
|
|
5
11
|
import { getGlRenderStateRuntime } from './glRenderState';
|
|
6
12
|
import { createGlState, makeGL } from './glTestHelper';
|
|
7
13
|
|
|
14
|
+
function makePass(state: GlRenderState): GlRenderPass {
|
|
15
|
+
const pass = allocateEntity<GlRenderPass>();
|
|
16
|
+
(pass as unknown as { gl: GlRenderState['gl'] }).gl = state.gl;
|
|
17
|
+
(pass as unknown as { state: GlRenderState }).state = state;
|
|
18
|
+
(pass as unknown as { target: null }).target = null as never;
|
|
19
|
+
return finishEntity(pass);
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
const FRAG_SRC = `#version 300 es
|
|
9
23
|
precision mediump float;
|
|
10
24
|
in vec2 v_texCoord;
|
|
@@ -14,8 +28,14 @@ void main() {
|
|
|
14
28
|
fragColor = texture(u_texture, v_texCoord);
|
|
15
29
|
}`;
|
|
16
30
|
|
|
17
|
-
function makeTarget(
|
|
18
|
-
|
|
31
|
+
function makeTarget(
|
|
32
|
+
framebuffer: WebGLFramebuffer,
|
|
33
|
+
width = 32,
|
|
34
|
+
height = 16,
|
|
35
|
+
gl?: WebGL2RenderingContext,
|
|
36
|
+
): GlTextureRenderTarget {
|
|
37
|
+
const out = allocateEntity<GlTextureRenderTarget>();
|
|
38
|
+
if (gl) (out as unknown as { gl: WebGL2RenderingContext }).gl = gl;
|
|
19
39
|
out.requestedAxes = {
|
|
20
40
|
width,
|
|
21
41
|
height,
|
|
@@ -33,13 +53,12 @@ function makeTarget(framebuffer: WebGLFramebuffer, width = 32, height = 16): GlR
|
|
|
33
53
|
out.colorFormats = ['rgba8'];
|
|
34
54
|
out.depth = 'none';
|
|
35
55
|
out.colorSpace = 'srgb';
|
|
36
|
-
out.clearColors = [];
|
|
37
|
-
out.clearDepth = 1;
|
|
38
56
|
out.sampleCount = 1;
|
|
39
57
|
out.framebuffer = framebuffer;
|
|
40
58
|
out.resolveFramebuffer = null;
|
|
41
|
-
|
|
42
|
-
out.
|
|
59
|
+
const texture = {} as WebGLTexture;
|
|
60
|
+
out.textures = [texture];
|
|
61
|
+
out.texture = texture;
|
|
43
62
|
out.depthTexture = null;
|
|
44
63
|
out.colorRenderbuffers = [];
|
|
45
64
|
out.depthStencilRenderbuffer = null;
|
|
@@ -47,61 +66,85 @@ function makeTarget(framebuffer: WebGLFramebuffer, width = 32, height = 16): GlR
|
|
|
47
66
|
}
|
|
48
67
|
|
|
49
68
|
describe('clearGlRenderTarget', () => {
|
|
50
|
-
it('binds the target framebuffer and clears
|
|
51
|
-
const {
|
|
69
|
+
it('binds the target framebuffer and clears color via clearBufferfv', () => {
|
|
70
|
+
const { gl } = createGlState();
|
|
52
71
|
const fb = {} as WebGLFramebuffer;
|
|
53
|
-
const target = makeTarget(fb);
|
|
72
|
+
const target = makeTarget(fb, 32, 16, gl);
|
|
54
73
|
const bindSpy = vi.spyOn(gl, 'bindFramebuffer');
|
|
55
|
-
const clearSpy = vi.spyOn(gl, '
|
|
74
|
+
const clearSpy = vi.spyOn(gl, 'clearBufferfv');
|
|
56
75
|
|
|
57
|
-
clearGlRenderTarget(
|
|
76
|
+
clearGlRenderTarget(target, { color: [0, 0, 0, 0] });
|
|
58
77
|
|
|
59
78
|
expect(bindSpy).toHaveBeenCalledWith(gl.FRAMEBUFFER, fb);
|
|
60
|
-
expect(clearSpy).toHaveBeenCalledWith(gl.
|
|
79
|
+
expect(clearSpy).toHaveBeenCalledWith(gl.COLOR, 0, expect.anything());
|
|
61
80
|
});
|
|
62
81
|
|
|
63
|
-
it('sets the viewport
|
|
64
|
-
const {
|
|
65
|
-
const target = makeTarget({} as WebGLFramebuffer, 48, 24);
|
|
82
|
+
it('sets the viewport to the target size', () => {
|
|
83
|
+
const { gl } = createGlState();
|
|
84
|
+
const target = makeTarget({} as WebGLFramebuffer, 48, 24, gl);
|
|
66
85
|
const viewportSpy = vi.spyOn(gl, 'viewport');
|
|
67
86
|
|
|
68
|
-
clearGlRenderTarget(
|
|
87
|
+
clearGlRenderTarget(target, { color: [0, 0, 0, 0] });
|
|
69
88
|
|
|
70
89
|
expect(viewportSpy).toHaveBeenCalledWith(0, 0, 48, 24);
|
|
71
|
-
expect(getGlRenderStateRuntime(state).renderTargetViewport).toEqual({ height: 24, width: 48, x: 0, y: 0 });
|
|
72
90
|
});
|
|
73
91
|
|
|
74
|
-
it('
|
|
75
|
-
const {
|
|
76
|
-
const
|
|
92
|
+
it('writes float RGBA values directly to clearBufferfv', () => {
|
|
93
|
+
const { gl } = createGlState();
|
|
94
|
+
const clearSpy = vi.spyOn(gl, 'clearBufferfv');
|
|
95
|
+
|
|
96
|
+
clearGlRenderTarget(makeTarget({} as WebGLFramebuffer, 32, 16, gl), { color: [1, 0, 0.5, 1] });
|
|
77
97
|
|
|
78
|
-
|
|
98
|
+
const rgba = clearSpy.mock.calls[0][2] as Float32Array;
|
|
99
|
+
expect(rgba[0]).toBeCloseTo(1);
|
|
100
|
+
expect(rgba[1]).toBeCloseTo(0);
|
|
101
|
+
expect(rgba[2]).toBeCloseTo(0.5);
|
|
102
|
+
expect(rgba[3]).toBeCloseTo(1);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
79
105
|
|
|
80
|
-
|
|
106
|
+
describe('clearGlRenderTargetAttachments', () => {
|
|
107
|
+
it('clears individual color attachments via clearBufferfv', () => {
|
|
108
|
+
const { gl } = createGlState();
|
|
109
|
+
const fb = {} as WebGLFramebuffer;
|
|
110
|
+
const target = makeTarget(fb, 32, 16, gl);
|
|
111
|
+
const clearSpy = vi.spyOn(gl, 'clearBufferfv');
|
|
112
|
+
|
|
113
|
+
clearGlRenderTargetAttachments(target, {
|
|
114
|
+
colors: [
|
|
115
|
+
[1, 0, 0, 1],
|
|
116
|
+
[0, 1, 0, 1],
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(clearSpy).toHaveBeenCalledWith(gl.COLOR, 0, expect.anything());
|
|
121
|
+
expect(clearSpy).toHaveBeenCalledWith(gl.COLOR, 1, expect.anything());
|
|
81
122
|
});
|
|
82
123
|
|
|
83
|
-
it('
|
|
84
|
-
const {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
runtime.context.currentBlendSignature = { dst: 0, equation: 0, src: 0 };
|
|
124
|
+
it('skips undefined entries in colors', () => {
|
|
125
|
+
const { gl } = createGlState();
|
|
126
|
+
const target = makeTarget({} as WebGLFramebuffer, 32, 16, gl);
|
|
127
|
+
const clearSpy = vi.spyOn(gl, 'clearBufferfv');
|
|
88
128
|
|
|
89
|
-
|
|
129
|
+
clearGlRenderTargetAttachments(target, {
|
|
130
|
+
colors: [undefined, [0, 0, 1, 1]],
|
|
131
|
+
});
|
|
90
132
|
|
|
91
|
-
expect(
|
|
92
|
-
expect(
|
|
133
|
+
expect(clearSpy).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(clearSpy).toHaveBeenCalledWith(gl.COLOR, 1, expect.anything());
|
|
93
135
|
});
|
|
94
136
|
|
|
95
|
-
it('
|
|
96
|
-
const {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
137
|
+
it('disables scissor test during clear and restores it', () => {
|
|
138
|
+
const { gl } = createGlState();
|
|
139
|
+
const target = makeTarget({} as WebGLFramebuffer, 32, 16, gl);
|
|
140
|
+
gl.enable(gl.SCISSOR_TEST);
|
|
141
|
+
const disableSpy = vi.spyOn(gl, 'disable');
|
|
142
|
+
const enableSpy = vi.spyOn(gl, 'enable');
|
|
101
143
|
|
|
102
|
-
|
|
144
|
+
clearGlRenderTargetAttachments(target, { colors: [[0, 0, 0, 0]] });
|
|
103
145
|
|
|
104
|
-
expect(
|
|
146
|
+
expect(disableSpy).toHaveBeenCalledWith(gl.SCISSOR_TEST);
|
|
147
|
+
expect(enableSpy).toHaveBeenCalledWith(gl.SCISSOR_TEST);
|
|
105
148
|
});
|
|
106
149
|
});
|
|
107
150
|
|
|
@@ -354,3 +397,64 @@ describe('drawGlFullscreenPass', () => {
|
|
|
354
397
|
});
|
|
355
398
|
});
|
|
356
399
|
});
|
|
400
|
+
|
|
401
|
+
describe('fillGlRect', () => {
|
|
402
|
+
it('unpacks a packed RGBA integer into float uniform values', () => {
|
|
403
|
+
const { state, gl } = createGlState();
|
|
404
|
+
const uniform4fSpy = vi.spyOn(gl, 'uniform4f');
|
|
405
|
+
|
|
406
|
+
fillGlRect(makePass(state), 0xff8040ff);
|
|
407
|
+
|
|
408
|
+
const call = uniform4fSpy.mock.calls.find((c) => typeof c[1] === 'number' && c[1] === 1);
|
|
409
|
+
expect(call).toBeDefined();
|
|
410
|
+
expect(call![2]).toBeCloseTo(0x80 / 255);
|
|
411
|
+
expect(call![3]).toBeCloseTo(0x40 / 255);
|
|
412
|
+
expect(call![4]).toBeCloseTo(1);
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('draws with blending enabled and depth test off', () => {
|
|
416
|
+
const { state, gl } = createGlState();
|
|
417
|
+
gl.enable(gl.DEPTH_TEST);
|
|
418
|
+
gl.disable(gl.BLEND);
|
|
419
|
+
let blendAtDraw: boolean | null = null;
|
|
420
|
+
let depthAtDraw: boolean | null = null;
|
|
421
|
+
vi.spyOn(gl, 'drawElements').mockImplementation(() => {
|
|
422
|
+
blendAtDraw = gl.isEnabled(gl.BLEND);
|
|
423
|
+
depthAtDraw = gl.isEnabled(gl.DEPTH_TEST);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
fillGlRect(makePass(state), 0x000000ff);
|
|
427
|
+
|
|
428
|
+
expect(blendAtDraw).toBe(true);
|
|
429
|
+
expect(depthAtDraw).toBe(false);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it('restores depth and blend state after drawing', () => {
|
|
433
|
+
const { state, gl } = createGlState();
|
|
434
|
+
gl.enable(gl.DEPTH_TEST);
|
|
435
|
+
gl.disable(gl.BLEND);
|
|
436
|
+
|
|
437
|
+
fillGlRect(makePass(state), 0x000000ff);
|
|
438
|
+
|
|
439
|
+
expect(gl.isEnabled(gl.DEPTH_TEST)).toBe(true);
|
|
440
|
+
expect(gl.isEnabled(gl.BLEND)).toBe(false);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('enables scissor test when rect is provided', () => {
|
|
444
|
+
const { state, gl } = createGlState();
|
|
445
|
+
const scissorSpy = vi.spyOn(gl, 'scissor');
|
|
446
|
+
|
|
447
|
+
fillGlRect(makePass(state), 0xff0000ff, { x: 10, y: 20, width: 30, height: 40 });
|
|
448
|
+
|
|
449
|
+
expect(scissorSpy).toHaveBeenCalledWith(10, 20, 30, 40);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it('restores scissor state when rect is provided and scissor was off', () => {
|
|
453
|
+
const { state, gl } = createGlState();
|
|
454
|
+
gl.disable(gl.SCISSOR_TEST);
|
|
455
|
+
|
|
456
|
+
fillGlRect(makePass(state), 0xff0000ff, { x: 0, y: 0, width: 10, height: 10 });
|
|
457
|
+
|
|
458
|
+
expect(gl.isEnabled(gl.SCISSOR_TEST)).toBe(false);
|
|
459
|
+
});
|
|
460
|
+
});
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GlTextureRenderTarget } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import { drawGlLinearToSrgbPass, LINEAR_TO_SRGB_FRAGMENT_SRC } from './glLinearToSrgbPass';
|
|
5
5
|
import { createGlState } from './glTestHelper';
|
|
6
6
|
|
|
7
|
-
function makeTarget(
|
|
8
|
-
|
|
7
|
+
function makeTarget(
|
|
8
|
+
framebuffer: WebGLFramebuffer,
|
|
9
|
+
texture: WebGLTexture,
|
|
10
|
+
width = 32,
|
|
11
|
+
height = 16,
|
|
12
|
+
): GlTextureRenderTarget {
|
|
13
|
+
const out = allocateEntity<GlTextureRenderTarget>();
|
|
9
14
|
out.requestedAxes = {
|
|
10
15
|
width,
|
|
11
16
|
height,
|
|
@@ -23,8 +28,6 @@ function makeTarget(framebuffer: WebGLFramebuffer, texture: WebGLTexture, width
|
|
|
23
28
|
out.colorFormats = ['rgba16f'];
|
|
24
29
|
out.depth = 'none';
|
|
25
30
|
out.colorSpace = 'linear';
|
|
26
|
-
out.clearColors = [];
|
|
27
|
-
out.clearDepth = 1;
|
|
28
31
|
out.sampleCount = 1;
|
|
29
32
|
out.framebuffer = framebuffer;
|
|
30
33
|
out.resolveFramebuffer = null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GlTextureRenderTarget } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import { presentGlRenderTarget } from './glPresentRenderTarget';
|
|
5
5
|
import { createGlState } from './glTestHelper';
|
|
6
6
|
|
|
7
|
-
function makeTarget(colorSpace: 'linear' | 'srgb', texture: WebGLTexture):
|
|
7
|
+
function makeTarget(colorSpace: 'linear' | 'srgb', texture: WebGLTexture): GlTextureRenderTarget {
|
|
8
8
|
const format = colorSpace === 'linear' ? 'rgba16f' : 'rgba8';
|
|
9
|
-
const out = allocateEntity<
|
|
9
|
+
const out = allocateEntity<GlTextureRenderTarget>();
|
|
10
10
|
out.requestedAxes = {
|
|
11
11
|
width: 32,
|
|
12
12
|
height: 16,
|
|
@@ -24,8 +24,6 @@ function makeTarget(colorSpace: 'linear' | 'srgb', texture: WebGLTexture): GlRen
|
|
|
24
24
|
out.colorFormats = [format];
|
|
25
25
|
out.depth = 'none';
|
|
26
26
|
out.colorSpace = colorSpace;
|
|
27
|
-
out.clearColors = [];
|
|
28
|
-
out.clearDepth = 1;
|
|
29
27
|
out.sampleCount = 1;
|
|
30
28
|
out.framebuffer = {} as WebGLFramebuffer;
|
|
31
29
|
out.resolveFramebuffer = null;
|
package/src/glReadback.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GlTextureRenderTarget } from '@flighthq/types/contract';
|
|
2
2
|
|
|
3
3
|
import { readGlRenderTargetPixels } from './glReadback';
|
|
4
4
|
import { createGlState } from './glTestHelper';
|
|
5
5
|
|
|
6
|
-
function makeTarget(overrides?: Partial<
|
|
6
|
+
function makeTarget(overrides?: Partial<GlTextureRenderTarget>): GlTextureRenderTarget {
|
|
7
7
|
return {
|
|
8
8
|
requestedAxes: {
|
|
9
9
|
width: 4,
|
|
@@ -31,7 +31,7 @@ function makeTarget(overrides?: Partial<GlRenderTarget>): GlRenderTarget {
|
|
|
31
31
|
colorRenderbuffers: [],
|
|
32
32
|
depthStencilRenderbuffer: null,
|
|
33
33
|
...overrides,
|
|
34
|
-
} as
|
|
34
|
+
} as GlTextureRenderTarget;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
describe('readGlRenderTargetPixels', () => {
|