2019-03-24 07:28:43 +00:00
|
|
|
#ifndef USEFUL_H
|
|
|
|
#define USEFUL_H
|
|
|
|
|
|
|
|
#include <switch.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-05-28 02:48:19 +00:00
|
|
|
#include "l2c.hpp"
|
|
|
|
|
2019-03-24 07:28:43 +00:00
|
|
|
#define LINKABLE __attribute__ ((weak))
|
|
|
|
|
|
|
|
#define debug_log(...) \
|
2019-05-27 19:33:40 +00:00
|
|
|
{char log_buf[0x200]; snprintf(log_buf, 0x200, __VA_ARGS__); \
|
|
|
|
svcOutputDebugString(log_buf, strlen(log_buf));}
|
2019-05-28 02:48:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rounds a number to the nearest multiple of another number.
|
|
|
|
*/
|
|
|
|
float round_to(float val, float to);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Linearly interpolates between two numbers, without bounds checking.
|
|
|
|
*/
|
|
|
|
float lerp(float min, float max, float t);
|
|
|
|
float unlerp(float min, float max, float val);
|
|
|
|
/**
|
|
|
|
* Linearly interpolates between two numbers, with bounds checking.
|
|
|
|
*/
|
|
|
|
float lerpBounded(float min, float max, float t);
|
|
|
|
float unlerpBounded(float min, float max, float val);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Linearly nterpolates between two colors, with bounds checking, accounting for gamma.
|
|
|
|
*/
|
|
|
|
Vector3f colorLerp(Vector3f minColor, Vector3f maxColor, float t, float gamma = 2.2f);
|
2019-05-27 19:33:40 +00:00
|
|
|
|
2019-03-24 07:28:43 +00:00
|
|
|
#endif // USEFUL_H
|