From d3fa95fa4bb1ea370721e093548624fc619c5976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niilo=20Kein=C3=A4nen?= Date: Tue, 10 Jan 2023 08:47:34 +0200 Subject: [PATCH] Return null when gl context not available --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 5603559..a41afb9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,9 @@ dom.window.HTMLCanvasElement.prototype.getContext = function () { if (arguments[0] === 'webgl') { // create headless-gl GL context const ctx: ReturnType & Partial = createContext(1, 1, arguments[1]) + if (!ctx) { + return ctx + } // insert the resize method to the context so that lcjs package can use it ctx.resize = ctx.getExtension('STACKGL_resize_drawingbuffer').resize return ctx