Fixed many bugs
Added NzOpenGL::GetEntry Activated preprocessor error if not compiling with a C++11 compliant compiler Cube can now be constructed with a Rect Desactived utility option "threaded window" (bugged) Epured Image interface (No more UpdateFace, use Update with z = the face you are targetting) Fixed compilation errors (Thanks to RafBill) Fixed predefined colors not exported Fixed uplading pixels not aligned by 4 bytes Fixed Thumbs.db files not ignored by git NzImage now supports Filling and Flipping (Horizontally and vertically) NzImage::Get(Const)Pixels now support pixel location NzVector(2/3) can now return floatting distance/length with all types NzVector(2/3/4) can now be constructed by a vector of smaller dimension Premake now set "-std=c++11" build option for GCC Renamed NzImage::(Get/Set)Pixel to (Get/Set)PixelColor Updated new([])/delete([]) in the leaks tracker to the new C++11 signatures
This commit is contained in:
@@ -47,15 +47,15 @@ class NzColor
|
||||
|
||||
nzUInt8 r, g, b, a;
|
||||
|
||||
static const NzColor Black;
|
||||
static const NzColor Blue;
|
||||
static const NzColor Cyan;
|
||||
static const NzColor Green;
|
||||
static const NzColor Magenta;
|
||||
static const NzColor Orange;
|
||||
static const NzColor Red;
|
||||
static const NzColor Yellow;
|
||||
static const NzColor White;
|
||||
static NAZARA_API const NzColor Black;
|
||||
static NAZARA_API const NzColor Blue;
|
||||
static NAZARA_API const NzColor Cyan;
|
||||
static NAZARA_API const NzColor Green;
|
||||
static NAZARA_API const NzColor Magenta;
|
||||
static NAZARA_API const NzColor Orange;
|
||||
static NAZARA_API const NzColor Red;
|
||||
static NAZARA_API const NzColor Yellow;
|
||||
static NAZARA_API const NzColor White;
|
||||
|
||||
private:
|
||||
static float Hue2RGB(float v1, float v2, float vH);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_CUBE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
@@ -17,6 +18,7 @@ class NzCube
|
||||
NzCube();
|
||||
NzCube(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzCube(T cube[6]);
|
||||
NzCube(const NzRect<T>& rect);
|
||||
template<typename U> explicit NzCube(const NzCube<U>& rect);
|
||||
NzCube(const NzCube& rect) = default;
|
||||
~NzCube() = default;
|
||||
|
||||
@@ -33,6 +33,17 @@ depth(vec[5])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const NzRect<T>& rect) :
|
||||
x(rect.x),
|
||||
y(rect.y),
|
||||
z(0),
|
||||
width(rect.width),
|
||||
height(rect.height),
|
||||
depth(1)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzCube<T>::NzCube(const NzCube<U>& rect) :
|
||||
|
||||
@@ -96,17 +96,12 @@ template<typename T> class NzMatrix4
|
||||
|
||||
struct SharedMatrix
|
||||
{
|
||||
SharedMatrix() : // Vivement GCC 4.7 sur Windows
|
||||
refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
T m11, m12, m13, m14;
|
||||
T m21, m22, m23, m24;
|
||||
T m31, m32, m33, m34;
|
||||
T m41, m42, m43, m44;
|
||||
|
||||
unsigned short refCount;
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ NzMatrix4<T> NzMatrix4<T>::GetInverse() const
|
||||
NzMatrix4 matrix;
|
||||
T det = GetDeterminant();
|
||||
|
||||
if (det != 0.0)
|
||||
if (!NzNumberEquals(det, static_cast<T>(0.0)))
|
||||
{
|
||||
matrix(0, 0) = (m_sharedMatrix->m22 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m43) - m_sharedMatrix->m32 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m24) + m_sharedMatrix->m42 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m24)) / det;
|
||||
matrix(0, 1) = -(m_sharedMatrix->m12 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m34) - m_sharedMatrix->m32 * (m_sharedMatrix->m13 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m14) + m_sharedMatrix->m42 * (m_sharedMatrix->m13 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m14)) / det;
|
||||
|
||||
@@ -217,15 +217,15 @@ NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& quatA, const NzQuater
|
||||
k1 = std::sin(interp * omega) * sinOmega;
|
||||
}
|
||||
|
||||
/* interpolate and return new quaternion */
|
||||
NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z);
|
||||
|
||||
return result += q;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzQuaternion<T>::ToEulerAngles() const
|
||||
{
|
||||
Normalize();
|
||||
|
||||
T test = x*y + z*w;
|
||||
if (test > 0.499)
|
||||
// singularity at north pole
|
||||
|
||||
@@ -22,12 +22,14 @@ template<typename T> class NzVector2
|
||||
|
||||
T AbsDotProduct(const NzVector2& vec) const;
|
||||
T Distance(const NzVector2& vec) const;
|
||||
float Distancef(const NzVector2& vec) const;
|
||||
T DotProduct(const NzVector2& vec) const;
|
||||
NzVector2 GetNormal() const;
|
||||
void MakeCeil(const NzVector2& vec);
|
||||
void MakeFloor(const NzVector2& vec);
|
||||
T Length() const;
|
||||
T Normalize();
|
||||
float Lengthf() const;
|
||||
void Normalize();
|
||||
T SquaredDistance(const NzVector2& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
|
||||
@@ -49,7 +49,14 @@ T NzVector2<T>::AbsDotProduct(const NzVector2& vec) const
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y);
|
||||
}
|
||||
|
||||
template<> inline int NzVector2<int>::AbsDotProduct(const NzVector2<int>& vec) const
|
||||
template<>
|
||||
inline int NzVector2<int>::AbsDotProduct(const NzVector2<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned int NzVector2<unsigned int>::AbsDotProduct(const NzVector2<unsigned int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
@@ -60,6 +67,12 @@ T NzVector2<T>::Distance(const NzVector2& vec) const
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector2<T>::Distancef(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredDistance(vec)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::DotProduct(const NzVector2& vec) const
|
||||
{
|
||||
@@ -102,17 +115,21 @@ T NzVector2<T>::Length() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::Normalize()
|
||||
float NzVector2<T>::Lengthf() const
|
||||
{
|
||||
T length = Length();
|
||||
return std::sqrt(static_cast<float>(SquaredLength()));
|
||||
}
|
||||
|
||||
if (length != 0.f)
|
||||
template<typename T>
|
||||
void NzVector2<T>::Normalize()
|
||||
{
|
||||
auto length = Length();
|
||||
|
||||
if (!NzNumberEquals(length, static_cast<T>(0.0)))
|
||||
{
|
||||
x /= length;
|
||||
y /= length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -214,7 +231,7 @@ NzVector2<T> NzVector2<T>::operator*(T scale) const
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -228,7 +245,7 @@ NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -278,7 +295,7 @@ NzVector2<T>& NzVector2<T>::operator*=(T scale)
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -295,7 +312,7 @@ NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -361,7 +378,7 @@ NzVector2<T> operator*(T scale, const NzVector2<T>& vec)
|
||||
template<typename T>
|
||||
NzVector2<T> operator/(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_VECTOR3_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template<typename T> class NzVector3
|
||||
{
|
||||
@@ -16,6 +17,7 @@ template<typename T> class NzVector3
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
NzVector3(const NzVector2<T>& vec);
|
||||
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||
NzVector3(const NzVector3& vec) = default;
|
||||
~NzVector3() = default;
|
||||
@@ -23,12 +25,14 @@ template<typename T> class NzVector3
|
||||
T AbsDotProduct(const NzVector3& vec) const;
|
||||
NzVector3 CrossProduct(const NzVector3& vec) const;
|
||||
T Distance(const NzVector3& vec) const;
|
||||
float Distancef(const NzVector3& vec) const;
|
||||
T DotProduct(const NzVector3& vec) const;
|
||||
NzVector3 GetNormal() const;
|
||||
void MakeCeil(const NzVector3& vec);
|
||||
void MakeFloor(const NzVector3& vec);
|
||||
T Length() const;
|
||||
T Normalize();
|
||||
float Lengthf() const;
|
||||
void Normalize();
|
||||
T SquaredDistance(const NzVector3& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
@@ -77,6 +81,7 @@ template<typename T> NzVector3<T> operator/(T scale, const NzVector3<T>& vec);
|
||||
typedef NzVector3<double> NzVector3d;
|
||||
typedef NzVector3<float> NzVector3f;
|
||||
typedef NzVector3<int> NzVector3i;
|
||||
typedef NzVector3<unsigned int> NzVector3ui;
|
||||
|
||||
#include <Nazara/Math/Vector3.inl>
|
||||
|
||||
|
||||
@@ -38,6 +38,14 @@ z(vec[2])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec) :
|
||||
x(vec.x),
|
||||
y(vec.y),
|
||||
z(0)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector3<T>::NzVector3(const NzVector3<U>& vec) :
|
||||
@@ -53,7 +61,14 @@ T NzVector3<T>::AbsDotProduct(const NzVector3& vec) const
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y) + std::fabs(z * vec.z);
|
||||
}
|
||||
|
||||
template<> inline int NzVector3<int>::AbsDotProduct(const NzVector3<int>& vec) const
|
||||
template<>
|
||||
inline int NzVector3<int>::AbsDotProduct(const NzVector3<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned int NzVector3<unsigned int>::AbsDotProduct(const NzVector3<unsigned int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z);
|
||||
}
|
||||
@@ -70,6 +85,12 @@ T NzVector3<T>::Distance(const NzVector3& vec) const
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector3<T>::Distancef(const NzVector3& vec) const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredDistance()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::DotProduct(const NzVector3& vec) const
|
||||
{
|
||||
@@ -118,18 +139,22 @@ T NzVector3<T>::Length() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::Normalize()
|
||||
float NzVector3<T>::Lengthf() const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredLength()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::Normalize()
|
||||
{
|
||||
T length = Length();
|
||||
|
||||
if (length != 0.f)
|
||||
if (!NzNumberEquals(length, static_cast<T>(0.0)))
|
||||
{
|
||||
x /= length;
|
||||
y /= length;
|
||||
z /= length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -231,7 +256,7 @@ NzVector3<T> NzVector3<T>::operator*(T scale) const
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator/(const NzVector3& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -245,7 +270,7 @@ NzVector3<T> NzVector3<T>::operator/(const NzVector3& vec) const
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -299,7 +324,7 @@ NzVector3<T>& NzVector3<T>::operator*=(T scale)
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator/=(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -317,7 +342,7 @@ NzVector3<T>& NzVector3<T>::operator/=(const NzVector3& vec)
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -385,7 +410,7 @@ NzVector3<T> operator*(T scale, const NzVector3<T>& vec)
|
||||
template<typename T>
|
||||
NzVector3<T> operator/(T scale, const NzVector3<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_VECTOR4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T> class NzVector4
|
||||
{
|
||||
@@ -17,6 +18,7 @@ template<typename T> class NzVector4
|
||||
explicit NzVector4(T scale);
|
||||
NzVector4(T vec[4]);
|
||||
template<typename U> explicit NzVector4(const NzVector4<U>& vec);
|
||||
NzVector4(const NzVector3<T>& vec, T W = 1.0);
|
||||
NzVector4(const NzVector4& vec) = default;
|
||||
~NzVector4() = default;
|
||||
|
||||
|
||||
@@ -51,13 +51,29 @@ w(static_cast<T>(vec.w))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(const NzVector3<T>& vec, T W) :
|
||||
x(vec.x),
|
||||
y(vec.y),
|
||||
z(vec.z),
|
||||
w(W)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector4<T>::AbsDotProduct(const NzVector4& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y) + std::fabs(z * vec.z) + std::fabs(w * vec.w);
|
||||
}
|
||||
|
||||
template<> inline int NzVector4<int>::AbsDotProduct(const NzVector4<int>& vec) const
|
||||
template<>
|
||||
inline int NzVector4<int>::AbsDotProduct(const NzVector4<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z) + std::labs(w * vec.w);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned int NzVector4<unsigned int>::AbsDotProduct(const NzVector4<unsigned int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z) + std::labs(w * vec.w);
|
||||
}
|
||||
@@ -103,7 +119,7 @@ void NzVector4<T>::MakeFloor(const NzVector4& vec)
|
||||
template<typename T>
|
||||
void NzVector4<T>::Normalize()
|
||||
{
|
||||
if (w != 0.f)
|
||||
if (!NzNumberEquals(w, static_cast<T>(0.0)))
|
||||
{
|
||||
x /= w;
|
||||
y /= w;
|
||||
@@ -116,7 +132,7 @@ NzString NzVector4<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector4(" << x << ", " << y << ", " << z <<')';
|
||||
return ss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -180,7 +196,7 @@ NzVector4<T> NzVector4<T>::operator+(const NzVector4& vec) const
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator-(const NzVector4& vec) const
|
||||
{
|
||||
return NzVector4(x - vec.x, y - vec.y, z - vec.z);
|
||||
return NzVector4(x - vec.x, y - vec.y, z - vec.z, w - vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -198,7 +214,7 @@ NzVector4<T> NzVector4<T>::operator*(T scale) const
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator/(const NzVector4& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)) || NzNumberEquals(vec.w, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -212,7 +228,7 @@ NzVector4<T> NzVector4<T>::operator/(const NzVector4& vec) const
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -270,7 +286,7 @@ NzVector4<T>& NzVector4<T>::operator*=(T scale)
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator/=(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)) || NzNumberEquals(vec.w, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -289,7 +305,7 @@ NzVector4<T>& NzVector4<T>::operator/=(const NzVector4& vec)
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
if (NzNumberEquals(scale, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
@@ -359,7 +375,7 @@ NzVector4<T> operator*(T scale, const NzVector4<T>& vec)
|
||||
template<typename T>
|
||||
NzVector4<T> operator/(T scale, const NzVector4<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
if (NzNumberEquals(vec.x, static_cast<T>(0.0)) || NzNumberEquals(vec.y, static_cast<T>(0.0)) || NzNumberEquals(vec.z, static_cast<T>(0.0)) || NzNumberEquals(vec.w, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
#ifndef NAZARA_PREREQUESITES_HPP
|
||||
#define NAZARA_PREREQUESITES_HPP
|
||||
|
||||
// (Commenté en attendant GCC 4.7)
|
||||
/*#if __cplusplus < 201103L
|
||||
#if __cplusplus < 201103L
|
||||
#error Nazara requires a C++11 compliant compiler
|
||||
#endif*/
|
||||
#endif
|
||||
|
||||
// Version du moteur
|
||||
#define NAZARA_VERSION_MAJOR 0
|
||||
|
||||
@@ -46,6 +46,7 @@ class NAZARA_API NzOpenGL
|
||||
Count
|
||||
};
|
||||
|
||||
static NzOpenGLFunc GetEntry(const NzString& entryPoint);
|
||||
static unsigned int GetVersion();
|
||||
static bool Initialize();
|
||||
static bool IsSupported(Extension extension);
|
||||
@@ -131,6 +132,7 @@ NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
||||
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
#define NAZARA_UTILITY_SAFE 1
|
||||
|
||||
// Fait tourner chaque fenêtre dans un thread séparé si le système le supporte
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 1
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7
|
||||
|
||||
#endif // NAZARA_CONFIG_UTILITY_HPP
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/ResourceLoader.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
@@ -19,12 +20,12 @@
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
nzCubemapFace_PositiveX,
|
||||
nzCubemapFace_NegativeX,
|
||||
nzCubemapFace_PositiveY,
|
||||
nzCubemapFace_NegativeY,
|
||||
nzCubemapFace_PositiveZ,
|
||||
nzCubemapFace_NegativeZ
|
||||
nzCubemapFace_PositiveX = 0,
|
||||
nzCubemapFace_NegativeX = 1,
|
||||
nzCubemapFace_PositiveY = 2,
|
||||
nzCubemapFace_NegativeY = 3,
|
||||
nzCubemapFace_PositiveZ = 4,
|
||||
nzCubemapFace_NegativeZ = 5
|
||||
};
|
||||
|
||||
enum nzImageType
|
||||
@@ -39,15 +40,8 @@ enum nzImageType
|
||||
|
||||
struct NzImageParams
|
||||
{
|
||||
// GCC 4.7 je te veux
|
||||
NzImageParams() :
|
||||
loadFormat(nzPixelFormat_Undefined),
|
||||
levelCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
nzPixelFormat loadFormat;
|
||||
nzUInt8 levelCount;
|
||||
nzPixelFormat loadFormat = nzPixelFormat_Undefined;
|
||||
nzUInt8 levelCount = 0;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
@@ -70,22 +64,27 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
|
||||
bool Convert(nzPixelFormat format);
|
||||
|
||||
bool Copy(const NzImage& source, const NzRectui& srcRect, const NzVector2ui& dstPos);
|
||||
bool CopyToFace(nzCubemapFace face, const NzImage& source, const NzRectui& srcRect, const NzVector2ui& dstPos);
|
||||
bool Copy(const NzImage& source, const NzCubeui& srcCube, const NzVector3ui& dstPos);
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const NzColor& color);
|
||||
bool Fill(const NzColor& color, const NzRectui& rect, unsigned int z = 0);
|
||||
bool Fill(const NzColor& color, const NzCubeui& cube);
|
||||
|
||||
bool FlipHorizontally();
|
||||
bool FlipVertically();
|
||||
|
||||
nzUInt8 GetBPP() const;
|
||||
const nzUInt8* GetConstPixels(nzUInt8 level = 0) const;
|
||||
const nzUInt8* GetConstPixels(nzUInt8 level = 0, unsigned int x = 0, unsigned int y = 0, unsigned int z = 0) const;
|
||||
unsigned int GetDepth(nzUInt8 level = 0) const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight(nzUInt8 level = 0) const;
|
||||
nzUInt8 GetLevelCount() const;
|
||||
nzUInt8 GetMaxLevel() const;
|
||||
NzColor GetPixel(unsigned int x, unsigned int y = 0, unsigned int z = 0) const;
|
||||
NzColor GetPixelFace(nzCubemapFace face, unsigned int x, unsigned int y) const;
|
||||
nzUInt8* GetPixels(nzUInt8 level = 0);
|
||||
NzColor GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const;
|
||||
nzUInt8* GetPixels(nzUInt8 level = 0, unsigned int x = 0, unsigned int y = 0, unsigned int z = 0);
|
||||
unsigned int GetSize() const;
|
||||
unsigned int GetSize(nzUInt8 level) const;
|
||||
nzImageType GetType() const;
|
||||
@@ -100,14 +99,11 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
|
||||
bool SetLevelCount(nzUInt8 levelCount);
|
||||
bool SetPixel(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
|
||||
bool SetPixelFace(nzCubemapFace face, const NzColor& color, unsigned int x, unsigned int y);
|
||||
bool SetPixelColor(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
|
||||
|
||||
bool Update(const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level = 0);
|
||||
|
||||
NzImage& operator=(const NzImage& image);
|
||||
NzImage& operator=(NzImage&& image);
|
||||
@@ -122,11 +118,6 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
|
||||
struct SharedImage
|
||||
{
|
||||
SharedImage() : // Vivement GCC 4.7 sur Windows
|
||||
refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
SharedImage(unsigned short RefCount, nzImageType Type, nzPixelFormat Format, nzUInt8 LevelCount = 1, nzUInt8** Pixels = nullptr, unsigned int Width = 1, unsigned int Height = 1, unsigned int Depth = 1) :
|
||||
type(Type),
|
||||
format(Format),
|
||||
@@ -147,7 +138,7 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
|
||||
unsigned short refCount;
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user