I have heard that you can calculate delta time with two functions called SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency. I'm not sure how they work completely, but I heard it is a bit similar to using SDL_GetTicks()
Uint64 NOW, LAST;
double deltaTime = 0;
while (somebool)
{
LAST = SDL_GetPerformanceCounter();
NOW = SDL_GetPerformanceCounter();
LAST = NOW;
deltaTime = (NOW - LAST) / (double)SDL_GetPerformanceFrequency();
/**Rendering**/
}
I have this code but whenever I print out deltaTime or try to use it it always equals some really random and insane numbers. Is this correct?
No comments:
Post a Comment