-
Notifications
You must be signed in to change notification settings - Fork 4
/
raymath_namespace.h
109 lines (99 loc) · 3.32 KB
/
raymath_namespace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**********************************************************************************************
*
* raylib-extras-cpp * Utilities and Shared Components for Raylib
*
* raymath-namespace.h * Simple wrapper to put raymath in a namespace
*
* LICENSE: MIT
*
* Copyright (c) 2021-2023 Jeffery Myers, Peter Damianov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************************************/
#pragma once
// declare the raylib types that raymath needs, if they haven't been declared yet
// they must be in the rl namespace, in order for the types to be compatible
// if they weren't defined like this, a function taking an rl::Vector2 wouldn't
// be able to accept an rm::Vector2
namespace rl
{
#if !defined(RL_MATRIX_TYPE)
// Matrix, 4x4 components, column major, OpenGL style, right handed
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
#if !defined(RL_VECTOR2_TYPE)
// Vector2 type
typedef struct Vector2 {
float x;
float y;
} Vector2;
#define RL_VECTOR2_TYPE
#endif
#if !defined(RL_VECTOR3_TYPE)
// Vector3 type
typedef struct Vector3 {
float x;
float y;
float z;
} Vector3;
#define RL_VECTOR3_TYPE
#endif
#if !defined(RL_VECTOR4_TYPE)
// Vector4 type
typedef struct Vector4 {
float x;
float y;
float z;
float w;
} Vector4;
#define RL_VECTOR4_TYPE
#endif
#if !defined(RL_QUATERNION_TYPE)
// Quaternion type
typedef Vector4 Quaternion;
#define RL_QUATERNION_TYPE
#endif
#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
}
// raymath includes:
#include <cmath>
namespace rm
{
using rl::Vector2;
using rl::Vector3;
using rl::Quaternion;
using rl::Matrix;
#include "raymath.h"
}