add fps limit of 30
This commit is contained in:
parent
7faeca627b
commit
efdedb23b8
1 changed files with 11 additions and 3 deletions
|
|
@ -70,21 +70,29 @@ function renderShader(gl, vsSource, fsSource) {
|
||||||
// Draw the scene
|
// Draw the scene
|
||||||
// drawScene(gl, programInfo, buffers, 0);
|
// drawScene(gl, programInfo, buffers, 0);
|
||||||
|
|
||||||
|
const fpsLimit = 30;
|
||||||
|
const fpsDelta = 1000 / 30;
|
||||||
// let timePrev = 0;
|
// let timePrev = 0;
|
||||||
// requestAnimationFrame asks the browser to call render,
|
// requestAnimationFrame asks the browser to call render,
|
||||||
// providing the time in milliseconds since the page loaded
|
// providing the time in milliseconds since the page loaded
|
||||||
function render(time) {
|
function render(time) {
|
||||||
time *= 0.001; // convert to seconds
|
time *= 0.001; // convert to seconds
|
||||||
// deltaTime = time - prevTime;
|
// delta = time - timePrev;
|
||||||
// prevTime = time;
|
|
||||||
|
|
||||||
drawScene(gl, programInfo, buffers, time);
|
drawScene(gl, programInfo, buffers, time);
|
||||||
|
|
||||||
|
setTimeout(() => requestAnimationFrame(render), fpsDelta);
|
||||||
|
}
|
||||||
|
function update() {
|
||||||
requestAnimationFrame(render);
|
requestAnimationFrame(render);
|
||||||
}
|
}
|
||||||
requestAnimationFrame(render);
|
|
||||||
|
|
||||||
// XXX: TODO: read this guide it's great! https://stackoverflow.com/questions/56998225/why-is-rendering-blurred-in-webgl
|
// XXX: TODO: read this guide it's great! https://stackoverflow.com/questions/56998225/why-is-rendering-blurred-in-webgl
|
||||||
// window.addEventListener('resize', render);
|
// window.addEventListener('resize', render);
|
||||||
|
|
||||||
|
requestAnimationFrame(render);
|
||||||
|
// update();
|
||||||
|
// setInterval(update, 1000 / fpsLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchShader(name) {
|
function fetchShader(name) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue