Add RAYMATH_TYPES_DEFINED to check if Vector*/Matrix* is defined, that we can use RAYMATH_STANDALONE with raylib.h

This commit is contained in:
MaiHD 2020-11-15 02:22:02 +07:00
parent c222e231f0
commit 4e91ae262e
2 changed files with 33 additions and 28 deletions

View File

@ -170,37 +170,41 @@
typedef enum { false, true } bool; typedef enum { false, true } bool;
#endif #endif
// Vector2 type #if !defined(RAYMATH_TYPES_DEFINED)
typedef struct Vector2 { #define RAYMATH_TYPES_DEFINED
float x;
float y;
} Vector2;
// Vector3 type // Vector2 type
typedef struct Vector3 { typedef struct Vector2 {
float x; float x;
float y; float y;
float z; } Vector2;
} Vector3;
// Vector4 type // Vector3 type
typedef struct Vector4 { typedef struct Vector3 {
float x; float x;
float y; float y;
float z; float z;
float w; } Vector3;
} Vector4;
// Quaternion type, same as Vector4 // Vector4 type
typedef Vector4 Quaternion; typedef struct Vector4 {
float x;
float y;
float z;
float w;
} Vector4;
// Matrix type (OpenGL style 4x4 - right handed, column major) // Quaternion type, same as Vector4
typedef struct Matrix { typedef Vector4 Quaternion;
float m0, m4, m8, m12;
float m1, m5, m9, m13; // Matrix type (OpenGL style 4x4 - right handed, column major)
float m2, m6, m10, m14; typedef struct Matrix {
float m3, m7, m11, m15; float m0, m4, m8, m12;
} Matrix; float m1, m5, m9, m13;
float m2, m6, m10, m14;
float m3, m7, m11, m15;
} Matrix;
#endif
// Color type, RGBA (32bit) // Color type, RGBA (32bit)
typedef struct Color { typedef struct Color {

View File

@ -100,7 +100,8 @@
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(RAYMATH_STANDALONE) #if defined(RAYMATH_STANDALONE) && !defined(RAYMATH_TYPES_DEFINED)
#define RAYMATH_TYPES_DEFINED
// Vector2 type // Vector2 type
typedef struct Vector2 { typedef struct Vector2 {
float x; float x;