Skip to content

Commit

Permalink
Merge pull request #178 from Strilanc/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Strilanc committed May 30, 2016
2 parents ca3b4c4 + b396b91 commit 563da3f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/gates/CountingGates.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ CountingGates.ClockPulseGate = Gate.fromVaryingMatrix(
t => (t % 1) < 0.5 ? Matrix.identity(2) : Matrix.PAULI_X,
"Clock Pulse Gate",
"Xors a square wave into the target wire.").
markedAsOnlyPermutingAndPhasing().
withCustomDrawer(STAIRCASE_DRAWER(0, 2)).
withStableDuration(0.5);

Expand All @@ -76,6 +77,7 @@ CountingGates.QuarterPhaseClockPulseGate = Gate.fromVaryingMatrix(
t => ((t+0.75) % 1) < 0.5 ? Matrix.identity(2) : Matrix.PAULI_X,
"Clock Pulse Gate (Quarter Phase)",
"Xors a quarter-phased square wave into the target wire.").
markedAsOnlyPermutingAndPhasing().
withCustomDrawer(STAIRCASE_DRAWER(0.75, 2)).
withStableDuration(0.25);

Expand Down
20 changes: 17 additions & 3 deletions src/issues.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import {notifyAboutKnownIssue} from "src/fallback.js"

/** @returns {!boolean} */
function detectWebGlNotSupported() {
let canvas = document.createElement('canvas');
let gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
return gl === null || gl === undefined;
}

/** @returns {!boolean} */
function detectFloatTexturesNotSupported() {
return document.createElement('canvas').getContext('webgl').getExtension('OES_texture_float') === null;
let canvas = document.createElement('canvas');
let gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
return gl.getExtension('OES_texture_float') === null;
}

/** @returns {!boolean} */
function detectFloatRenderingNotSupported() {
let canvas = document.createElement('canvas');
let gl = canvas.getContext('webgl');
let gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
gl.getExtension('OES_texture_float');
let texture = gl.createTexture();
let frameBuffer = gl.createFramebuffer();
Expand All @@ -23,7 +32,12 @@ function detectFloatRenderingNotSupported() {
return gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE;
}

if (detectFloatTexturesNotSupported()) {
if (detectWebGlNotSupported()) {
notifyAboutKnownIssue(
"Can't simulate circuits. Your browser doesn't support WebGL, or has it disabled.",
"https://github.com/Strilanc/Quirk/issues/168",
[/Computing circuit values failed/, /Error creating WebGL context./])
} else if (detectFloatTexturesNotSupported()) {
notifyAboutKnownIssue(
"Can't simulate circuits. Your browser/GPU doesn't support creating floating point textures.",
"https://github.com/Strilanc/Quirk/issues/156",
Expand Down
8 changes: 7 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,13 @@ loadCircuitFromUrl();
// If the webgl initialization is going to fail, don't fail during the module loading phase.
haveLoaded = true;
setTimeout(() => {
initializedWglContext().onContextRestored = () => redrawThrottle.trigger();
redrawNow();
document.getElementById("loading-div").style.display = 'none';
try {
initializedWglContext().onContextRestored = () => redrawThrottle.trigger();
} catch (ex) {
// If that failed, the user is already getting warnings about WebGL not being supported.
// Just silently log it.
console.error(ex);
}
}, 0);

0 comments on commit 563da3f

Please sign in to comment.