diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-04-09 02:02:51 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-04-09 02:02:51 +0300 |
commit | fc027f7d214028086178a7328926c9b14ead464d (patch) | |
tree | d2972055a06565f26a19626ac3fb26ead84e0766 /src/common.h |
map loading done
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..d9a222f --- /dev/null +++ b/src/common.h @@ -0,0 +1,49 @@ +#ifndef COMMON_H +#define COMMON_H + +#include <stdint.h> // 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 <SDL2/SDL.h> +#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 |