Skip to content

Commit

Permalink
Merge pull request #7443 from processing/fix/erase-fbo
Browse files Browse the repository at this point in the history
Fix noErase() breaking in WebGL
  • Loading branch information
davepagurek authored Dec 21, 2024
2 parents e03060a + af2d87b commit 05e35cb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -3683,9 +3683,7 @@ function material(p5, fn){
);
break;
}
if (!this._isErasing) {
this._cachedBlendMode = this.states.curBlendMode;
}
this._cachedBlendMode = this.states.curBlendMode;
};

RendererGL.prototype.shader = function(s) {
Expand Down
29 changes: 29 additions & 0 deletions test/unit/visual/cases/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,4 +533,33 @@ visualSuite('WebGL', function() {
screenshot();
});
});

visualSuite('erase()', () => {
visualTest('on the main canvas', (p5, screenshot) => {
p5.createCanvas(50, 50, p5.WEBGL);
p5.background(0);
p5.fill('red');
p5.rect(-20, -20, 40, 40);
p5.erase();
p5.circle(0, 0, 10);
p5.noErase();
screenshot();
});

visualTest('on a framebuffer', (p5, screenshot) => {
p5.createCanvas(50, 50, p5.WEBGL);
p5.background(0);
const fbo = p5.createFramebuffer();
fbo.begin();
p5.fill('red');
p5.rect(-20, -20, 40, 40);
p5.erase();
p5.circle(0, 0, 10);
p5.noErase();
fbo.end();
p5.imageMode(p5.CENTER);
p5.image(fbo, 0, 0);
screenshot();
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}

0 comments on commit 05e35cb

Please sign in to comment.