1 /* 2 Copyright © 2020, Inochi2D Project 3 Distributed under the 2-Clause BSD License, see LICENSE file. 4 5 Authors: Luna Nielsen 6 */ 7 module inochi2d; 8 //public import inochi2d.inochi2d; 9 public import inochi2d.math; 10 public import inochi2d.phys; 11 public import inochi2d.fmt; 12 public import inochi2d.core; 13 public import inochi2d.ver; 14 15 private double currentTime_ = 0; 16 private double lastTime_ = 0; 17 private double deltaTime_ = 0; 18 private double function() tfunc_; 19 20 /** 21 Initializes Inochi2D 22 Run this after OpenGL context has been set current 23 */ 24 void inInit(double function() timeFunc) { 25 initRenderer(); 26 tfunc_ = timeFunc; 27 } 28 29 void inSetTimingFunc(double function() timeFunc) { 30 tfunc_ = timeFunc; 31 } 32 33 /** 34 Run this at the start of your render/game loop 35 */ 36 void inUpdate() { 37 currentTime_ = tfunc_(); 38 deltaTime_ = currentTime_-lastTime_; 39 lastTime_ = currentTime_; 40 } 41 42 /** 43 Gets the time difference between the last frame and the current frame 44 */ 45 double deltaTime() { 46 return deltaTime_; 47 } 48 49 /** 50 Gets the last frame's time step 51 */ 52 double lastTime() { 53 return lastTime_; 54 } 55 56 /** 57 Gets the current time step 58 */ 59 double currentTime() { 60 return currentTime_; 61 }