Skip to content

Commit

Permalink
fix: support stencil union, intersection and mask #184
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed May 16, 2024
1 parent ab4dffc commit 91911a6
Show file tree
Hide file tree
Showing 11 changed files with 1,424 additions and 7 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __tests__/integration/snapshots/stencil-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __tests__/integration/snapshots/stencil-union.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions __tests__/integration/stencil-intersection.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import _gl from 'gl';
import { getWebGLDeviceContributionAndCanvas } from '../utils';
import { render } from '../../examples/demos/stencil-intersection';
import '../useSnapshotMatchers';

describe('Stencil Intersection Operation', () => {
it('should render correctly.', async () => {
const [webGLDeviceContribution, $canvas] =
getWebGLDeviceContributionAndCanvas();

const disposeCallback = await render(
webGLDeviceContribution,
$canvas,
false,
);

const dir = `${__dirname}/snapshots`;

expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'stencil-intersection',
);

disposeCallback();
});
});
26 changes: 26 additions & 0 deletions __tests__/integration/stencil-mask.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import _gl from 'gl';
import { getWebGLDeviceContributionAndCanvas } from '../utils';
import { render } from '../../examples/demos/stencil-mask';
import '../useSnapshotMatchers';

describe('Stencil Mask', () => {
it('should render correctly.', async () => {
const [webGLDeviceContribution, $canvas] =
getWebGLDeviceContributionAndCanvas();

const disposeCallback = await render(
webGLDeviceContribution,
$canvas,
false,
);

const dir = `${__dirname}/snapshots`;

expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'stencil-mask',
);

disposeCallback();
});
});
26 changes: 26 additions & 0 deletions __tests__/integration/stencil-union.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import _gl from 'gl';
import { getWebGLDeviceContributionAndCanvas } from '../utils';
import { render } from '../../examples/demos/stencil-union';
import '../useSnapshotMatchers';

describe('Stencil Union Operation', () => {
it('should render correctly.', async () => {
const [webGLDeviceContribution, $canvas] =
getWebGLDeviceContributionAndCanvas();

const disposeCallback = await render(
webGLDeviceContribution,
$canvas,
false,
);

const dir = `${__dirname}/snapshots`;

expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'stencil-union',
);

disposeCallback();
});
});
3 changes: 3 additions & 0 deletions examples/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export { render as CanvasGradient } from './canvas-gradient';
export { render as RotatingCube } from './rotating-cube';
export { render as NestedRenderPass } from './nested-render-pass';
export { render as Stencil } from './stencil';
export { render as StencilMask } from './stencil-mask';
export { render as StencilUnion } from './stencil-union';
export { render as StencilIntersection } from './stencil-intersection';
export { render as Scissor } from './scissor';
export { render as TwoCubes } from './two-cubes';
export { render as TexturedCube } from './textured-cube';
Expand Down
Loading

0 comments on commit 91911a6

Please sign in to comment.