-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_2.c
52 lines (44 loc) · 1.48 KB
/
time_2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* time_2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: martiper <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/08 12:26:24 by martiper #+# #+# */
/* Updated: 2023/05/08 12:30:26 by martiper ### ########.fr */
/* */
/* ************************************************************************** */
#include "time/time.h"
t_timestamp time_get_now(void)
{
return (clock() * 1000.0 / CLOCKS_PER_SEC);
}
size_t time_get_elapsed(void)
{
t_time *time;
clock_t now;
double timestamp;
time = get_time_ctx();
if (!time)
return (0);
now = clock();
timestamp = (now - time->started) * 1000.0 / CLOCKS_PER_SEC;
return ((size_t)timestamp);
}
double time_get_delta_time(void)
{
t_time *time;
time = get_time_ctx();
if (!time)
return (0);
return (time->frame.delta_time);
}
void time_def_internal_on_frame_rendered(void)
{
t_time *time;
time = get_time_ctx();
if (!time)
return ;
time->frame.frame_time = 0;
}