Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.52 KB | None | 0 0
  1. void init()
  2. {
  3.     lastSecond = window.performance.now();
  4.     window.requestAnimationFrame(draw);
  5. }
  6.  
  7. void draw() {
  8.  
  9.     gl.clearColor(0.8, 0.8, 0.8, 1);
  10.     gl.clearDepth(1.0);
  11.     gl.clear(COLOR_BUFFER_BIT | DEPTH_BUFFER_BIT);
  12.  
  13.     frameCounter++;
  14.     double timeNow = window.performance.now();
  15.  
  16.     if (timeNow > lastSecond + 1000)
  17.     {
  18.       e.text = ((frameCounter * 1000) / ((timeNow - lastSecond))).toStringAsFixed(2);
  19.       lastSecond = window.performance.now();
  20.      
  21.       frameCounter = 0;
  22.     }
  23.  
  24.     window.requestAnimationFrame(draw);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement