From 1fc8e8dbebb1a0973fd92a32860e71c01f8d408a Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Thu, 28 Mar 2019 09:34:35 -0700 Subject: [PATCH] WebGL fix for "createContext is not a function". One of the recent releases of emsdk moved its GL-related utility methods into an object called GL, previously it exposed them directly. This change also makes it so that we create the WebGL 2.0 context and register it with emscripten, rather than the other way around. Note that our CI does "emsdk activate latest", not sure when this broke exactly. --- web/filament-js/extensions.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/filament-js/extensions.js b/web/filament-js/extensions.js index d95ccee7ce..c863abf8f1 100644 --- a/web/filament-js/extensions.js +++ b/web/filament-js/extensions.js @@ -43,12 +43,16 @@ Filament.loadClassExtensions = function() { alpha: false }; options = Object.assign(defaults, options); - Filament.createContext(canvas, true, true, options); + + // Create the WebGL 2.0 context and register it with emscripten. + const ctx = canvas.getContext("webgl2", options); + const handle = GL.registerContext(ctx, options); + GL.makeContextCurrent(handle); // Enable all desired extensions by calling getExtension on each one. - Filament.ctx.getExtension('WEBGL_compressed_texture_s3tc'); - Filament.ctx.getExtension('WEBGL_compressed_texture_astc'); - Filament.ctx.getExtension('WEBGL_compressed_texture_etc'); + ctx.getExtension('WEBGL_compressed_texture_s3tc'); + ctx.getExtension('WEBGL_compressed_texture_astc'); + ctx.getExtension('WEBGL_compressed_texture_etc'); return Filament.Engine._create(); };