world_of_cow/vec.h

29 lines
955 B
C

#ifndef _VEC
#define _VEC
// Vectors and matrices are really useful when doing 2D/3D, esp in games
// sadly, i did not really need much more than that, and even the limited usage i had was not as fun as usual
// because the way C doesnt allow to define different operators for structs(that is, i cannot do vec3 + vec3)
// I know i could have chosen to use c++ or python but i oppose using c++ and decided to take the opportunity to work
// on my C programming skills(and i also dont like python)
typedef struct _vec3 {
float x;
float y;
float z;
} vec3;
// (x, y, z)
vec3 vec3_new(float x, float y, float z);
// (f, f, f)
vec3 vec3_splat(float f);
// a + b
vec3 vec3_add(vec3 a, vec3 b);
// a - b
vec3 vec3_sub(vec3 a, vec3 b);
vec3 vec3_mult(vec3 a, float s);
// Some opengl extensions to support these vectors - more could be defined, but the usage of the vec struct was annoying
void glVertexVec(vec3 v);
void glColorVec(vec3 v);
#endif