Closed
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
1.8.0
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
- Enable the stencil test in setup().
- I don't enable the stencil test, inside draw loop.
- When drawing with a stencil inside a drawloop, the stencil is not taken into account.
Snippet:
function setup() {
createCanvas(400, 400, WEBGL);
noStroke();
const gl = this._renderer.GL;
// enable
gl.enable(gl.STENCIL_TEST);
}
function draw(){
background(0);
const gl = this._renderer.GL;
//gl.enable(gl.STENCIL_TEST);
// initialize 0
gl.clear(gl.STENCIL_BUFFER_BIT);
// set 1
gl.stencilFunc(gl.ALWAYS, 1, ~0);
gl.stencilOp(gl.KEEP, gl.REPLACE, gl.REPLACE);
fill(255, 0, 0);
plane(200, 400);
// if stencil value is 1, draw plane
gl.stencilFunc(gl.EQUAL, 1, ~0);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
fill(0, 0, 255);
plane(400, 200);
noLoop();
}
version 1.7.0
version 1.8.0
Of course, if you enable the stencil test inside the draw loop, you will get the desired drawing result.
However, some users may not like it when the stencil test is disabled regardless of their intentions.