From bf2d39541c75af4d1b6c7c9965ce6774198908a4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:29:40 +0200 Subject: [PATCH 1/7] Fixed cubemaps rendering (Skyboxes) Former-commit-id: a8d065cbdf8bdbde55547739e53b4daa6ce2969d --- src/Nazara/Graphics/SkyboxBackground.cpp | 4 ++-- src/Nazara/Renderer/OpenGL.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 }; From 00a35cd565e5df54e72282ef7569ccf523282eb7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:29:54 +0200 Subject: [PATCH 2/7] Removed useless enum Former-commit-id: b342be41eda3271320954a0279cf0a2afdfcd8e2 --- include/Nazara/Renderer/Enums.hpp | 10 ---------- 1 file changed, 10 deletions(-) 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, From 1b949777222112da1a046bd4e421baca94867ac4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:30:12 +0200 Subject: [PATCH 3/7] Added Quaternion::Normalize static method Former-commit-id: a4530be00673dec5b9731b75fb4edbac7ccd69d5 --- include/Nazara/Math/Quaternion.hpp | 1 + include/Nazara/Math/Quaternion.inl | 6 ++++++ 2 files changed, 7 insertions(+) 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) { From e32c0c626e869c80cad7aa0707d587f18d364173 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:30:21 +0200 Subject: [PATCH 4/7] Fixed global math include Former-commit-id: 0f1871a2ecf1e8b94d63612c7357d6fc0ab0287b --- include/Nazara/Math.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 522ceb1e308db346f3c76b4d8698a3adc41a4fdd Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:32:37 +0200 Subject: [PATCH 5/7] Improved SparsePtr class Added implicit conversion from a normal pointer to a sparse pointer Added implicit conversion to boolean Added implicit conversion to normal pointer Added support for const pointers Renamed Get/Set to GetPtr/SetPtr Former-commit-id: 32d5d2ec6a7b296c5b89b722de9ca142d5c64aae --- include/Nazara/Core/SparsePtr.hpp | 21 +++++++++-- include/Nazara/Core/SparsePtr.inl | 62 ++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 13 deletions(-) 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 { From ce2aa91b327a2de9db24ab71626dd9833c04ce94 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Sep 2014 13:35:10 +0200 Subject: [PATCH 7/7] Fixed PCX loader crash Former-commit-id: 3c0734a67d271a68f79a56e986ebd96552ae6d4b --- src/Nazara/Utility/Loaders/PCX/Loader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }