From 239b3ab10b460da34c490a7e06a21c984e21ffb6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 26 Nov 2021 20:21:12 +0000 Subject: Enable all Jason Turner recommended warnings --- gfx/models/mesh.cpp | 11 ++++++----- gfx/models/obj.h | 2 +- gfx/models/obj.impl.cpp | 6 +++--- gfx/models/texture.cpp | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'gfx/models') diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 52ce6bb..82eafbc 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -2,10 +2,10 @@ #include "vertex.hpp" #include -#define offset_ptr(T, m) (((char *)1) + offsetof(T, m) - 1) +#define offset_ptr(T, m) ((reinterpret_cast(1)) + offsetof(T, m) - 1) Mesh::Mesh(const std::span vertices, const std::span indices, GLenum m) : - m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {(GLsizei)indices.size()}, mode {m} + m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {static_cast(indices.size())}, mode {m} { glGenVertexArrays(1, &m_vertexArrayObject); glBindVertexArray(m_vertexArrayObject); @@ -13,7 +13,8 @@ Mesh::Mesh(const std::span vertices, const std::span(sizeof(Vertex) * vertices.size()), vertices.data(), + GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), offset_ptr(Vertex, pos)); @@ -25,8 +26,8 @@ Mesh::Mesh(const std::span vertices, const std::span(sizeof(indices[0]) * indices.size()), indices.data(), + GL_STATIC_DRAW); glBindVertexArray(0); } diff --git a/gfx/models/obj.h b/gfx/models/obj.h index 9a2a30e..6db16c0 100644 --- a/gfx/models/obj.h +++ b/gfx/models/obj.h @@ -25,7 +25,7 @@ public: std::vector vertices; std::vector texCoords; std::vector normals; - using FaceElement = glm::vec<3, int>; + using FaceElement = glm::vec<3, unsigned int>; using Face = std::vector; using Faces = std::vector; using Object = std::pair; diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp index 02996da..745689e 100644 --- a/gfx/models/obj.impl.cpp +++ b/gfx/models/obj.impl.cpp @@ -52,15 +52,15 @@ ObjParser::createMeshData() const const auto & fe {face[idx]}; if (const auto existing = std::find(vertexOrder.begin(), vertexOrder.end(), fe); existing != vertexOrder.end()) { - indices.push_back(std::distance(vertexOrder.begin(), existing)); + indices.push_back(static_cast(std::distance(vertexOrder.begin(), existing))); } else { - indices.push_back(overtices.size()); + indices.push_back(static_cast(overtices.size())); overtices.emplace_back(vertices[fe.x - 1], texCoords[fe.y - 1], -normals[fe.z - 1]); vertexOrder.emplace_back(fe); } }; - f(0); + f(0U); f(idx); f(idx - 1); } diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index 898f495..cd275e8 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -18,7 +18,8 @@ Texture::Texture(const std::filesystem::path & fileName) : m_texture {} glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width, tex.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast(tex.width), static_cast(tex.height), 0, + GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data()); } Texture::~Texture() -- cgit v1.2.3