Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
trc_timer.c File Reference
#include "trc_timer.h"
#include "SDL_timer.h"
#include <stdio.h>
#include "log.h"

Macros

#define SECONDS_TO_MILLISECONDS(X)   ((X) * 1000.0)
 
#define MILLISECONDS_TO_SECONDS(X)   ((X) / 1000.0)
 

Functions

char * timer_to_string_with_name (const trc_timer_t timer, const char *timer_name)
 
float get_actual_time_seconds (void)
 
float get_actual_time_milliseconds (void)
 
trc_timer_t create_timer (const float duration)
 
void start_timer (trc_timer_t *timer)
 
void reset_timer (trc_timer_t *timer)
 
bool is_timer_up (trc_timer_t *timer)
 

Macro Definition Documentation

◆ MILLISECONDS_TO_SECONDS

#define MILLISECONDS_TO_SECONDS (   X)    ((X) / 1000.0)

◆ SECONDS_TO_MILLISECONDS

#define SECONDS_TO_MILLISECONDS (   X)    ((X) * 1000.0)

Function Documentation

◆ create_timer()

trc_timer_t create_timer ( const float  duration)

Creates a timer object with the duration (in seconds) passed by argument

Note
It does NOT start running!
Parameters
durationThe duration (in seconds) that the timer will save

◆ get_actual_time_milliseconds()

float get_actual_time_milliseconds ( void  )

Returns the ticks elapsed in milliseconds

◆ get_actual_time_seconds()

float get_actual_time_seconds ( void  )

Returns the ticks elapsed in seconds

◆ is_timer_up()

bool is_timer_up ( trc_timer_t timer)

Returns true if the timer stops and call reset_timer with the given timer; returns false if the timer has yet not finished

Note
If the timer is inactive, the function will always return false (inactive is equal to running)
Parameters
timerA pointer to the timer to check

◆ reset_timer()

void reset_timer ( trc_timer_t timer)

Sets the timer to not running

Parameters
timerA pointer to the timer to reset

◆ start_timer()

void start_timer ( trc_timer_t timer)

Starts the given timer

Parameters
timerA pointer to the timer to start

◆ timer_to_string_with_name()

char * timer_to_string_with_name ( const trc_timer_t  timer,
const char *  timer_name 
)
Note
Remember to free the memory allocated for the string!