diff --git a/src/simulator/js/FloatColorRenderer.js b/src/simulator/js/FloatColorRenderer.js index 2cb723e3..f56aec9d 100644 --- a/src/simulator/js/FloatColorRenderer.js +++ b/src/simulator/js/FloatColorRenderer.js @@ -1,16 +1,6 @@ class FloatColorRenderer { - constructor(ctx, origin, scale, lengthScale) { - const contextAttributes = { - alpha: true, - depth: false, - stencil: false, - antialias: false, - preserveDrawingBuffer: true, - premultipliedAlpha: false, - failIfMajorPerformanceCaveat: false - }; - this.gl = ctx.canvas.getContext('webgl', contextAttributes) || - ctx.canvas.getContext('experimental-webgl', contextAttributes); + constructor(gl, origin, scale, lengthScale) { + this.gl = gl; if (!this.gl) { throw new Error('Unable to initialize WebGL. Your browser may not support it.'); } @@ -21,7 +11,7 @@ class FloatColorRenderer { throw new Error('OES_texture_float not supported'); } - this.canvas = ctx.canvas; + this.canvas = gl.canvas; this.origin = origin; this.scale = scale; this.lengthScale = lengthScale; diff --git a/src/simulator/js/app.js b/src/simulator/js/app.js index 3407662d..0788280f 100644 --- a/src/simulator/js/app.js +++ b/src/simulator/js/app.js @@ -127,7 +127,12 @@ async function startApp() { if (useFloatColorRenderer) { try { - var gl = canvasLight.getContext('webgl') || canvasLight.getContext('experimental-webgl'); + const contextAttributes = { + alpha: true, + premultipliedAlpha: true, + antialias: false, + }; + var gl = canvasLight.getContext('webgl', contextAttributes) || canvasLight.getContext('experimental-webgl', contextAttributes); var ext = gl.getSupportedExtensions('OES_texture_float'); if (!ext) { throw new Error('OES_texture_float not supported');