2023-07-03 15:40:28 +00:00
|
|
|
#ifndef _VEC
|
|
|
|
#define _VEC
|
|
|
|
|
2023-08-09 15:27:55 +00:00
|
|
|
// 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)
|
2023-07-03 15:40:28 +00:00
|
|
|
typedef struct _vec3 {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
} vec3;
|
2023-08-09 15:27:55 +00:00
|
|
|
// (x, y, z)
|
2023-07-03 15:40:28 +00:00
|
|
|
vec3 vec3_new(float x, float y, float z);
|
2023-08-09 15:27:55 +00:00
|
|
|
// (f, f, f)
|
2023-07-03 15:40:28 +00:00
|
|
|
vec3 vec3_splat(float f);
|
2023-08-09 15:27:55 +00:00
|
|
|
// a + b
|
2023-07-03 15:40:28 +00:00
|
|
|
vec3 vec3_add(vec3 a, vec3 b);
|
2023-08-09 15:27:55 +00:00
|
|
|
// a - b
|
2023-07-03 15:40:28 +00:00
|
|
|
vec3 vec3_sub(vec3 a, vec3 b);
|
|
|
|
vec3 vec3_mult(vec3 a, float s);
|
|
|
|
|
2023-08-09 15:27:55 +00:00
|
|
|
// Some opengl extensions to support these vectors - more could be defined, but the usage of the vec struct was annoying
|
2023-07-05 08:37:27 +00:00
|
|
|
void glVertexVec(vec3 v);
|
|
|
|
void glColorVec(vec3 v);
|
|
|
|
|
2023-07-03 15:40:28 +00:00
|
|
|
#endif
|