diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index eec23149c..aff3460ac 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -10,21 +10,34 @@ ///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ? #include +#include template class NzSparsePtr { public: + using BytePtr = typename std::conditional::value, const nzUInt8*, nzUInt8*>::type; + using VoidPtr = typename std::conditional::value, const void*, void*>::type; + NzSparsePtr(); - NzSparsePtr(void* ptr, unsigned int stride); + NzSparsePtr(T* ptr); + NzSparsePtr(VoidPtr ptr, unsigned int stride); NzSparsePtr(const NzSparsePtr& ptr) = default; ~NzSparsePtr() = default; - void* Get() const; + VoidPtr GetPtr() const; unsigned int GetStride() const; - void Set(void* ptr); + + void Reset(); + void Reset(T* ptr); + void Reset(VoidPtr ptr, unsigned int stride); + void Reset(const NzSparsePtr& ptr); + + void SetPtr(VoidPtr ptr); void SetStride(unsigned int stride); + operator bool() const; + operator T*() const; T& operator*() const; T& operator->() const; T& operator[](unsigned int index) const; @@ -51,7 +64,7 @@ class NzSparsePtr NzSparsePtr& operator=(const NzSparsePtr& ptr) = default; private: - nzUInt8* m_ptr; + BytePtr m_ptr; unsigned int m_stride; }; diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index f769e577e..b98599bfd 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -5,21 +5,25 @@ #include template -NzSparsePtr::NzSparsePtr() : -m_ptr(nullptr), -m_stride(0) +NzSparsePtr::NzSparsePtr() { + Reset(); } template -NzSparsePtr::NzSparsePtr(void* ptr, unsigned int stride) +NzSparsePtr::NzSparsePtr(T* ptr) { - Set(ptr); - SetStride(stride); + Reset(ptr); } template -void* NzSparsePtr::Get() const +NzSparsePtr::NzSparsePtr(VoidPtr ptr, unsigned int stride) +{ + Reset(ptr, stride); +} + +template +typename NzSparsePtr::VoidPtr NzSparsePtr::GetPtr() const { return m_ptr; } @@ -31,9 +35,37 @@ unsigned int NzSparsePtr::GetStride() const } template -void NzSparsePtr::Set(void* ptr) +void NzSparsePtr::Reset() { - m_ptr = reinterpret_cast(ptr); + SetPtr(nullptr); + SetStride(0); +} + +template +void NzSparsePtr::Reset(T* ptr) +{ + SetPtr(ptr); + SetStride(sizeof(T)); +} + +template +void NzSparsePtr::Reset(VoidPtr ptr, unsigned int stride) +{ + SetPtr(ptr); + SetStride(stride); +} + +template +void NzSparsePtr::Reset(const NzSparsePtr& ptr) +{ + SetPtr(ptr.GetPtr()); + SetStride(ptr.GetStride()); +} + +template +void NzSparsePtr::SetPtr(VoidPtr ptr) +{ + m_ptr = reinterpret_cast(ptr); } template @@ -42,6 +74,18 @@ void NzSparsePtr::SetStride(unsigned int stride) m_stride = stride; } +template +NzSparsePtr::operator bool() const +{ + return m_ptr != nullptr; +} + +template +NzSparsePtr::operator T*() const +{ + return reinterpret_cast(m_ptr); +} + template T& NzSparsePtr::operator*() const { diff --git a/include/Nazara/Math.hpp b/include/Nazara/Math.hpp index e70158c4a..b80211a25 100644 --- a/include/Nazara/Math.hpp +++ b/include/Nazara/Math.hpp @@ -30,7 +30,7 @@ #ifndef NAZARA_GLOBAL_MATH_HPP #define NAZARA_GLOBAL_MATH_HPP -#include +#include #include #include #include diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index 4521ea909..35e6a7b65 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -76,6 +76,7 @@ template class NzQuaternion static NzQuaternion Identity(); static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation); + static NzQuaternion Normalize(const NzQuaternion& quat, T* length = nullptr); static NzQuaternion RotationBetween(const NzVector3& from, const NzVector3& to); static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation); static NzQuaternion Zero(); diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 76290c0c7..8348a5e2f 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -408,6 +408,12 @@ NzQuaternion NzQuaternion::Lerp(const NzQuaternion& from, const NzQuaterni return interpolated; } +template +NzQuaternion NzQuaternion::Normalize(const NzQuaternion& quat, T* length) +{ + return quat.GetNormal(length); +} + template NzQuaternion NzQuaternion::RotationBetween(const NzVector3& from, const NzVector3& to) { diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 229800e9b..fa9fc9a3d 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -185,16 +185,6 @@ enum nzSamplerWrap nzSamplerWrap_Max = nzSamplerWrap_Repeat }; -enum nzShaderTarget -{ - nzShaderTarget_FullscreenQuad, - nzShaderTarget_Model, - nzShaderTarget_None, - nzShaderTarget_Sprite, - - nzShaderTarget_Max = nzShaderTarget_Sprite -}; - enum nzShaderUniform { nzShaderUniform_EyePosition, diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index d4347d25f..d1d7b8ca3 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -87,7 +87,7 @@ namespace "void main()\n" "{\n" " gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n" - " vTexCoord = vec3(VertexPosition.x, -VertexPosition.y, -VertexPosition.z);\n" + " vTexCoord = vec3(VertexPosition.x, VertexPosition.y, -VertexPosition.z);\n" "}\n"; const char* vertexSource140 = @@ -102,7 +102,7 @@ namespace "void main()\n" "{\n" " gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n" - " vTexCoord = vec3(VertexPosition.x, -VertexPosition.y, -VertexPosition.z);\n" + " vTexCoord = vec3(VertexPosition.x, VertexPosition.y, -VertexPosition.z);\n" "}\n"; ///TODO: Remplacer ça par des ShaderNode diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 476800edf..ef9e096d9 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -1941,8 +1941,8 @@ GLenum NzOpenGL::CubemapFace[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, // nzCubemapFace_PositiveX GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // nzCubemapFace_NegativeX - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // nzCubemapFace_PositiveY (Inversion pour les standards OpenGL) - GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // nzCubemapFace_NegativeY (Inversion pour les standards OpenGL) + GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // nzCubemapFace_PositiveY + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // nzCubemapFace_NegativeY GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // nzCubemapFace_PositiveZ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z // nzCubemapFace_NegativeZ }; diff --git a/src/Nazara/Utility/Loaders/PCX/Loader.cpp b/src/Nazara/Utility/Loaders/PCX/Loader.cpp index 6f3558f95..d0b75dff2 100644 --- a/src/Nazara/Utility/Loaders/PCX/Loader.cpp +++ b/src/Nazara/Utility/Loaders/PCX/Loader.cpp @@ -287,7 +287,7 @@ namespace /* for each color plane */ for (int c = 0; c < 3; ++c) { - nzUInt8* ptr = &pixels[y * width * 4]; + nzUInt8* ptr = &pixels[y * width * 3]; int bytes = header.bytesPerScanLine; /* decode line number y */ @@ -324,7 +324,7 @@ namespace } default: - NazaraError("Failed to load " + NzString::Number(bitCount) + " bitcount pcx files"); + NazaraError("Unsupported " + NzString::Number(bitCount) + " bitcount for pcx files"); return false; }