From 5c4d5b8c30616f23583d2d81fa846e4b7bf9185a Mon Sep 17 00:00:00 2001 From: Matthew Owens Date: Tue, 6 Oct 2020 20:21:45 +0100 Subject: [PATCH] additional types --- math_3d.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/math_3d.h b/math_3d.h index cdc6101..32873fc 100644 --- a/math_3d.h +++ b/math_3d.h @@ -96,8 +96,22 @@ v1.0 2016-02-15 Initial release // So you can just upload the vectors into shaders as they are. // +typedef struct { float x, y; } vec2_t; typedef struct { float x, y, z; } vec3_t; +typedef struct { float w, x, y, z; } vec4_t; + +typedef struct { int x, y; } vec2i_t; +typedef struct { int x, y, z; } vec3i_t; +typedef struct { int w, x, y, z; } vec4i_t; + static inline vec3_t vec3(float x, float y, float z) { return (vec3_t){ x, y, z }; } +static inline vec2_t vec2(float x, float y) { return (vec2_t){ x, y }; } +static inline vec4_t vec4(float w, float x,float y,float z) { return (vec4_t){ w, x, y, z }; } + +static inline vec3i_t vec3i(int x, int y, int z) { return (vec3i_t){ x, y, z }; } +static inline vec2i_t vec2i(int x, int y) { return (vec2i_t){ x, y }; } +static inline vec4i_t vec4i(int w, int x,int y,int z) { return (vec4i_t){ w, x, y, z }; } + static inline vec3_t v3_add (vec3_t a, vec3_t b) { return (vec3_t){ a.x + b.x, a.y + b.y, a.z + b.z }; } static inline vec3_t v3_adds (vec3_t a, float s) { return (vec3_t){ a.x + s, a.y + s, a.z + s }; } @@ -624,4 +638,4 @@ void m4_fprintp(FILE* stream, mat4_t matrix, int width, int precision) { } } -#endif // MATH_3D_IMPLEMENTATION \ No newline at end of file +#endif // MATH_3D_IMPLEMENTATION -- 2.20.1