Been using OGL for a bit to create shaders. Nice library, thank you!
Problem:
The Renderer logic currently adds width and height on canvas in addition to an inline style tag:
Because of these inline styles, it isn't possible to make the canvas element responsive based on its own clientWidth. The canvas will be set up with default styles but will not reflow on resize.
// Will not work! The inline styles prevent `clientWidth` from updating.
// On first load, the canvas will be appropriately sized at 100%, but
// the element won't reflow or change sizes along with the rest of the DOM.
function updateCanvasSize() {
const { clientWidth, clientHeight } = canvas;
renderer.setSize(clientWidth, clientHeight);
}
render() {
// ...
updateCanvasSize();
}
Fix:
Do not set inline style on canvas. Allow users to update the canvas size during the render loop as illustrated in this example.
Been using OGL for a bit to create shaders. Nice library, thank you!
Problem:
The Renderer logic currently adds
widthandheightoncanvasin addition to an inlinestyletag:Because of these inline styles, it isn't possible to make the
canvaselement responsive based on its ownclientWidth. The canvas will be set up with default styles but will not reflow on resize.Fix:
Do not set inline
styleoncanvas. Allow users to update the canvas size during the render loop as illustrated in this example.