summaryrefslogtreecommitdiff
path: root/src/util/time.h
blob: ae696c58341ced506f279f6816d6f7df0e962c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include <SDL.h>
#include <SDL_timer.h>

#include "typedef.h"

const U32 TICK_RESOLUTION = 1000000;

inline U64 u_tick() {
  return (SDL_GetPerformanceCounter() * TICK_RESOLUTION / SDL_GetPerformanceFrequency());
}

inline F32 u_time() {
  return (F32)((F64)u_tick() / TICK_RESOLUTION);
}

inline F64 u_time64() {
  return (F64)u_tick() / TICK_RESOLUTION;
}