Skip to content

Commit 4e96c69

Browse files
Olli Etuahophemavax
authored andcommitted
Clear inside render in Aquarium VR
This makes the boundary between onAnimationFrame() and render() functions clearer. When doing stereo rendering, the initial clear is scissored so that the two halves of the framebuffer are cleared separately. This will make it possible to do multiview rendering.
1 parent b2af56e commit 4e96c69

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

aquarium-vr/aquarium-vr.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,9 @@ function initialize() {
11131113
ambient[1] = g.globals.ambientGreen;
11141114
ambient[2] = g.globals.ambientBlue;
11151115

1116-
/*
11171116
gl.colorMask(true, true, true, true);
11181117
gl.clearColor(0,0.8,1,0);
11191118
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
1120-
*/
11211119

11221120
var near = 1;
11231121
var far = 25000;
@@ -1498,12 +1496,10 @@ function initialize() {
14981496
gl.depthMask(true);
14991497
}
15001498

1501-
/*
15021499
// Set the alpha to 255.
15031500
gl.colorMask(false, false, false, true);
15041501
gl.clearColor(0,0,0,1);
15051502
gl.clear(gl.COLOR_BUFFER_BIT);
1506-
*/
15071503

15081504
// turn off logging after 1 frame.
15091505
g_logGLCalls = false;
@@ -1559,9 +1555,6 @@ function initialize() {
15591555

15601556
g_fpsTimer.update(elapsedTime);
15611557
fpsElem.innerHTML = g_fpsTimer.averageFPS;
1562-
gl.colorMask(true, true, true, true);
1563-
gl.clearColor(0,0.8,1,0);
1564-
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
15651558

15661559
if (g_vrDisplay) {
15671560
g_requestId = g_vrDisplay.requestAnimationFrame(onAnimationFrame);
@@ -1604,28 +1597,28 @@ function initialize() {
16041597
}
16051598
}
16061599
}
1607-
1600+
1601+
gl.enable(gl.SCISSOR_TEST);
16081602
gl.viewport(0, 0, canvas.width * 0.5, canvas.height);
1603+
gl.scissor(0, 0, canvas.width * 0.5, canvas.height);
16091604
render(g_frameData.leftProjectionMatrix, g_frameData.pose);
16101605

16111606
gl.viewport(canvas.width * 0.5, 0, canvas.width * 0.5, canvas.height);
1607+
gl.scissor(canvas.width * 0.5, 0, canvas.width * 0.5, canvas.height);
16121608
render(g_frameData.rightProjectionMatrix, g_frameData.pose);
16131609

16141610
g_vrDisplay.submitFrame();
16151611
} else {
1612+
gl.disable(gl.SCISSOR_TEST);
16161613
gl.viewport(0, 0, canvas.width, canvas.height);
16171614
render();
16181615
}
16191616
} else {
16201617
g_requestId = tdl.webgl.requestAnimationFrame(onAnimationFrame, canvas);
1618+
gl.disable(gl.SCISSOR_TEST);
16211619
gl.viewport(0, 0, canvas.width, canvas.height);
16221620
render();
16231621
}
1624-
1625-
// Set the alpha to 255.
1626-
gl.colorMask(false, false, false, true);
1627-
gl.clearColor(0,0,0,1);
1628-
gl.clear(gl.COLOR_BUFFER_BIT);
16291622
}
16301623

16311624
onAnimationFrame();

0 commit comments

Comments
 (0)