Skip to content

Commit

Permalink
Updated makefile and fixed dynamic libraries compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Jul 17, 2022
1 parent 83e3137 commit e34d217
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 55 deletions.
14 changes: 14 additions & 0 deletions HPML.makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: debug
.PHONY: release
.PHONY: clean
.PHONY: MESSAGE

MESSAGE:
@echo [Log] Building HPML internals

debug: MESSAGE

release: MESSAGE

clean:
@echo [Log] Cleaning HPML internals
8 changes: 8 additions & 0 deletions include/hpml/affine_transformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <hpml/mat4.h> // mat4_t
#include <hpml/vec4.h> // vec4_t

#ifdef __cplusplus
extern "C" {
#endif

/* mat4_rotation: Creates a euler angles rotation matrix
* x: angle of rotation around x-axis in radians
* y: angle of rotation around y-axis in radians
Expand Down Expand Up @@ -175,3 +179,7 @@ HPML_API mat4_t mat4_axis_rotation(float angle, float x, float y, float z);
* returns: mat4_t shear matrix in 3D space
*/
HPML_API mat4_t mat4_shear(float xy_angle, float yx_angle, float zx_angle, float xz_angle, float yz_angle, float zy_angle);

#ifdef __cplusplus
}
#endif
14 changes: 11 additions & 3 deletions include/hpml/mat2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ typedef union mat2_t

#define MAT2 (mat2_t)

