Created
January 5, 2013 05:52
-
-
Save mbohun/4460018 to your computer and use it in GitHub Desktop.
defines all the different opengl vector and matrix types in a page of code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VEC_H_INCLUDED | |
#define VEC_H_INCLUDED | |
#include <stdbool.h> | |
#define VEC_H_DEF2(T) T x; T y; | |
#define VEC_H_DEF3(T) VEC_H_DEF2(T) T z; | |
#define VEC_H_DEF4(T) VEC_H_DEF3(T) T w; | |
#define VEC_H_DEF(P, NAME, T, N) \ | |
typedef struct P##NAME##N { \ | |
VEC_H_DEF##N(T) \ | |
} P##NAME##N##_t; | |
#define VEC_H_DEFS3(P2, P3, P4, NAME, T) \ | |
VEC_H_DEF(P2, NAME, T, 2) \ | |
VEC_H_DEF(P3, NAME, T, 3) \ | |
VEC_H_DEF(P4, NAME, T, 4) | |
#define VEC_H_DEFS(P, NAME, T) VEC_H_DEFS3(P, P, P, NAME, T) | |
VEC_H_DEFS(vec, , float) | |
VEC_H_DEFS(vec, d, double) | |
VEC_H_DEFS(vec, i, int) | |
VEC_H_DEFS(vec, b, bool) | |
VEC_H_DEFS3(mat , mat2x, mat2x, , vec2_t) | |
VEC_H_DEFS3(mat3x, mat , mat3x, , vec3_t) | |
VEC_H_DEFS3(mat4x, mat4x, mat , , vec4_t) | |
VEC_H_DEFS3(dmat , dmat2x, dmat2x, , dvec2_t) | |
VEC_H_DEFS3(dmat3x, dmat , dmat3x, , dvec3_t) | |
VEC_H_DEFS3(dmat4x, dmat4x, dmat , , dvec4_t) | |
#endif /* VEC_H_INCLUDED */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VEC_H_INCLUDED | |
#define VEC_H_INCLUDED | |
#include <stdbool.h> | |
#define VEC_H_DEF2(T) T x; T y; | |
#define VEC_H_DEF3(T) VEC_H_DEF2(T) T z; | |
#define VEC_H_DEF4(T) VEC_H_DEF3(T) T w; | |
#define VEC_H_STRUCT(S, T, N) \ | |
typedef struct S##N { \ | |
VEC_H_DEF##N(T) \ | |
} S##N##_t; | |
#define VEC_H_DEF(S2, S3, S4, T) \ | |
VEC_H_STRUCT(S2, T, 2) \ | |
VEC_H_STRUCT(S3, T, 3) \ | |
VEC_H_STRUCT(S4, T, 4) | |
#define VEC_H_DEFVEC(S, T) VEC_H_DEF(S, S, S, T) | |
VEC_H_DEFVEC(vec , float) | |
VEC_H_DEFVEC(dvec, double) | |
VEC_H_DEFVEC(ivec, int) | |
VEC_H_DEFVEC(bvec, bool) | |
#define VEC_H_DEFMAT(P) \ | |
VEC_H_DEF(P##mat , P##mat2x, P##mat2x, P##vec2_t) \ | |
VEC_H_DEF(P##mat3x, P##mat , P##mat3x, P##vec3_t) \ | |
VEC_H_DEF(P##mat4x, P##mat4x, P##mat , P##vec4_t) | |
VEC_H_DEFMAT() | |
VEC_H_DEFMAT(d) | |
#endif /* VEC_H_INCLUDED */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment