-
Notifications
You must be signed in to change notification settings - Fork 46
/
timer.c
58 lines (45 loc) · 902 Bytes
/
timer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "timer.h"
#include "lutro.h"
#include <stdlib.h>
#include <string.h>
int lutro_timer_preload(lua_State *L)
{
static luaL_Reg gfx_funcs[] = {
{ "getTime", timer_getTime },
{ "getDelta", timer_getDelta },
{ "getFPS", timer_getFPS },
{NULL, NULL}
};
lutro_ensure_global_table(L, "lutro");
luaL_newlib(L, gfx_funcs);
lua_setfield(L, -2, "timer");
return 1;
}
void lutro_timer_init()
{
}
int timer_getTime(lua_State *L)
{
lua_pushnumber(L, perf_cb.get_time_usec() / 1000000.0);
return 1;
}
/**
* lutro.timer.getDelta()
*
* @see https://love2d.org/wiki/love.timer.getDelta
*/
int timer_getDelta(lua_State *L)
{
lua_pushnumber(L, settings.delta);
return 1;
}
/**
* lutro.timer.getFPS()
*
* @see https://love2d.org/wiki/love.timer.getFPS
*/
int timer_getFPS(lua_State *L)
{
lua_pushnumber(L, settings.fps);
return 1;
}