Skip to content

Commit e6d7551

Browse files
committed
1 parent c1d2c0e commit e6d7551

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

webgl/lessons/resources/webgl-state-diagram/program-ui.js

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ import {
3939
globals,
4040
} from './globals.js';
4141

42+
// ---vvv--- firefox bug workaround: https://bugzilla.mozilla.org/show_bug.cgi?id=1645092
43+
const useProgram1Fn = WebGLRenderingContext.prototype.useProgram;
44+
const useProgram2Fn = typeof WebGL2RenderingContext !== undefined ? WebGL2RenderingContext.prototype.useProgram : undefined;
45+
// --^^^---
4246
const glEnumToString = twgl.glEnumToString;
4347
const noop = () => {};
4448

@@ -338,7 +342,14 @@ function createProgramUniforms(parent, gl, program) {
338342
locationInfos.forEach((locationInfo, ndx) => {
339343
const {location, uniformTypeInfo} = locationInfo;
340344
const cell = tbody.rows[ndx].cells[1];
345+
// -- start firefox bug workaround : https://bugzilla.mozilla.org/show_bug.cgi?id=1645092
346+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
347+
(globals.isWebGL2 ? useProgram2Fn : useProgram1Fn).call(gl, program);
348+
// -- end firefox bug workaround
341349
const value = gl.getUniform(program, location);
350+
// -- start firefox bug workaround
351+
(globals.isWebGL2 ? useProgram2Fn : useProgram1Fn).call(gl, currentProgram);
352+
// -- end firefox bug workaround
342353
updateElemAndFlashExpanderIfClosed(cell, formatUniformValue(value), !initial);
343354
const bindPoint = uniformTypeInfo.bindPoint;
344355
if (bindPoint) {

0 commit comments

Comments
 (0)