#include #include #include #include #include #include #include #include #include #include #include "raygui.h" #ifndef UTIL_H #define UTIL_H //#define FT_DEBUG_MODE #define FT_NAMEMAX 256 // Memory management. #define FT_MALLOC(size) malloc(size) #define FT_CALLOC(nmemb, size) calloc(nmemb, size) #define FT_REALLOC(ptr, size) realloc(ptr, size) #define FT_REALLOCARRAY(ptr, nmemb, size) reallocarray(ptr, nmemb, size) //#define FT_REALLOCARRAY(ptr, nmemb, size) realloc(ptr, nmemb * size) #define FT_FREE(ptr) free(ptr) // Errors. #define ALLOCATION_ERROR TraceLog(LOG_ERROR, "Allocation error in %s:%d", \ __FILE__, __LINE__) #define PLATFORM_DESKTOP // GLSL version #ifdef PLATFORM_DESKTOP #define GLSL_VERSION 330 #else // PLATFORM_ANDROID, PLATFORM_WEB #define GLSL_VERSION 100 #endif // Bit shit. #define SET_BIT(b, n) (b | (0x1 << n)) #define CLEAR_BIT(b, n) (b & ~(0x1 << n)) #define IS_BIT_SET(b, n) ((b >> n) & 0x1) #define TOGGLE_BIT(b, n) (b ^ (0x1 << n)) #define HAS_FLAG(v, f) ((v & f) == f) // https://en.wikipedia.org/wiki/Linear_congruential_generator #define FT_RANDOM16(seed) (seed = (75 * seed + 74) % 65537) #define FT_RANDOM32(seed) (seed = (1664525 * seed + 1013904223) % 4294967296) // Helpful for debugging #define PRINT_VECTOR2(v) printf("%f %f\n", v.x, v.y) #define PRINT_VECTOR3(v) printf("%f %f %f\n", v.x, v.y, v.z) // Typedef hackery. typedef struct Game Game; typedef struct World World; typedef enum FTError { FTERROR = -1, FTSUCCESS = 0 } FTError; Vector2 randomDirection2(int seed, int* nextSeed); Vector3 randomDirection3(int seed, int* nextSeed); #endif