mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-18 22:29:28 -07:00
Fixing the resize logic
This commit is contained in:
@@ -38,8 +38,9 @@ export default async (canvas, config) => {
|
|||||||
await Promise.all([loadJS("lib/regl.min.js"), loadJS("lib/gl-matrix.js")]);
|
await Promise.all([loadJS("lib/regl.min.js"), loadJS("lib/gl-matrix.js")]);
|
||||||
|
|
||||||
const resize = () => {
|
const resize = () => {
|
||||||
canvas.width = Math.ceil(canvas.clientWidth * config.resolution);
|
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
||||||
canvas.height = Math.ceil(canvas.clientHeight * config.resolution);
|
canvas.width = Math.ceil(canvas.clientWidth * devicePixelRatio * config.resolution);
|
||||||
|
canvas.height = Math.ceil(canvas.clientHeight * devicePixelRatio * config.resolution);
|
||||||
};
|
};
|
||||||
window.onresize = resize;
|
window.onresize = resize;
|
||||||
if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
|
if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
|
||||||
@@ -75,7 +76,7 @@ export default async (canvas, config) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const regl = createREGL({ canvas, extensions, optionalExtensions });
|
const regl = createREGL({ canvas, pixelRatio: 1, extensions, optionalExtensions });
|
||||||
|
|
||||||
const cameraTex = regl.texture(cameraCanvas);
|
const cameraTex = regl.texture(cameraCanvas);
|
||||||
const lkg = await getLKG(config.useHoloplay, true);
|
const lkg = await getLKG(config.useHoloplay, true);
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ export default async (canvas, config) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
||||||
const canvasWidth = canvas.clientWidth * devicePixelRatio;
|
const canvasWidth = Math.ceil(canvas.clientWidth * devicePixelRatio * config.resolution);
|
||||||
const canvasHeight = canvas.clientHeight * devicePixelRatio;
|
const canvasHeight = Math.ceil(canvas.clientHeight * devicePixelRatio * config.resolution);
|
||||||
const canvasSize = [canvasWidth, canvasHeight];
|
const canvasSize = [canvasWidth, canvasHeight];
|
||||||
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
||||||
canvas.width = canvasWidth;
|
canvas.width = canvasWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user