#pragma once #include #define Assert(condition, message) do { assert(condition && message); } while(0) // generic defines #define KB(n) n * 1024LL #define MB(n) KB(n) * 1024LL #define GB(n) MB(n) * 1024LL #define TB(n) GB(n) * 1024LL #define DEFAULT_ALIGNMENT (2*sizeof(rawptr)) #define Len(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) #define MakeString(x) #x #define BitEq(var, bits) (((var) & (bits)) == bits) #define AlignPow2(x, b) (((x) + (b) - 1) & (~((b) - 1))) #define IsPow2(x) ((x) != 0 && ((x) &((x) - 1)) == 0) #define PtrAdd(ptr, add) (((char *)ptr) + add) // Types typedef union { struct { f32 r, g; }; struct { f32 x, y; }; } Vec2; typedef union { struct { f32 x, y, z; }; struct { f32 r, g, b; }; } Vec3; typedef union { struct { f32 x, y, z, w; }; struct { f32 r, g, b, a; }; } Vec4; typedef union { struct { i32 x, y; }; struct { i32 r, g; }; } iVec2; typedef union { struct { i32 x, y, z; }; struct { i32 r, g, b; }; } iVec3; typedef union { struct { i32 x, y, z, w; }; struct { i32 r, g, b, a; }; } iVec4; typedef f32 Mat2[4]; typedef f32 Mat3[9]; typedef f32 Mat4[16]; typedef f64 dMat2[4]; typedef f64 dMat3[9]; typedef f64 dMat4[16]; // String Functions u32 StrLen(const char *str); b32 StrEq(const char *l, const char *r); i32 SPrintf(char *buf, rawptr fmt, ...); // Memory Functions void MemZero(void *ptr, isize size); // Math Functions u32 u32Min(u32 l, u32 r); i32 i32Min(i32 l, i32 r); u32 u32Max(u32 l, u32 r); i32 i32Max(i32 l, i32 r); i32 i32Clamp(i32 v, i32 min, i32 max); u32 u32Clamp(u32 v, u32 min, u32 max);