Enhancement limit WebGL textures to gl.MAX_TEXTURE_SIZE
Resolves #6546
Changes:
For both Graphics and Framebuffer
- Calculated the maximum allowed pixel dimensions using the hardware limit and pixel density.
- Limited the dimensions to stay within these calculated maximum dimensions.
Screenshots of the change:
PR Checklist
- [ ]
npm run lintpasses - [ ] Inline documentation is included / updated
- [ ] Unit tests are included / updated
Hi @davepagurek,
Here's the problem:
- Let's say both the w and h given by the users are above the calculated maxAllowedPixelDimensions(let's say 8192), in this case, both the w and h are limited to maxAllowedPixelDimensions(8192), which works well for Graphics.
- But for Framebuffer restricting both w and h to maxAllowedPixelDimensions(8192) results in a CONTEXT_LOST_WEBGL error. Oddly, the error doesn't occur when only one dimension is limited to 8192 and the other is kept below 4000.
Is there something I might have overlooked or misunderstood in this context? Any insights on what might be causing this behaviour?
Hi @davepagurek,
I have spent significant time in debugging this. Strangely, I encountered a completely different error when running npm test, and after pushing the code, yet another error emerged. Could you please assist me by suggesting any potential areas that might be causing this error? Also, let me know if the tests I wrote looks good to you
Looks like some of the tests are failing. It might be that in the test environment on CI, the max texture size is something unexpected. Does the same thing happen when you run npm run ci locally? That might help us figure out if it's something about github's test runner, or something else.
Sorry forgot to add comment during the previous commit, after updating this.height and this.width to adjusted sizes, by that time I was using glStub.restore() inside afterEach(), and I did npm run test all tests passed.
Since we are only using glStub in a couple of tests made sense to use glStub.restore() inside the tests itself. So, pushed the code after this change. And the tests failed.
Now, this commit uses glStub.restore() inside afterEach(), tests passed. But why does this happen?
P.S. I just tried glStub.restore() inside the test("it resizes the graphics based on max texture size") in p5.Graphics, I usually get this (often),
Looks great! Thanks @capGoblin and @davepagurek!