#ifdef __cplusplus
extern "C" {
#endif

/* mat2_identity: Creates an identity matrix of order 2x2
returns: 2x2 identity matrix
*/
static HPML_API HPML_FORCE_INLINE mat2_t mat2_identity() { return MAT2 { 1, 0, 0, 1 }; }
static HPML_FORCE_INLINE mat2_t mat2_identity() { return MAT2 { 1, 0, 0, 1 }; }

/* mat2: mat2 contructor taking four parameter to initialize the components
* float v0: element at [0, 0] -> [Row, Column]
Expand All @@ -36,7 +40,7 @@ static HPML_API HPML_FORCE_INLINE mat2_t mat2_identity() { return MAT2 { 1, 0, 0
* float v3: element at [1, 0] -> [Row, Column]
* returns: mat2_t initialized matrix
*/
static HPML_API HPML_FORCE_INLINE mat2_t mat2(float v0, float v1, float v2, float v3)
static HPML_FORCE_INLINE mat2_t mat2(float v0, float v1, float v2, float v3)
{
return MAT2 { v0, v1, v2, v3 };
}
Expand All @@ -45,7 +49,7 @@ static HPML_API HPML_FORCE_INLINE mat2_t mat2(float v0, float v1, float v2, floa
* mat2_t m: Matrix of which the trace to be calculated
* returns: float trace value
*/
static HPML_API HPML_FORCE_INLINE float mat2_trace(mat2_t m)
static HPML_FORCE_INLINE float mat2_trace(mat2_t m)
{
return m.m0 + m.m3;
}
Expand Down Expand Up @@ -143,3 +147,7 @@ HPML_API mat2_t mat2_rotation(float angle);

/* mat2_print */
HPML_API void mat2_print(mat2_t m);

#ifdef __cplusplus
}
#endif
22 changes: 15 additions & 7 deletions include/hpml/mat4.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ typedef struct mat4_t

#define MAT4 (mat4_t)

#ifdef __cplusplus
extern "C" {
#endif

/* mat4: mat4 contructor taking 16 parameter to initialize the components
* float v00: element at [0, 0] -> [Row, Column]
* float v01: element at [0, 1] -> [Row, Column]
Expand All @@ -57,7 +61,7 @@ typedef struct mat4_t
* float v33: element at [3, 3] -> [Row, Column]
* returns: mat4_t initialized matrix
*/
static HPML_API HPML_FORCE_INLINE mat4_t mat4(float v00, float v01, float v02, float v03,
static HPML_FORCE_INLINE mat4_t mat4(float v00, float v01, float v02, float v03,
float v10, float v11, float v12, float v13,
float v20, float v21, float v22, float v23,
float v30, float v31, float v32, float v33)
Expand Down Expand Up @@ -86,7 +90,7 @@ HPML_API float* const* const __mat4_data(mat4_t* m);
* NOTE: this function doesn't support rvalue src matrix; use mat4_move instead
*/
#define mat4_copy(dest, src) __mat4_copy(&(dest), &(src))
static HPML_API HPML_FORCE_INLINE void __mat4_copy(mat4_t* const dest, const mat4_t* const src)
static HPML_FORCE_INLINE void __mat4_copy(mat4_t* const dest, const mat4_t* const src)
{
/*
TODO: This should be like this:
Expand All @@ -101,7 +105,7 @@ static HPML_API HPML_FORCE_INLINE void __mat4_copy(mat4_t* const dest, const mat
* returns: nothing
*/
#define mat4_move(dst, src) __mat4_move(&(dst), src)
static HPML_API HPML_FORCE_INLINE void __mat4_move(mat4_t* const dest, const mat4_t src)
static HPML_FORCE_INLINE void __mat4_move(mat4_t* const dest, const mat4_t src)
{
__mat4_copy(dest, &src);
}
Expand Down Expand Up @@ -133,15 +137,15 @@ HPML_API void mat4_build_cofactor(mat4_t m, float* const* const cofactorMatrix,
/* mat4_identity: constructs a 4x4 identity matrix
* returns: identity matrix of order 4x4
*/
static HPML_API HPML_FORCE_INLINE mat4_t mat4_identity()
static HPML_FORCE_INLINE mat4_t mat4_identity()
{
return mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}

/* mat4_null: Creates a null or zero matrix
* returns: a 4x4 matrix having all entries equal to zero
*/
static HPML_API HPML_FORCE_INLINE mat4_t mat4_null() { return mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); }
static HPML_FORCE_INLINE mat4_t mat4_null() { return mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); }
#define mat4_zero mat4_null


Expand All @@ -153,7 +157,7 @@ static HPML_API HPML_FORCE_INLINE mat4_t mat4_null() { return mat4(0, 0, 0, 0, 0
* returns: mat4_t 4x4 diagonal matrix
*/

static HPML_API HPML_FORCE_INLINE mat4_t mat4_diagonal(float x, float y, float z, float w)
static HPML_FORCE_INLINE mat4_t mat4_diagonal(float x, float y, float z, float w)
{
return MAT4
{
Expand All @@ -168,7 +172,7 @@ static HPML_API HPML_FORCE_INLINE mat4_t mat4_diagonal(float x, float y, float z
* mat4_t m: Matrix of which the trace to be calculated
* returns: float trace value
*/
static HPML_API HPML_FORCE_INLINE float mat4_trace(mat4_t m)
static HPML_FORCE_INLINE float mat4_trace(mat4_t m)
{
return m.m00 + m.m11 + m.m22 + m.m33;
}
Expand Down Expand Up @@ -254,3 +258,7 @@ HPML_API mat4_t mat4_inverse(mat4_t m);

/* mat4_print */
HPML_API void mat4_print(mat4_t m);

#ifdef __cplusplus
}
#endif // __cplusplus
18 changes: 13 additions & 5 deletions include/hpml/quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,27 @@ typedef struct quat_t

#define QUAT (quat_t)

#ifdef __cplusplus
extern "C" {
#endif

/* quat : constructs a quat_t instance
x, y, z, w : components of the quaternion
returns: an initialized instance of quat_t struct
*/
static HPML_API HPML_FORCE_INLINE quat_t quat(float x, float y, float z, float w) { return QUAT { x, y, z, w }; }
static HPML_FORCE_INLINE quat_t quat(float x, float y, float z, float w) { return QUAT { x, y, z, w }; }

/*
quat_identity : consturcts an identity quaternion instance
returns: identity quaternion
*/
static HPML_API HPML_FORCE_INLINE quat_t quat_identity() { return quat(0, 0, 0, 1); }
static HPML_FORCE_INLINE quat_t quat_identity() { return quat(0, 0, 0, 1); }

/*
quat_zero : constructs a null quaternion instance
returns : null quaternion
*/
static HPML_API HPML_FORCE_INLINE quat_t quat_zero() { return quat(0, 0, 0, 0); }
static HPML_FORCE_INLINE quat_t quat_zero() { return quat(0, 0, 0, 0); }

/* quat_add : adds variable number of quaternions into q (quat_t)
count : number of variable quaternions to add
Expand Down Expand Up @@ -107,7 +111,7 @@ HPML_API quat_t __quat_div(quat_t q1, quat_t q2);
s : scalar floating point value
returns : q * s
*/
static HPML_API HPML_FORCE_INLINE quat_t quat_mul_scalar(quat_t q, float s) { return quat(q.x * s, q.y * s, q.z * s, q.w * s); }
static HPML_FORCE_INLINE quat_t quat_mul_scalar(quat_t q, float s) { return quat(q.x * s, q.y * s, q.z * s, q.w * s); }

/* quat_difference : calculates the rotation difference between two quaternions q1 and q2
q1 : first quaternion (final rotation)
Expand All @@ -131,7 +135,7 @@ HPML_API quat_t quat_inverse(quat_t q);
q : original quaternion
returns : conjugate of the quaterion 'q'
*/
static HPML_API HPML_FORCE_INLINE quat_t quat_conjugate(quat_t q) { return quat(-q.x, -q.y, -q.z, q.w); }
static HPML_FORCE_INLINE quat_t quat_conjugate(quat_t q) { return quat(-q.x, -q.y, -q.z, q.w); }
#define quat_conj(x) quat_conjugate(x)

/*
Expand Down Expand Up @@ -267,3 +271,7 @@ HPML_API bool quat_equal(quat_t q1, quat_t q2);
/* For debugging purpose */

HPML_API void quat_print(quat_t q);

#ifdef __cplusplus
}
#endif // __cplusplus
20 changes: 14 additions & 6 deletions include/hpml/vec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,36 @@ typedef struct vec2_t

#define VEC2 (vec2_t)

#ifdef __cplusplus
extern "C" {
#endif

/* vec2: Creates vector2 object in memory taking two arguments
* x: x-component
* y: y-component
* returns: vec_t vector having x, y
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2(float x, float y) { return VEC2 { x, y }; }
static HPML_FORCE_INLINE vec2_t vec2(float x, float y) { return VEC2 { x, y }; }

/* vec2_right: Returns the right direction vector (vector2)
* returns: vec2_t right direction, i.e. Vector2.right [+ve x axis direction]
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2_right() { return vec2(1, 0); }
static HPML_FORCE_INLINE vec2_t vec2_right() { return vec2(1, 0); }

/* vec2_left: Returns the left direction vector (vector2)
* returns: vec2_t left direction, i.e. Vector2.left [-ve x axis direction]
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2_left() { return vec2(-1, 0); }
static HPML_FORCE_INLINE vec2_t vec2_left() { return vec2(-1, 0); }

/* vec2_down: Returns the down direction vector (vector2)
* returns: vec2_t down direction, i.e. Vector2.down [-ve y axis direction]
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2_down() { return vec2(0, -1); }
static HPML_FORCE_INLINE vec2_t vec2_down() { return vec2(0, -1); }

/* vec2_up: Returns the up direction vector (vector2)
* returns: vec2_t up direction, i.e. Vector2.up [+ve y axis direction]
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2_up() { return vec2(0, 1); }
static HPML_FORCE_INLINE vec2_t vec2_up() { return vec2(0, 1); }


/* vec2_slerp: Calculates the spherical interpolation value in between vector v1 and v2
Expand Down Expand Up @@ -154,7 +158,7 @@ HPML_API float vec2_dot(vec2_t v1, vec2_t v2);
/* vec2_null: Creates a vector2 object in memory having x = 0, and y = 0
* returns: vec2_t vector having x = 0, y = 0
*/
static HPML_API HPML_FORCE_INLINE vec2_t vec2_null() { return vec2(0, 0); }
static HPML_FORCE_INLINE vec2_t vec2_null() { return vec2(0, 0); }

/* vec2_is_null: Checks if passed vector2 is null or not
* vec2_t v: vector2 to be checked for
Expand Down Expand Up @@ -202,3 +206,7 @@ HPML_API vec2_t vec2_div(vec2_t v1, vec2_t v2);

/* For debugging purpose */
HPML_API void vec2_print(vec2_t v);

#ifdef __cplusplus
}
#endif // extern "C"
18 changes: 9 additions & 9 deletions include/hpml/vec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,43 @@ typedef union

/*CONSTRUCTOR*/
/*vec3*/
HPML_API HPML_FORCE_INLINE vec3_t vec3(float x, float y, float z) { return (vec3_t) { x, y, z }; }
HPML_FORCE_INLINE vec3_t vec3(float x, float y, float z) { return (vec3_t) { x, y, z }; }

/* vec3_zero: Creates a vector3 object in memory having x = 0, and y = 0
* returns: vec3_t vector having x = 0, y = 0
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_zero() { return (vec3_t) { 0, 0, 0 }; }
HPML_FORCE_INLINE vec3_t vec3_zero() { return (vec3_t) { 0, 0, 0 }; }

/* vec3_up: Returns the up direction vector (vector3)
* returns: vec3_t up direction, i.e. Vector4.up [+ve y axis direction]
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_up() { return (vec3_t) { 0, 1, 0 }; }
HPML_FORCE_INLINE vec3_t vec3_up() { return (vec3_t) { 0, 1, 0 }; }

/* vec3_down: Returns the down direction vector (vector3)
* returns: vec3_t down direction, i.e. Vector4.down [-ve y axis direction]
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_down() { return (vec3_t) { 0, -1, 0 }; }
HPML_FORCE_INLINE vec3_t vec3_down() { return (vec3_t) { 0, -1, 0 }; }

/* vec3_right: Returns the right direction vector (vector3)
* returns: vec3_t right direction, i.e. Vector4.right [+ve x axis direction]
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_right() { return (vec3_t) { 1, 0, 0 }; }
HPML_FORCE_INLINE vec3_t vec3_right() { return (vec3_t) { 1, 0, 0 }; }

/*vec3_left*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_left() { return (vec3_t) { -1, 0, 0 }; }
HPML_FORCE_INLINE vec3_t vec3_left() { return (vec3_t) { -1, 0, 0 }; }

/* vec3_forward: Returns the forward direction vector (vector3)
* returns: vec3_t forward direction, i.e. Vector4.forward [+ve z axis direction]
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_forward() { return (vec3_t) { 0, 0, 1 }; }
HPML_FORCE_INLINE vec3_t vec3_forward() { return (vec3_t) { 0, 0, 1 }; }

/* vec3_back: Return the backward direction vector (vector3)
* returns: vec3_t backward direction, i.e. Vector4.back [-ve z axis direction]
*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_back() { return (vec3_t) { 0, 0, 1 }; }
HPML_FORCE_INLINE vec3_t vec3_back() { return (vec3_t) { 0, 0, 1 }; }

/*vec3_one*/
HPML_API HPML_FORCE_INLINE vec3_t vec3_one() { return (vec3_t) { 1, 1, 1 }; }
HPML_FORCE_INLINE vec3_t vec3_one() { return (vec3_t) { 1, 1, 1 }; }


/*ARITHMETIC*/
Expand Down
Loading

0 comments on commit e34d217

Please sign in to comment.