![]() |
cmdfx 0.2.0
Lightweight game engine for your terminal
|
Cross-Platform Utilities for CmdFX. More...
Go to the source code of this file.
Macros | |
#define | MAX_INTERNAL_CMDFX_MUTEXES 128 |
Maximum number of internal mutexes. | |
Functions | |
int | CmdFX_getTickSpeed () |
Gets the tick speed of cmdfx. | |
int | CmdFX_setTickSpeed (int tickspeed) |
Sets the tick speed of cmdfx. | |
unsigned long | currentTimeMillis () |
Gets the current time in milliseconds. | |
unsigned long long | currentTimeNanos () |
Gets the current time in nanoseconds. | |
void | sleepMillis (unsigned long millis) |
Pauses the program for a specified number of milliseconds. | |
void | sleepNanos (unsigned long long nanos) |
Pauses the program for a specified number of nanoseconds. | |
double | clamp_d (double value, double min, double max) |
Clamps a value between a minimum and maximum. | |
float | clamp_f (float value, float min, float max) |
Clamps a value between a minimum and maximum. | |
int | clamp_i (int value, int min, int max) |
Clamps a value between a minimum and maximum. | |
double | lerp_d (double a, double b, double t) |
Linearly interpolates between two values. | |
float | lerp_f (float a, float b, float t) |
Linearly interpolates between two values. | |
int | lerp_i (int a, int b, double t) |
Linearly interpolates between two values. | |
void | rgb_to_hsv (int rgb, double *h, double *s, double *v) |
Converts an RGB color to HSV. | |
int | hsv_to_rgb (double h, double s, double v) |
Converts an HSV color to RGB. | |
int | lerp_color (int rgb1, int rgb2, double t) |
Linearly interpolates between two colors. | |
int | CmdFX_initThreadSafe () |
Initializes thread-safe functions. | |
int | CmdFX_isThreadSafeEnabled () |
Checks if thread-safe functions are enabled. | |
int | CmdFX_destroyThreadSafe () |
Cleans up thread-safe functions. | |
void * | CmdFX_getInternalMutex (int index) |
Gets an internal mutex. | |
int | CmdFX_lockMutex (void *mutex) |
Locks a mutex. | |
int | CmdFX_unlockMutex (void *mutex) |
Unlocks a mutex. | |
void | CmdFX_tryLockMutex (int id) |
Tries to lock a mutex. | |
void | CmdFX_tryUnlockMutex (int id) |
Tries to unlock a mutex. | |
Cross-Platform Utilities for CmdFX.
#define MAX_INTERNAL_CMDFX_MUTEXES 128 |
Maximum number of internal mutexes.
This constant defines the maximum number of internal mutexes that can be created. It is used to limit the number of mutexes that can be created in the system.
double clamp_d | ( | double | value, |
double | min, | ||
double | max ) |
Clamps a value between a minimum and maximum.
value | The value to clamp. |
min | The minimum value. |
max | The maximum value. |
float clamp_f | ( | float | value, |
float | min, | ||
float | max ) |
Clamps a value between a minimum and maximum.
value | The value to clamp. |
min | The minimum value. |
max | The maximum value. |
int clamp_i | ( | int | value, |
int | min, | ||
int | max ) |
Clamps a value between a minimum and maximum.
value | The value to clamp. |
min | The minimum value. |
max | The maximum value. |
int CmdFX_destroyThreadSafe | ( | ) |
Cleans up thread-safe functions.
This method cleans up internal mutexes and ensures that all thread-safe operations are properly terminated. It should be called after all unsafe functions have been used or at the end of the program.
void * CmdFX_getInternalMutex | ( | int | index | ) |
Gets an internal mutex.
This method gets an internal mutex that can be used for synchronizing access to shared resources. The index should be between 0 and _MAX_INTERNAL_CMDFX_MUTEXES - 1.
index | The index of the mutex to get. |
int CmdFX_getTickSpeed | ( | ) |
Gets the tick speed of cmdfx.
The tick speed controls the rate of which ticking happens, such as the physics engine. The default value is 12.
int CmdFX_initThreadSafe | ( | ) |
Initializes thread-safe functions.
This method initializes internal mutexes and ensures thread-safe operations. It should be called before using any unsafe functions that may be accessed by multiple threads or at the start of the program.
int CmdFX_isThreadSafeEnabled | ( | ) |
Checks if thread-safe functions are enabled.
This method checks if thread-safe functions are enabled. It returns 1 if they are enabled, 0 if they are not.
int CmdFX_lockMutex | ( | void * | mutex | ) |
Locks a mutex.
This method locks a mutex, blocking the calling thread until the mutex is available.
mutex | Pointer to the platform-specific mutex object. |
int CmdFX_setTickSpeed | ( | int | tickspeed | ) |
Sets the tick speed of cmdfx.
The tick speed controls the rate of which ticking happens, such as the physics engine. The default value is 12.
tickspeed | The new tickspeed to set |
void CmdFX_tryLockMutex | ( | int | id | ) |
Tries to lock a mutex.
This method tries to lock a mutex without blocking the calling thread. If the mutex is already locked, it returns immediately.
It will also initialize the mutex if it is not already initialized.
id | The ID of the mutex to lock. |
void CmdFX_tryUnlockMutex | ( | int | id | ) |
Tries to unlock a mutex.
This method tries to unlock a mutex without blocking the calling thread. If the mutex is already unlocked, it returns immediately.
id | The ID of the mutex to unlock. |
int CmdFX_unlockMutex | ( | void * | mutex | ) |
Unlocks a mutex.
This method unlocks a mutex, allowing other threads to access the shared resource.
mutex | Pointer to the platform-specific mutex object. |
unsigned long currentTimeMillis | ( | ) |
Gets the current time in milliseconds.
unsigned long long currentTimeNanos | ( | ) |
Gets the current time in nanoseconds.
int hsv_to_rgb | ( | double | h, |
double | s, | ||
double | v ) |
Converts an HSV color to RGB.
h | The hue. |
s | The saturation. |
v | The value. |
int lerp_color | ( | int | rgb1, |
int | rgb2, | ||
double | t ) |
Linearly interpolates between two colors.
rgb1 | The first color in RGB format. |
rgb2 | The second color in RGB format. |
t | The interpolation factor. |
double lerp_d | ( | double | a, |
double | b, | ||
double | t ) |
Linearly interpolates between two values.
a | The first value. |
b | The second value. |
t | The interpolation factor. |
float lerp_f | ( | float | a, |
float | b, | ||
float | t ) |
Linearly interpolates between two values.
a | The first value. |
b | The second value. |
t | The interpolation factor. |
int lerp_i | ( | int | a, |
int | b, | ||
double | t ) |
Linearly interpolates between two values.
a | The first value. |
b | The second value. |
t | The interpolation factor. |
void rgb_to_hsv | ( | int | rgb, |
double * | h, | ||
double * | s, | ||
double * | v ) |
Converts an RGB color to HSV.
rgb | The RGB color. |
h | The pointer to the hue. |
s | The pointer to the saturation. |
v | The pointer to the value. |
void sleepMillis | ( | unsigned long | millis | ) |
Pauses the program for a specified number of milliseconds.
millis | The number of milliseconds to pause. |
void sleepNanos | ( | unsigned long long | nanos | ) |
Pauses the program for a specified number of nanoseconds.
nanos | The number of nanoseconds to pause. |