1
0
Fork 0

Move everything from global namespace to "sp" namespace

When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine.

So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
This commit is contained in:
Henrik Hautakoski 2019-09-29 23:47:57 +02:00
parent 9da8addeb2
commit e10daeaaa6
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
120 changed files with 551 additions and 105 deletions

View file

@ -5,6 +5,8 @@
#include "Vector3.h"
#include "Vector4.h"
namespace sp {
// Basic structure representing a color in 32bit RGBA
struct Color
{
@ -62,4 +64,6 @@ Color operator -(const Color& a, unsigned int s);
Color operator /(const Color& a, unsigned int s);
Color operator *(const Color& a, unsigned int s);
} // namespace sp
#endif /* SPECTRE_MATH_COLOR_H */

View file

@ -6,7 +6,7 @@
#include "Vector2.h"
#include "Matrix4.h"
namespace math
namespace sp { namespace math
{
float rand(float min, float max);
@ -28,13 +28,13 @@ namespace math
// ------------------------------
// Create a orthographic projection matrix.
Matrix4f orthoProjection(float left, float right,
float bottom, float top,
Matrix4f orthoProjection(float left, float right,
float bottom, float top,
float zNear = -1.0f, float zFar = 1.0f);
// Create a 2D rotation matrix. (rotation around Z-axis)
Matrix4f rotation(float theta);
// Create a 2D translation matrix.
Matrix4f translate(const Vector2f& v);
@ -47,6 +47,7 @@ namespace math
Vector3f getUpVector(const Matrix4f matrix);
Vector3f getForwardVector(const Matrix4f matrix);
};
} } // namespace sp
#endif /* SPECTRE_MATH_MATH_H */

View file

@ -7,6 +7,8 @@
#include <iostream>
#include <Spectre/Math/Vector2.h>
namespace sp {
template<typename T>
struct Matrix3
{
@ -20,7 +22,7 @@ struct Matrix3
| 0 3 6 |
| 1 4 7 |
| 2 5 8 |
|_ _|
|_ _|
*/
T v[9];
};
@ -77,6 +79,8 @@ typedef Matrix3<double> Matrix3d;
typedef Matrix3<int> Matrix3i;
typedef Matrix3<unsigned> Matrix3u;
} // namespace sp
#include "Matrix3.inl"
#endif /* SPECTRE_MATH_MATRIX3_H */

View file

@ -2,6 +2,8 @@
#include <string>
#include "Matrix3.h"
namespace sp {
template <>
Matrix3f Matrix3f::Identity(
1, 0, 0,
@ -120,3 +122,5 @@ inline std::ostream& operator<<(std::ostream &s, const Matrix3<T>& mat)
<< mat.v[1] << " " << mat.v[4] << " " << mat.v[7] << std::endl
<< mat.v[2] << " " << mat.v[5] << " " << mat.v[8] << std::endl;
}
} // namespace sp

View file

@ -9,6 +9,8 @@
#include <Spectre/Math/Vector3.h>
#include <Spectre/Math/Vector2.h>
namespace sp {
template<typename T>
struct Matrix4
{
@ -100,10 +102,11 @@ typedef Matrix4<double> mat4d;
typedef Matrix4<int> mat4i;
typedef Matrix4<unsigned> mat4u;
} // namespace sp
// ----------------
// Implementation
// ----------------
#include "Matrix4.inl"
#endif /* SPECTRE_MATH_MATRIX4_H */

View file

@ -4,6 +4,8 @@
#include <string.h>
#include "Matrix4.h"
namespace sp {
template<typename T>
const Matrix4<T> Matrix4<T>::Identity(
1, 0, 0, 0,
@ -152,3 +154,5 @@ inline std::ostream& operator<<(std::ostream &s, const Matrix4<T>& mat)
{
return s << mat.toString();
}
} // namespace sp

View file

@ -5,6 +5,8 @@
#include "Vector2.h"
#include "Matrix4.h"
namespace sp {
// Class representing a transformation matrix.
class Transform
@ -75,4 +77,6 @@ Transform& operator*=(Transform& a, const Transform& b);
Vector2f operator*(const Transform& t, const Vector2f& v);
} // namespace sp
#endif /* SPECTRE_MATH_TRANSFORM_H */

View file

@ -5,11 +5,13 @@
#include <string>
#include <iostream>
namespace sp {
template <typename T>
struct Vector2
{
union {
struct {
struct {
T x, y;
};
T v[2];
@ -111,7 +113,7 @@ template <typename T>
inline Vector2<T> operator+(T s, const Vector2<T>& v);
template <typename T>
inline Vector2<T> operator-(const Vector2<T>& v,T s);
inline Vector2<T> operator-(const Vector2<T>& v, T s);
template <typename T>
inline Vector2<T> operator-(T s, const Vector2<T>& v);
@ -132,7 +134,7 @@ template <typename T>
inline Vector2<T>& operator+=(Vector2<T>& v, T s);
template <typename T>
inline Vector2<T>& operator-=(Vector2<T>& v,T s);
inline Vector2<T>& operator-=(Vector2<T>& v, T s);
template <typename T>
inline Vector2<T>& operator/=(Vector2<T>& v, T s);
@ -190,6 +192,8 @@ typedef Vector2<int> vec2i;
typedef Vector2<unsigned> vec2u;
typedef Vector2<unsigned char> vec2b;
} // namespace sp
#include "Vector2.inl"
#endif /* SPECTRE_MATH_VECTOR2_H */

View file

@ -3,6 +3,8 @@
#include <math.h>
#include "Vector2.h"
namespace sp {
template <typename T>
Vector2<T>::Vector2()
{
@ -314,3 +316,5 @@ inline std::ostream& operator<<(std::ostream &s, const Vector2<T>& v)
{
return s << "(" << v.x << "," << v.y << ")";
}
} // namespace sp

View file

@ -5,6 +5,8 @@
#include "Vector2.h"
#include <iostream>
namespace sp {
template <typename T>
struct Vector3
{
@ -167,6 +169,8 @@ typedef Vector3<int> vec3i;
typedef Vector3<unsigned> vec3u;
typedef Vector3<unsigned char> vec3b;
} // namespace sp
#include "Vector3.inl"
#endif /* SPECTRE_MATH_VECTOR3_H */

View file

@ -2,6 +2,8 @@
#include <math.h>
#include "Vector3.h"
namespace sp {
template <typename T>
Vector3<T>::Vector3()
{
@ -265,3 +267,5 @@ inline std::ostream& operator<<(std::ostream &s, const Vector3<T>& v)
{
return s << "(" << v.x << "," << v.y << "," << v.z << ")";
}
} // namespace sp

View file

@ -4,6 +4,8 @@
#include <iostream>
namespace sp {
template <typename T>
struct Vector4
{
@ -153,6 +155,8 @@ typedef Vector4<int> vec4i;
typedef Vector4<unsigned> vec4u;
typedef Vector4<unsigned char> vec4b;
} // namespace sp
#include "Vector4.inl"
#endif /* SPECTRE_MATH_VECTOR4_H */

View file

@ -2,6 +2,8 @@
#include <math.h>
#include "Vector4.h"
namespace sp {
template <typename T>
Vector4<T>::Vector4()
{
@ -252,3 +254,5 @@ inline std::ostream& operator<<(std::ostream &s, const Vector4<T>& v)
{
return s << "(" << v.x << "," << v.y << "," << v.z << "," << v.w << ")";
}
} // namespace sp