39 lines
730 B
C++
39 lines
730 B
C++
|
|
#pragma once
|
|
|
|
#include "vertex.hpp"
|
|
#include <glm/matrix.hpp>
|
|
|
|
namespace Graphics {
|
|
template <int VERTICES, int INDICES>
|
|
struct Primitive {
|
|
Vertex m_vertices[VERTICES];
|
|
unsigned int m_indices[INDICES];
|
|
|
|
constexpr Primitive with_colour(glm::vec4 colour) const {
|
|
Primitive p = *this;
|
|
for(Vertex& v : p.m_vertices) {
|
|
v.m_colour = colour;
|
|
}
|
|
return p;
|
|
}
|
|
|
|
constexpr Primitive with_matrix(glm::mat4 mat) const {
|
|
Primitive p = *this;
|
|
for(Vertex& v : p.m_vertices) {
|
|
v.m_pos = mat * v.m_pos;
|
|
}
|
|
return p;
|
|
}
|
|
|
|
constexpr Primitive with_translation(glm::vec3 vec) const {
|
|
Primitive p = *this;
|
|
for(Vertex& v : p.m_vertices) {
|
|
v.m_pos += glm::vec4(vec, 0);
|
|
}
|
|
return p;
|
|
}
|
|
};
|
|
};
|
|
|