Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Nov 24, 2022
1 parent c1d2c0e commit e6d7551
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions webgl/lessons/resources/webgl-state-diagram/program-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
globals,
} from './globals.js';

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

Expand Down Expand Up @@ -338,7 +342,14 @@ function createProgramUniforms(parent, gl, program) {
locationInfos.forEach((locationInfo, ndx) => {
const {location, uniformTypeInfo} = locationInfo;
const cell = tbody.rows[ndx].cells[1];
// -- start firefox bug workaround : https://bugzilla.mozilla.org/show_bug.cgi?id=1645092
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
(globals.isWebGL2 ? useProgram2Fn : useProgram1Fn).call(gl, program);
// -- end firefox bug workaround
const value = gl.getUniform(program, location);
// -- start firefox bug workaround
(globals.isWebGL2 ? useProgram2Fn : useProgram1Fn).call(gl, currentProgram);
// -- end firefox bug workaround
updateElemAndFlashExpanderIfClosed(cell, formatUniformValue(value), !initial);
const bindPoint = uniformTypeInfo.bindPoint;
if (bindPoint) {
Expand Down

0 comments on commit e6d7551

Please sign in to comment.