Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- utils.h
- #ifndef GFX_UTILS_H
- #define GFX_UTILS_H
- // Concatenation
- #define CAT_BAD(x,y) x ## y
- #define CAT(x,y) CAT_BAD(x,y)
- // Template naming
- #define NAME_BAD(x,y) x ## _ ## y
- #define NAME(x,y) NAME_BAD(x,y)
- #endif // GFX_UTILS_H
- vec.h
- #ifndef GFX_MATH_VEC_H
- #define GFX_MATH_VEC_H
- #include "Groufix/utils.h"
- // One worded datatypes
- typedef unsigned char uchar;
- typedef unsigned short ushort;
- typedef unsigned int uint;
- #endif // GFX_MATH_VEC_H
- /////////////////////////////////////////////////
- // Load all default sizes
- /////////////////////////////////////////////////
- #if !defined(VEC_SIZE)
- // Default 2D vector
- #define VEC_SIZE 2
- #include "Groufix/Math/vec.h"
- #undef VEC_SIZE
- // Default 3D vector
- #define VEC_SIZE 3
- #include "Groufix/Math/vec.h"
- #undef VEC_SIZE
- // Default 4D vector
- #define VEC_SIZE 4
- #include "Groufix/Math/vec.h"
- #undef VEC_SIZE
- /////////////////////////////////////////////////
- // Load all default datatypes
- /////////////////////////////////////////////////
- #elif !defined(VEC_TYPE)
- #define VEC_TYPE char
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), c);
- #undef VEC_TYPE
- #define VEC_TYPE uchar
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), uc);
- #undef VEC_TYPE
- #define VEC_TYPE short
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), s);
- #undef VEC_TYPE
- #define VEC_TYPE ushort
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), us);
- #undef VEC_TYPE
- #define VEC_TYPE int
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), i);
- #undef VEC_TYPE
- #define VEC_TYPE uint
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), ui);
- #undef VEC_TYPE
- #define VEC_TYPE float
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), f);
- #undef VEC_TYPE
- #define VEC_TYPE double
- #include "Groufix/Math/vec.h"
- typedef VEC_NAME CAT(CAT(vec, VEC_SIZE), d);
- #undef VEC_TYPE
- #else
- // Name & Function
- #undef VEC_NAME
- #undef VEC_FUNC
- #define VEC_NAME NAME(CAT(vec, VEC_SIZE), VEC_TYPE)
- #define VEC_FUNC(postfix) NAME(VEC_NAME, postfix)
- typedef VEC_TYPE VEC_NAME[VEC_SIZE];
- #endif
Advertisement
Add Comment
Please, Sign In to add comment