-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix textureWrap REPEAT for WebGL Power Of Two Image Element #5987
Fix textureWrap REPEAT for WebGL Power Of Two Image Element #5987
Conversation
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution looks great, and thanks for adding tests! I just have a comment about making the test setup a little more predictable but then I think this is good to go!
test/unit/webgl/p5.Texture.js
Outdated
p.createImg(texImg2.canvas.toDataURL(), '', 'anonymous', el => { | ||
el.size(50, 50); | ||
imgElementPowerOfTwo = el; | ||
p.texture(imgElementPowerOfTwo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is working right now, but maybe we can make it a tad clearer for readers of the tests which texture will be active at the end of setup
? I think the success callback here will always run immediately due to it being a data URL, but I think done()
gets called before those callbacks run. Maybe we could do something like this to ensure we always end with texImg1
as the active texture, and that we call done
after?
new Promise(resolve => {
p.createImg(texImg2.canvas.toDataURL(), '', 'anonymous', el => {
el.size(50, 50);
imgElementPowerOfTwo = el;
p.texture(imgElementPowerOfTwo);
resolve();
});
}).then(() => new Promise(resolve => {
p.createImg(texImg3.canvas.toDataURL(), '', 'anonymous', el => {
el.size(50, 50);
imgElementNotPowerOfTwo = el;
p.texture(imgElementNotPowerOfTwo);
resolve();
});
})).then(() => {
p.texture(texImg1);
done();
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing--added this.
Awesome, thanks! |
@davepagurek Thanks! Would it be ok to go ahead and add myself to the contributors list? |
Oh yes thanks for reminding me! |
@all-contributors please add @kate-grant for bug, code, test |
I've put up a pull request to add @kate-grant! 🎉 |
@davepagurek thanks! |
Resolves #5668
Previously
setWrapMode
checkedisPowerOfTwo
on element dimensions and not on src image dimensions. This causedtextureWrap(REPEAT)
to set to CLAMP ifthis
was an HTML element with non-power-of-two element dimensions, but this outcome was designed for non-power-of-two src image dimensions.Changes:
p5.Texture.prototype.setWrapMode
to addwrapWidth
andwrapHeight
to differentiate between HTML element src image dimensions vs. the element dimensions.PR Checklist
npm run lint
passesinline documentation already existed but the code did not perform as described