Program Listing for File Mesh.hpp¶
↰ Return to documentation for file (gui/Demeter/Renderer/Mesh.hpp)
#pragma once
#include <vector>
#include "Camera.hpp"
#include "Shader.hpp"
#include "Texture.hpp"
#include "Vertex.hpp"
struct Mesh {
private:
GLuint VAO, VBO, EBO = 0;
std::string _name;
std::unique_ptr<std::vector<Vertex>> _vertices;
std::unique_ptr<std::vector<unsigned int>> _indices;
std::shared_ptr<Texture> _texture = nullptr;
void GenMesh();
public:
Mesh() = default;
Mesh(const Mesh &) = delete;
Mesh &operator=(const Mesh &) = delete;
~Mesh();
[[nodiscard]] bool Init(
const std::string &name,
std::unique_ptr<std::vector<Vertex>> vv,
std::unique_ptr<std::vector<unsigned int>> vi);
[[nodiscard]] const std::string &GetName() const
{
return _name;
}
void SetTexture(std::shared_ptr<Texture> t);
void
Draw(ShaderProgram &shader, const glm::mat4 &modelMatrix, Camera &camera)
const;
friend std::ostream &operator<<(std::ostream &os, const Mesh &mesh)
{
for (const Vertex &v: *mesh._vertices)
os << v << '\n';
for (size_t i = 0; i < mesh._indices->size(); i += 3)
os << mesh._indices->at(i) << ' ' << mesh._indices->at(i + 1) << ' '
<< mesh._indices->at(i + 2) << '\n';
return os;
}
};