From 72916706cc39b213f84af1d4d5c314aad0d75fba Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 8 Mar 2025 20:05:05 -0800 Subject: [PATCH] Create GL canvas as part of initialization call. --- src/classes/gl.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/classes/gl.ts b/src/classes/gl.ts index 520ab89..1dbc056 100644 --- a/src/classes/gl.ts +++ b/src/classes/gl.ts @@ -12,7 +12,7 @@ export class NanoPowGl { /** Used to set canvas size. */ static #cores: number = Math.max(1, Math.floor(navigator.hardwareConcurrency)) static #WORKLOAD: number = 256 * this.#cores - static #canvas: OffscreenCanvas = new OffscreenCanvas(this.#WORKLOAD, this.#WORKLOAD) + static #canvas: OffscreenCanvas static get size () { return this.#gl?.drawingBufferWidth } static #gl: WebGL2RenderingContext | null @@ -43,6 +43,7 @@ export class NanoPowGl { this.#busy = true try { + this.#canvas = new OffscreenCanvas(this.#WORKLOAD, this.#WORKLOAD) this.#canvas.addEventListener('webglcontextlost', event => { event.preventDefault() console.warn('WebGL context lost. Waiting for it to be restored...') -- 2.34.1