From 99d21b87227ef1d6d37ff4fb9a30df01b87c0b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 2 Oct 2017 16:18:15 +0200 Subject: [PATCH] Fix compilation and some warnings --- include/Nazara/Core/Bitset.hpp | 4 ++-- include/Nazara/Core/Bitset.inl | 4 ++-- include/Nazara/Core/SparsePtr.hpp | 1 + include/Nazara/Core/SparsePtr.inl | 19 +++++++++++++++++++ include/Nazara/Utility/Algorithm.hpp | 6 +++--- include/Nazara/Utility/Mesh.hpp | 7 ++++--- src/Nazara/Renderer/ShaderStage.cpp | 2 +- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 04fb2f3c6..97bcc43f3 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -90,8 +90,8 @@ namespace Nz void UnboundedSet(std::size_t bit, bool val = true); bool UnboundedTest(std::size_t bit) const; - Bit operator[](int index); - bool operator[](int index) const; + Bit operator[](std::size_t index); + bool operator[](std::size_t index) const; Bitset operator~() const; diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 44a5e2c16..044c7d0af 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -958,7 +958,7 @@ namespace Nz */ template - typename Bitset::Bit Bitset::operator[](int index) + typename Bitset::Bit Bitset::operator[](std::size_t index) { return Bit(m_blocks[GetBlockIndex(index)], Block(1U) << GetBitIndex(index)); } @@ -969,7 +969,7 @@ namespace Nz */ template - bool Bitset::operator[](int index) const + bool Bitset::operator[](std::size_t index) const { return Test(index); } diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index 10e76c9c3..b90067bc2 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -25,6 +25,7 @@ namespace Nz SparsePtr(); SparsePtr(T* ptr); SparsePtr(VoidPtr ptr, int stride); + SparsePtr(VoidPtr ptr, std::size_t stride); template SparsePtr(const SparsePtr& ptr); SparsePtr(const SparsePtr& ptr) = default; ~SparsePtr() = default; diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index db8fb6b33..a5c9d6212 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -2,7 +2,10 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include +#include #include +#include #include namespace Nz @@ -48,6 +51,22 @@ namespace Nz Reset(ptr, stride); } + /*! + * \brief Constructs a SparsePtr object with a pointer and a step + * + * \param ptr Pointer to data + * \param stride Step between two elements + * + * \remark This constructor only exists because std::size_t is a frequent type for constructing this object, but stride may not be higher than int max + */ + + template + SparsePtr::SparsePtr(VoidPtr ptr, std::size_t stride) + { + assert(stride <= std::numeric_limits::max()); + Reset(ptr, static_cast(stride)); + } + /*! * \brief Constructs a SparsePtr object from another type of SparsePtr * diff --git a/include/Nazara/Utility/Algorithm.hpp b/include/Nazara/Utility/Algorithm.hpp index d3cc0475d..aadec8aaa 100644 --- a/include/Nazara/Utility/Algorithm.hpp +++ b/include/Nazara/Utility/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -21,8 +21,8 @@ namespace Nz { class Joint; - class VertexStruct_XYZ_Normal_UV_Tangent; - class VertexStruct_XYZ_Normal_UV_Tangent_Skinning; + struct VertexStruct_XYZ_Normal_UV_Tangent; + struct VertexStruct_XYZ_Normal_UV_Tangent_Skinning; using MeshVertex = VertexStruct_XYZ_Normal_UV_Tangent; using SkeletalMeshVertex = VertexStruct_XYZ_Normal_UV_Tangent_Skinning; diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index eb93ac783..d3082b82f 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace Nz @@ -52,8 +53,8 @@ namespace Nz class Skeleton; class SubMesh; - typedef VertexStruct_XYZ_Normal_UV_Tangent MeshVertex; - typedef VertexStruct_XYZ_Normal_UV_Tangent_Skinning SkeletalMeshVertex; + using MeshVertex = VertexStruct_XYZ_Normal_UV_Tangent; + using SkeletalMeshVertex = VertexStruct_XYZ_Normal_UV_Tangent_Skinning; using MeshConstRef = ObjectRef; using MeshLibrary = ObjectLibrary; diff --git a/src/Nazara/Renderer/ShaderStage.cpp b/src/Nazara/Renderer/ShaderStage.cpp index 98f863d59..29f434091 100644 --- a/src/Nazara/Renderer/ShaderStage.cpp +++ b/src/Nazara/Renderer/ShaderStage.cpp @@ -161,7 +161,7 @@ namespace Nz #endif const char* tmp = source.GetConstBuffer(); - GLint length = source.GetSize(); + GLint length = static_cast(source.GetSize()); glShaderSource(m_id, 1, &tmp, &length); }