Skip to content

Commit

Permalink
Fix gl attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ricktu288 committed Dec 25, 2024
1 parent dd6a401 commit c189656
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 3 additions & 13 deletions src/simulator/js/FloatColorRenderer.js
Original file line number Diff line number Diff line change
@@ -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.');
}
Expand All @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/simulator/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit c189656

Please sign in to comment.