Created
June 27, 2012 12:35
-
-
Save KAYLukas/3003815 to your computer and use it in GitHub Desktop.
new fps implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double frame(){ | |
double t = glfwGetTime(); | |
static double oldt; | |
double dt = t - oldt; | |
oldt = t; | |
static double time_between_frames; | |
//Determine the weight on the amount of fps, so that every second always has a equal weight. | |
int weight = (int) (1.0/time_between_frames); | |
weight /= 10; | |
if(weight < 3){ | |
weight = 3; | |
} | |
time_between_frames = (weight*time_between_frames + dt)/(weight+1); | |
return 1.0/time_between_frames; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ik denk dat het wel veilig is om de timing naar doubles om te zetten. De aanpassingen voor de serializatie zijn nog wel te doen. Let op FRATE, ElapsedTime en de FPS class. Deze moeten aangepast worden om met het nieuwe systeem te werken.