Shkyera Engine
Easy to use, game engine for Python
Loading...
Searching...
No Matches
Wireframe.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <glad/glad.h>
4#include <filesystem>
5#include <glm/glm.hpp>
6#include <string>
7#include <vector>
8
9namespace shkyera {
10
11class Wireframe {
12 public:
13 struct Edge {
14 glm::vec3 start;
15 glm::vec3 end;
16
17 Edge(const glm::vec3& s, const glm::vec3& e) : start(s), end(e) {}
18 };
19
20 Wireframe(const std::filesystem::path& filepath);
21 Wireframe(const std::vector<Edge>& edges);
22
23 Wireframe(const Wireframe& other) = delete;
24 Wireframe& operator=(const Wireframe& other) = delete;
25
26 Wireframe(Wireframe&& other) noexcept;
27 Wireframe& operator=(Wireframe&& other) noexcept;
28
29 ~Wireframe();
30
31 void bind() const { glBindVertexArray(_vao); }
32 void unbind() const { glBindVertexArray(0); }
33
34 GLuint getVAO() const { return _vao; }
35 GLuint getVBO() const { return _vbo; }
36 GLsizei getEdgeCount() const { return _edgeCount; }
37
38 class Factory {
39 public:
40 enum class Type { UNDEFINED = 0, CUBE = 1, CYLINDER = 2, SPHERE = 3 };
41
42 static Wireframe create(Type type);
43
44 private:
45 static Wireframe createCube();
47 static Wireframe createSphere();
48 };
49
50 private:
51 void loadFromFile(const std::filesystem::path& filepath);
52 void uploadToGPU(const std::vector<Edge>& edges);
53
54 GLuint _vao, _vbo;
55 GLsizei _edgeCount;
56};
57
58} // namespace shkyera
Definition Wireframe.hpp:38
static Wireframe createCube()
Definition Wireframe.cpp:114
static Wireframe createCylinder()
Definition Wireframe.cpp:138
static Wireframe createSphere()
Definition Wireframe.cpp:171
static Wireframe create(Type type)
Definition Wireframe.cpp:97
Type
Definition Wireframe.hpp:40
Definition Wireframe.hpp:11
GLuint getVBO() const
Definition Wireframe.hpp:35
void loadFromFile(const std::filesystem::path &filepath)
Definition Wireframe.cpp:42
void uploadToGPU(const std::vector< Edge > &edges)
Definition Wireframe.cpp:74
~Wireframe()
Definition Wireframe.cpp:37
GLuint _vao
Definition Wireframe.hpp:54
void unbind() const
Definition Wireframe.hpp:32
GLuint getVAO() const
Definition Wireframe.hpp:34
GLsizei getEdgeCount() const
Definition Wireframe.hpp:36
GLsizei _edgeCount
Definition Wireframe.hpp:55
Wireframe(const Wireframe &other)=delete
Wireframe & operator=(const Wireframe &other)=delete
GLuint _vbo
Definition Wireframe.hpp:54
void bind() const
Definition Wireframe.hpp:31
Definition Asset.hpp:6
Definition Wireframe.hpp:13
Edge(const glm::vec3 &s, const glm::vec3 &e)
Definition Wireframe.hpp:17
glm::vec3 end
Definition Wireframe.hpp:15
glm::vec3 start
Definition Wireframe.hpp:14