print out fps
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -133,8 +133,21 @@ function initFBO() {
|
|||||||
|
|
||||||
/** Update/Draw function. Targeting 60UPS. */
|
/** Update/Draw function. Targeting 60UPS. */
|
||||||
var timeSpent = 0.0;
|
var timeSpent = 0.0;
|
||||||
|
/** Framerate measurement variables */
|
||||||
|
var lastTime = new Date().getTime();
|
||||||
|
var counter = 0.0;
|
||||||
|
var fps = 0;
|
||||||
function drawScene(buffer: WebGLBuffer, program: WebGLProgram) {
|
function drawScene(buffer: WebGLBuffer, program: WebGLProgram) {
|
||||||
timeSpent += 1.0 / 60.0;
|
timeSpent += 1.0 / 60.0;
|
||||||
|
fps++;
|
||||||
|
let now = new Date();
|
||||||
|
let delta = now.getTime() - lastTime;
|
||||||
|
if ((counter += delta) >= 1000.) {
|
||||||
|
counter = 0;
|
||||||
|
console.log("FPS: " + fps);
|
||||||
|
fps = 0;
|
||||||
|
}
|
||||||
|
lastTime = now.getTime();
|
||||||
// Two Rendering passes. The first one generates a perlin noise
|
// Two Rendering passes. The first one generates a perlin noise
|
||||||
// texture. Second one uses the textur for vertex displacement
|
// texture. Second one uses the textur for vertex displacement
|
||||||
// of a grid representing the water surface.
|
// of a grid representing the water surface.
|
||||||
|
|||||||
Reference in New Issue
Block a user