Add window resizing
This commit is contained in:
parent
1aea0b1221
commit
d542b2a2bc
18
window.ts
18
window.ts
@ -8,9 +8,9 @@ import { COLOR, palette } from "./colors.ts";
|
||||
|
||||
export const gameWindow = createWindow({
|
||||
title: "Faux",
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
resizable: false,
|
||||
width: 512,
|
||||
height: 512,
|
||||
resizable: true,
|
||||
glVersion: [3, 2],
|
||||
gles: true,
|
||||
});
|
||||
@ -92,16 +92,20 @@ if (status[0] === gl.FALSE) {
|
||||
|
||||
gl.ClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
addEventListener("resize", (event) => {
|
||||
gl.Viewport(0, 0, event.width, event.height);
|
||||
});
|
||||
|
||||
const pixelsPerRow = 128;
|
||||
|
||||
const top = 1;
|
||||
const left = -1;
|
||||
const cell = 2/pixelsPerRow;
|
||||
|
||||
const getHalfAsInt = (n: number) => Number(parseInt(Math.floor(n/2).toString()));
|
||||
|
||||
addEventListener("resize", (event) => {
|
||||
const {width, height} = event;
|
||||
const min = Math.min(width, height);
|
||||
gl.Viewport(getHalfAsInt(width-min), getHalfAsInt(height-min), min, min);
|
||||
});
|
||||
|
||||
const px = (x: number, y: number) => {
|
||||
// deno-fmt-ignore
|
||||
return [
|
||||
|
Loading…
x
Reference in New Issue
Block a user