I have just looked over the api and it seem pretty reasonable, but here are some tips:
- The naming of the structs are too long (cvector2? cvec2 or even vec2 are much better)
- If you want to convince people to use your library or given proper feedback you better add C++ operator overloading and namespace support. Through ifdef you can exclude that features from native C if needed
- There are no swizzling, array, or union support (This so much more usable):
- There are no vec2i (Its not always float, sometimes there is even a double vec4d or mat4d)
- No SIMD (SSE/SSE2) implementation (This improves performance a lot, especially for mat4 operations)
Example of a better struct definition:
union vec2i {
struct {
int x, y;
};
struct {
int w, h;
};
int m[2];
};
union vec2f {
struct {
float x, y;
};
struct {
float w, h;
};
float m[2];
};
union vec4f {
struct {
union {
vec3f xyz;
struct {
float x, y, z;
};
};
float w;
};
struct {
union {
vec3f rgb;
struct {
float r, g, b;
};
};
float a;
};
struct {
vec3f xyz;
float w;
};
struct {
vec2f xy;
float ignored0;
float ignored1;
};
struct {
float ignored2;
vec2f yz;
float ignored3;
};
struct {
float ignored4;
float ignored5;
vec2f zw;
};
float m[4];
};
union mat4f {
struct {
vec4f col1;
vec4f col2;
vec4f col3;
vec4f col4;
};
float m[16];
};