#ifndef COMMON_H #define COMMON_H #include // for size_t typedef unsigned int uint; #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) #define clamp(x, l, h) (min(max((x), (l)), (h))) #define cross(x1, y1, x2, y2) ((x1)*(y2) - (x2)*(y1)) struct xy { float x, y; }; struct xyz { float x, y, z; }; #define COLOR_WHITE 0xFFFFFF #define COLOR_BLACK 0x000000 #define COLOR_RED 0xFF0000 #define COLOR_GREEN 0x00FF00 #define COLOR_BLUE 0x0000FF #define COLOR_LIGHTWHITE 0xF5F5F5FF #define color(col) (((col)>>16) & 0xFF), (((col)>>8) & 0xFF), ((col) & 0xFF) // macro wrapper for the sdl logging system #include #define LOG_APPLICATION SDL_LOG_CATEGORY_APPLICATION #define LOG_ERROR SDL_LOG_CATEGORY_ERROR #define LOG_ASSERT SDL_LOG_CATEGORY_ASSERT #define LOG_SYSTEM SDL_LOG_CATEGORY_SYSTEM #define LOG_AUDIO SDL_LOG_CATEGORY_AUDIO #define LOG_VIDEO SDL_LOG_CATEGORY_VIDEO #define LOG_RENDER SDL_LOG_CATEGORY_RENDER #define LOG_INPUT SDL_LOG_CATEGORY_INPUT #define LOG_TEST SDL_LOG_CATEGORY_TEST #define LOG_CUSTOM SDL_LOG_CATEGORY_CUSTOM #define log(f, ...) SDL_Log(f, ##__VA_ARGS__) #define log_critical(c, f, ...) SDL_LogCritical(c, f, ##__VA_ARGS__) #define log_error(c, f, ...) SDL_LogError(c, f, ##__VA_ARGS__) #define log_warn(c, f, ...) SDL_LogWarn(c, f, ##__VA_ARGS__) #define log_info(c, f, ...) SDL_LogInfo(c, f, ##__VA_ARGS__) #define log_debug(c, f, ...) SDL_LogDebug(c, f, ##__VA_ARGS__) #define log_verbose(c, f, ...) SDL_LogVerbose(c, f, ##__VA_ARGS__) #endif