first commit
This commit is contained in:
57
src/COMMON.h
Normal file
57
src/COMMON.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <cglm/cglm.h>
|
||||
|
||||
#define PI (GLM_PI)
|
||||
#define PI_FOURTH (PI / 4)
|
||||
#define PI_EIGHTH (PI / 8)
|
||||
#define PI_HALF (PI / 2)
|
||||
#define TAU (PI * 2)
|
||||
#define RADIANS(x) (x * (PI / 180))
|
||||
#define RADIANS_MIN (0)
|
||||
#define RADIANS_MAX (TAU)
|
||||
|
||||
#define MIN(x, min) (x < min ? min : x)
|
||||
#define MAX(x, max) (x > max ? max : x)
|
||||
#define CLAMP(x, min, max) (MIN(MAX(x, max), min))
|
||||
|
||||
#define RANDOM_SEED_SET(seed) (srand(seed))
|
||||
#define RANDOM ((f32)rand() / (f32)RAND_MAX)
|
||||
#define RANDOM_F32(min, max) ((f32)((RANDOM * (max - min + 1)) + min))
|
||||
#define RANDOM_S32(min, max) ((s32)((RANDOM * (max - min + 1)) + min))
|
||||
#define RANDOM_BOOL() (RANDOM_S32(0, 2))
|
||||
|
||||
#define DISTANCE_2D(x1, x2, y1, y2) (sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
|
||||
#define ATAN(x1, x2, y1, y2) (fmod((atan2(y2 - y1, x2 - x1) + TAU), TAU)) /* Range between 0 and 2PI */
|
||||
|
||||
#define MILLISECOND_TICK 600
|
||||
#define SECOND_TICK 60
|
||||
#define MINUTE_TICK 3600
|
||||
#define HOUR_TICK 216000
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
typedef int8_t s8;
|
||||
typedef int16_t s16;
|
||||
typedef int32_t s32;
|
||||
typedef int64_t s64;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
typedef s32 (*SortCompareFunction)(const void*, const void*);
|
||||
|
||||
static const vec4 OPAQUE = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
static const vec4 BLACK = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
static const vec4 TRANSPARENT = {0.0f, 0.0f, 0.0f, 0.0f};
|
Reference in New Issue
Block a user