Most appropriate sub-area of p5.js?
p5.js version
2.3.0
Web browser and version
All
Operating system
All
Steps to reproduce this
Steps:
- Create a high density canvas
- Create a framebuffer at 1x density
- The framebuffer may still get its size truncated as if it were the same density as the main canvas
This is because we are using the renderer's density when adjusting the size, even for framebuffers:
|
_adjustDimensions(width, height) { |
|
if (!this._maxTextureSize) { |
|
this._maxTextureSize = this._getMaxTextureSize(); |
|
} |
|
let maxTextureSize = this._maxTextureSize; |
|
|
|
let maxAllowedPixelDimensions = Math.floor( |
|
maxTextureSize / this._pixelDensity |
|
); |
|
let adjustedWidth = Math.min(width, maxAllowedPixelDimensions); |
|
let adjustedHeight = Math.min(height, maxAllowedPixelDimensions); |
|
|
|
if (adjustedWidth !== width || adjustedHeight !== height) { |
|
console.warn( |
|
"Warning: The requested width/height exceeds hardware limits. " + |
|
`Adjusting dimensions to width: ${adjustedWidth}, height: ${adjustedHeight}.` |
|
); |
|
} |
We need to update this to take in the target object's density.
This is probably an issue in the WebGPU renderer too.
Snippet:
function setup() {
let renderer = createCanvas(100, 100, WEBGL);
renderer._maxTextureSize = 100 // For testing
pixelDensity(4)
console.log(width, height) // Expected: 25, 25
let fbo = createFramebuffer({ width: 100, height: 100, density: 1 })
console.log(fbo.width, fbo.height) // Expected: 100, 100
// Actually logs 25, 25
}
Live: https://editor.p5js.org/davepagurek/sketches/iwHW4IMvB
Most appropriate sub-area of p5.js?
p5.js version
2.3.0
Web browser and version
All
Operating system
All
Steps to reproduce this
Steps:
This is because we are using the renderer's density when adjusting the size, even for framebuffers:
p5.js/src/webgl/p5.RendererGL.js
Lines 444 to 461 in b96a732
We need to update this to take in the target object's density.
This is probably an issue in the WebGPU renderer too.
Snippet:
Live: https://editor.p5js.org/davepagurek/sketches/iwHW4IMvB