4 #include <OpenGL/gl3.h>
8 #include <glm/vec4.hpp>
9 #include <glm/vec3.hpp>
10 #include <glm/vec2.hpp>
42 std::map<DATA_TYPE, std::vector<float>> float_vector1s;
43 std::map<DATA_TYPE, std::vector<glm::vec2>> float_vector2s;
44 std::map<DATA_TYPE, std::vector<glm::vec3>> float_vector3s;
45 std::map<DATA_TYPE, std::vector<glm::vec4>> float_vector4s;
46 std::map<DATA_TYPE, std::vector<double>> double_vector1s;
47 std::map<DATA_TYPE, std::vector<glm::dvec2>> double_vector2s;
48 std::map<DATA_TYPE, std::vector<glm::dvec3>> double_vector3s;
49 std::map<DATA_TYPE, std::vector<glm::dvec4>> double_vector4s;
50 std::map<DATA_TYPE, std::vector<int>> int_vector1s;
51 std::map<DATA_TYPE, std::vector<glm::ivec2>> int_vector2s;
52 std::map<DATA_TYPE, std::vector<glm::ivec3>> int_vector3s;
53 std::map<DATA_TYPE, std::vector<glm::ivec4>> int_vector4s;
54 std::map<DATA_TYPE, std::vector<unsigned int>> unsigned_int_vector1s;
55 std::map<DATA_TYPE, std::vector<glm::uvec2>> unsigned_int_vector2s;
56 std::map<DATA_TYPE, std::vector<glm::uvec3>> unsigned_int_vector3s;
57 std::map<DATA_TYPE, std::vector<glm::uvec4>> unsigned_int_vector4s;
58 std::vector<unsigned int> indices;
59 unsigned int index_count;
60 unsigned int vertex_count;
61 GLenum primitive_type;
64 const unsigned char ANY = 0;
66 const std::map<GLenum, unsigned char> divisibility {
68 {GL_TRIANGLE_STRIP, ANY},
69 {GL_TRIANGLE_FAN, ANY},
76 const std::map<GLenum, unsigned char> minimum {
78 {GL_TRIANGLE_STRIP, 3},
86 void checkDivisibility(
const unsigned int size);
87 void checkMinimum(
const unsigned int size);
88 void clearDataType(
const DATA_TYPE& type);
90 void setHighestZIfHigher(
float z) noexcept;
93 bool mapCompare(std::map<
DATA_TYPE, std::vector<T>> lhs, std::map<
DATA_TYPE, std::vector<T>> rhs);
99 static const std::map<DATA_TYPE, unsigned int>
DataWidth;
106 VertexData(
const GLenum primitive_type = GL_TRIANGLES);
153 void addIndices(
const std::vector<unsigned int>& indices);
192 std::vector<
unsigned int>
getIndices() const noexcept;
Definition: vertex_data.h:24
Definition: vertex_data.h:30
Definition: vertex_data.h:29
Definition: vertex_data.h:33
static const std::map< DATA_TYPE, unsigned int > DataWidth
Definition: vertex_data.h:99
unsigned int numberVertexBufferObjects() const noexcept
Returns number of vertex buffer objects needed for this vertex data.
Definition: vertex_data.cpp:684
void addIndices(const std::vector< unsigned int > &indices)
Adds indices.
Definition: vertex_data.cpp:187
Definition: vertex_data.h:38
Definition: vertex_data.h:37
DATA_TYPE
VertexData possible types.
Definition: vertex_data.h:22
unsigned int getVertexCount() const noexcept
Gets the vertex count.
Definition: vertex_data.cpp:532
VertexData(const GLenum primitive_type=GL_TRIANGLES)
VertexData constructor.
Definition: vertex_data.cpp:9
VertexData operator=(const VertexData &vertex_data)
= operator
Definition: vertex_data.cpp:38
Definition: vertex_data.h:27
Definition: vertex_data.h:26
Class for vertex data.
Definition: vertex_data.h:17
std::string to_string() const noexcept
Returns a string representation of the object.
Definition: vertex_data.cpp:763
Definition: vertex_data.h:23
unsigned int generateVertexArrayObject() const
Generates an opengl vertex array object.
Definition: vertex_data.cpp:691
std::vector< unsigned int > getIndices() const noexcept
Gets the indices.
Definition: vertex_data.cpp:540
bool operator!=(const VertexData &other)
!= operator
Definition: vertex_data.cpp:127
void addVec(DATA_TYPE data_type, const std::vector< T > &vec)
Adds a vector of data for a certain data type.
bool operator==(const VertexData &other)
== operator
Definition: vertex_data.cpp:87
Definition: vertex_data.h:32
float highestZ() const noexcept
Returns the highest Z value found in this vertex data.
Definition: vertex_data.cpp:680
Definition: vertex_data.h:31
std::map< DATA_TYPE, std::vector< T > > getCollapsedVectors() const
Gets a map of collapsed type vectors to a data types.
~VertexData()
Destroys the object.
Definition: vertex_data.cpp:63
Definition: vertex_data.h:34
unsigned int getIndexCount() const noexcept
Gets the index count.
Definition: vertex_data.cpp:536
Definition: vertex_data.h:28
Definition: vertex_data.h:25
Definition: vertex_data.h:36
Definition: vertex_data.h:35