Skip to content

Commit

Permalink
Merge pull request #6420 from KeyboardSounds/framebuffer-texture-filt…
Browse files Browse the repository at this point in the history
…ering-bug

fixed texture filtering bug in p5.Framebuffer
  • Loading branch information
davepagurek committed Sep 19, 2023
2 parents efc4c73 + ade64b0 commit bae626e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/webgl/p5.Framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ class Framebuffer {
this.target._renderer,
this.color,
{
glMinFilter: filter,
glMagFilter: filter
minFilter: filter,
magFilter: filter
}
);
this.target._renderer.textures.set(this.color, this.colorP5Texture);
Expand Down
30 changes: 30 additions & 0 deletions test/unit/webgl/p5.Framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,34 @@ suite('p5.Framebuffer', function() {
});
}
});

suite('texture filtering', function() {
test('can create a framebuffer that uses NEAREST texture filtering',
function() {
myp5.createCanvas(10, 10, myp5.WEBGL);
const fbo = myp5.createFramebuffer({
textureFiltering: myp5.NEAREST
});

assert.equal(
fbo.color.framebuffer.colorP5Texture.glMinFilter, fbo.gl.NEAREST
);
assert.equal(
fbo.color.framebuffer.colorP5Texture.glMagFilter, fbo.gl.NEAREST
);
});
test('can create a framebuffer that uses LINEAR texture filtering',
function() {
myp5.createCanvas(10, 10, myp5.WEBGL);
// LINEAR should be the default
const fbo = myp5.createFramebuffer({});

assert.equal(
fbo.color.framebuffer.colorP5Texture.glMinFilter, fbo.gl.LINEAR
);
assert.equal(
fbo.color.framebuffer.colorP5Texture.glMagFilter, fbo.gl.LINEAR
);
});
});
});

0 comments on commit bae626e

Please sign in to comment.