summaryrefslogtreecommitdiff
path: root/gfx/models/mesh.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-11-26 20:21:12 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-26 20:21:12 +0000
commit239b3ab10b460da34c490a7e06a21c984e21ffb6 (patch)
tree4ce09f5d091ffbcf063a9d0fc076659dfe9e3142 /gfx/models/mesh.cpp
parentDon't run the app by default (diff)
downloadilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.tar.bz2
ilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.tar.xz
ilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.zip
Enable all Jason Turner recommended warnings
Diffstat (limited to 'gfx/models/mesh.cpp')
-rw-r--r--gfx/models/mesh.cpp11
1 files changed, 6 insertions, 5 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);
}