REVIEWED: Added new mechanism to avoid data types collision between modules that share same data types and can be used in standalone mode
This commit is contained in:
parent
aeb1a0da84
commit
b4fddf146b
6 changed files with 490 additions and 494 deletions
|
@ -9,14 +9,10 @@
|
|||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
*
|
||||
* #define RAYMATH_HEADER_ONLY
|
||||
* #define RAYMATH_STATIC_INLINE
|
||||
* Define static inline functions code, so #include header suffices for use.
|
||||
* This may use up lots of memory.
|
||||
*
|
||||
* #define RAYMATH_STANDALONE
|
||||
* Avoid raylib.h header inclusion in this file.
|
||||
* Vector3 and Matrix data types are defined internally in raymath module.
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
|
@ -42,15 +38,8 @@
|
|||
#ifndef RAYMATH_H
|
||||
#define RAYMATH_H
|
||||
|
||||
//#define RAYMATH_STANDALONE // NOTE: To use raymath as standalone lib, just uncomment this line
|
||||
//#define RAYMATH_HEADER_ONLY // NOTE: To compile functions as static inline, uncomment this line
|
||||
|
||||
#ifndef RAYMATH_STANDALONE
|
||||
#include "raylib.h" // Required for: Vector3, Matrix structs definition
|
||||
#endif
|
||||
|
||||
#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_HEADER_ONLY)
|
||||
#error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_HEADER_ONLY is contradictory"
|
||||
#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE)
|
||||
#error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory"
|
||||
#endif
|
||||
|
||||
#if defined(RAYMATH_IMPLEMENTATION)
|
||||
|
@ -61,7 +50,7 @@
|
|||
#else
|
||||
#define RMDEF extern inline // Provide external definition
|
||||
#endif
|
||||
#elif defined(RAYMATH_HEADER_ONLY)
|
||||
#elif defined(RAYMATH_STATIC_INLINE)
|
||||
#define RMDEF static inline // Functions may be inlined, no external out-of-line definition
|
||||
#else
|
||||
#if defined(__TINYC__)
|
||||
|
@ -100,38 +89,51 @@
|
|||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#if defined(RAYMATH_STANDALONE)
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
} Vector2;
|
||||
#if !defined(RL_VECTOR2_TYPE)
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
} Vector2;
|
||||
#define RL_VECTOR2_TYPE
|
||||
#endif
|
||||
|
||||
// Vector3 type
|
||||
typedef struct Vector3 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3;
|
||||
#if !defined(RL_VECTOR3_TYPE)
|
||||
// Vector3 type
|
||||
typedef struct Vector3 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3;
|
||||
#define RL_VECTOR3_TYPE
|
||||
#endif
|
||||
|
||||
// Vector4 type
|
||||
typedef struct Vector4 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
} Vector4;
|
||||
#if !defined(RL_VECTOR4_TYPE)
|
||||
// Vector4 type
|
||||
typedef struct Vector4 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
} Vector4;
|
||||
#define RL_VECTOR4_TYPE
|
||||
#endif
|
||||
|
||||
// Quaternion type
|
||||
typedef Vector4 Quaternion;
|
||||
#if !defined(RL_QUATERNION_TYPE)
|
||||
// Quaternion type
|
||||
typedef Vector4 Quaternion;
|
||||
#define RL_QUATERNION_TYPE
|
||||
#endif
|
||||
|
||||
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||
typedef struct Matrix {
|
||||
float m0, m4, m8, m12;
|
||||
float m1, m5, m9, m13;
|
||||
float m2, m6, m10, m14;
|
||||
float m3, m7, m11, m15;
|
||||
} Matrix;
|
||||
#if !defined(RL_MATRIX_TYPE)
|
||||
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||
typedef struct Matrix {
|
||||
float m0, m4, m8, m12; // Matrix first row (4 components)
|
||||
float m1, m5, m9, m13; // Matrix second row (4 components)
|
||||
float m2, m6, m10, m14; // Matrix third row (4 components)
|
||||
float m3, m7, m11, m15; // Matrix fourth row (4 components)
|
||||
} Matrix;
|
||||
#define RL_MATRIX_TYPE
|
||||
#endif
|
||||
|
||||
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue