summaryrefslogtreecommitdiff
path: root/gfx/models
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/models')
-rw-r--r--gfx/models/mesh.cpp11
-rw-r--r--gfx/models/obj.h2
-rw-r--r--gfx/models/obj.impl.cpp6
-rw-r--r--gfx/models/texture.cpp3
4 files changed, 12 insertions, 10 deletions
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 <cstddef>
-#define offset_ptr(T, m) (((char *)1) + offsetof(T, m) - 1)
+#define offset_ptr(T, m) ((reinterpret_cast<char *>(1)) + offsetof(T, m) - 1)
Mesh::Mesh(const std::span<const Vertex> vertices, const std::span<const unsigned int> indices, GLenum m) :
- m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {(GLsizei)indices.size()}, mode {m}
+ m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {static_cast<GLsizei>(indices.size())}, mode {m}
{
glGenVertexArrays(1, &m_vertexArrayObject);
glBindVertexArray(m_vertexArrayObject);
@@ -13,7 +13,8 @@ Mesh::Mesh(const std::span<const Vertex> vertices, const std::span<const unsigne
glGenBuffers(2, m_vertexArrayBuffers.data());
glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[0]);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(Vertex) * vertices.size()), vertices.data(), GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(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<const Vertex> vertices, const std::span<const unsigne
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), offset_ptr(Vertex, normal));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vertexArrayBuffers[1]);
- glBufferData(
- GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)(sizeof(indices[0]) * indices.size()), indices.data(), GL_STATIC_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(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<glm::vec4> vertices;
std::vector<glm::vec3> texCoords;
std::vector<glm::vec3> normals;
- using FaceElement = glm::vec<3, int>;
+ using FaceElement = glm::vec<3, unsigned int>;
using Face = std::vector<FaceElement>;
using Faces = std::vector<Face>;
using Object = std::pair<std::string, Faces>;
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<unsigned int>(std::distance(vertexOrder.begin(), existing)));
}
else {
- indices.push_back(overtices.size());
+ indices.push_back(static_cast<unsigned int>(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<GLsizei>(tex.width), static_cast<GLsizei>(tex.height), 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data());
}
Texture::~Texture()