Skip to content

Commit b1bef2d

Browse files
authored
Merge pull request #45 from brianpeiris/fix-firefox-aquarium
Fix aquarium in Firefox. Only enable multiview when VR is supported
2 parents 167a4e3 + 64b95e3 commit b1bef2d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

aquarium/aquarium.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var g_putCount = 0;
6060

6161
var g_frameData;
6262
var g_vrUi;
63+
var g_vrSupported = false;
6364

6465
var g_multiviewFb; // multiview framebuffer.
6566
var g_multiviewViewFb; // single views inside the multiview framebuffer.
@@ -536,7 +537,7 @@ function createProgramFromTags(
536537

537538
var vs = getScriptText(vertexTagId);
538539

539-
if (multiview) {
540+
if (g_vrSupported && multiview) {
540541
// Replace shader code to get ESSL3 shader code and enable multiview (huge hack, do not do this at home kids)
541542

542543
var vsPrefix = ["#version 300 es"];
@@ -991,7 +992,7 @@ function initialize() {
991992
});
992993

993994
var particleSystem = new tdl.particles.ParticleSystem(
994-
gl, null, math.pseudoRandom);
995+
gl, null, math.pseudoRandom, g_vrSupported);
995996
setupBubbles(particleSystem);
996997
var bubbleTimer = 0;
997998
var bubbleIndex = 0;
@@ -2273,6 +2274,7 @@ $(function(){
22732274
vrButton = addButton("Enter VR", "E", vrButtonURL, onRequestPresent);
22742275
g_vrUi = new Ui(gl, g_numFish);
22752276
g_vrUi.load("./vr_assets/ui/config.js");
2277+
g_vrSupported = true;
22762278
}
22772279
});
22782280
navigator.xr.addEventListener('devicechange', onDeviceChange);

tdl/particles.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ tdl.particles.CORNERS_ = [
275275
*/
276276
tdl.particles.ParticleSystem = function(gl,
277277
opt_clock,
278-
opt_randomFunction) {
278+
opt_randomFunction,
279+
opt_vrSupported) {
279280
this.gl = gl;
280281

281282
// Entities which can be drawn -- emitters or OneShots
@@ -325,7 +326,7 @@ tdl.particles.ParticleSystem = function(gl,
325326
};
326327

327328
var multiviewShaders = [];
328-
if (gl.getExtension('OVR_multiview2')) {
329+
if (opt_vrSupported && gl.getExtension('OVR_multiview2')) {
329330
multiviewShaders.push(new tdl.shader.Shader(gl,
330331
makeShaderSourceMultiview('vs', tdl.particles.SHADER_STRINGS[0]),
331332
makeShaderSourceMultiview('fs', tdl.particles.SHADER_STRINGS[2])));

0 commit comments

Comments
 (0)