Fixing the resize logic

This commit is contained in:
Rezmason
2022-10-04 21:52:44 -07:00
parent 6986ed45f5
commit 507f907096
2 changed files with 6 additions and 5 deletions

View File

@@ -38,8 +38,9 @@ export default async (canvas, config) => {
await Promise.all([loadJS("lib/regl.min.js"), loadJS("lib/gl-matrix.js")]);
const resize = () => {
canvas.width = Math.ceil(canvas.clientWidth * config.resolution);
canvas.height = Math.ceil(canvas.clientHeight * config.resolution);
const devicePixelRatio = window.devicePixelRatio ?? 1;
canvas.width = Math.ceil(canvas.clientWidth * devicePixelRatio * config.resolution);
canvas.height = Math.ceil(canvas.clientHeight * devicePixelRatio * config.resolution);
};
window.onresize = resize;
if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
@@ -75,7 +76,7 @@ export default async (canvas, config) => {
break;
}
const regl = createREGL({ canvas, extensions, optionalExtensions });
const regl = createREGL({ canvas, pixelRatio: 1, extensions, optionalExtensions });
const cameraTex = regl.texture(cameraCanvas);
const lkg = await getLKG(config.useHoloplay, true);

View File

@@ -115,8 +115,8 @@ export default async (canvas, config) => {
}
const devicePixelRatio = window.devicePixelRatio ?? 1;
const canvasWidth = canvas.clientWidth * devicePixelRatio;
const canvasHeight = canvas.clientHeight * devicePixelRatio;
const canvasWidth = Math.ceil(canvas.clientWidth * devicePixelRatio * config.resolution);
const canvasHeight = Math.ceil(canvas.clientHeight * devicePixelRatio * config.resolution);
const canvasSize = [canvasWidth, canvasHeight];
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
canvas.width = canvasWidth;