{
const t0 = newTexture(seed);
const fb0 = newFramebuffer(t0);
const thalf = newTexture();
const fbhalf = newFramebuffer(thalf);
const t1 = newTexture();
const fb1 = newFramebuffer(t1);
for (let i = 0; true; ++i) {
gl.useProgram(timestepProgram);
const u_Dt = gl.getUniformLocation(timestepProgram, "u_Dt");
gl.viewport(0, 0, W, H);
for (let j = 0; j < 8; ++j) {
if (midpointIntegration) {
step(t0, t0, fbhalf, u_Dt, timestep * 0.5);
step(t0, thalf, fb1, u_Dt, timestep);
step(t1, t1, fbhalf, u_Dt, timestep * 0.5);
step(t1, thalf, fb0, u_Dt, timestep);
} else {
step(t0, t0, fb1, u_Dt, timestep);
step(t1, t1, fb0, u_Dt, timestep);
}
}
gl.useProgram(renderProgram);
gl.viewport(0, 0, canvas.width, canvas.height);
gl.bindTexture(gl.TEXTURE_2D, t0);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.drawArrays(gl.TRIANGLES, 0, 3);
yield i;
}
}