13 const std::vector<IndexedRectangle>& rect,
14 const std::vector<IndexedRectangle>& tri,
15 const std::vector<IndexedColoredRectangle>& coloredRect,
16 const std::vector<IndexedColoredRectangle>& coloredTri) {
17 for (
auto& t : rect) {
19 verticesBuff.push_back(glm::vec3(vert.at(t.v1).x, vert.at(t.v1).y, vert.at(t.v1).z));
20 verticesBuff.push_back(glm::vec3(vert.at(t.v2).x, vert.at(t.v2).y, vert.at(t.v2).z));
21 verticesBuff.push_back(glm::vec3(vert.at(t.v3).x, vert.at(t.v3).y, vert.at(t.v3).z));
22 verticesBuff.push_back(glm::vec3(vert.at(t.v4).x, vert.at(t.v4).y, vert.at(t.v4).z));
28 verticesBuff.push_back(glm::vec3(vert.at(t.v1).x, vert.at(t.v1).y, vert.at(t.v1).z));
29 verticesBuff.push_back(glm::vec3(vert.at(t.v2).x, vert.at(t.v2).y, vert.at(t.v2).z));
30 verticesBuff.push_back(glm::vec3(vert.at(t.v3).x, vert.at(t.v3).y, vert.at(t.v3).z));
34 for (
auto& t : coloredRect) {
36 verticesColorBuff.push_back(glm::vec3(vert.at(t.v1).x, vert.at(t.v1).y, vert.at(t.v1).z));
37 verticesColorBuff.push_back(glm::vec3(vert.at(t.v2).x, vert.at(t.v2).y, vert.at(t.v2).z));
38 verticesColorBuff.push_back(glm::vec3(vert.at(t.v3).x, vert.at(t.v3).y, vert.at(t.v3).z));
39 verticesColorBuff.push_back(glm::vec3(vert.at(t.v4).x, vert.at(t.v4).y, vert.at(t.v4).z));
43 for (
auto& t : coloredTri) {
45 verticesColorBuff.push_back(glm::vec3(vert.at(t.v1).x, vert.at(t.v1).y, vert.at(t.v1).z));
46 verticesColorBuff.push_back(glm::vec3(vert.at(t.v2).x, vert.at(t.v2).y, vert.at(t.v2).z));
47 verticesColorBuff.push_back(glm::vec3(vert.at(t.v3).x, vert.at(t.v3).y, vert.at(t.v3).z));
53 std::vector<unsigned short> ind;
54 std::vector<glm::vec3> vert;
55 std::vector<glm::vec2> uvBuff;
56 std::vector<unsigned int> tex;
61 for (
int x = 0; x < ((
indicesBuff.at(i) == 0) ? 4 : 3); x++) {
67 ind.push_back(vert.size());
70 tex.push_back(texture);
74 ind.push_back(ind.at(ind.size() - 4));
75 ind.push_back(ind.at(ind.size() - 3));
90 std::vector<unsigned short> indCol;
91 std::vector<glm::vec3> vertCol;
92 std::vector<glm::vec3> cols;
102 indCol.push_back(vertCol.size());
105 cols.push_back(glm::vec3(c.x, c.y, c.z));
109 indCol.push_back(indCol.at(indCol.size() - 4));
110 indCol.push_back(indCol.at(indCol.size() - 3));
131 unsigned int indexStart = 0;
132 unsigned int indexPos = 1;
135 while ((indexStart != indexPos) && (indexPos <
indicesBuff.size())) {
141 std::vector<unsigned short> ind(
indicesBuff.begin() + indexStart,
147 indexStart = indexPos;
void bufferData(int elem, int size, void *data)
Mesh(const std::vector< glm::vec3 > &vertices, const std::vector< IndexedRectangle > &rectangles, const std::vector< IndexedRectangle > &triangles, const std::vector< IndexedColoredRectangle > &coloredRectangles, const std::vector< IndexedColoredRectangle > &coloredTriangles)
static TextureTile & getTile(int index)
std::vector< glm::vec3 > verticesColorBuff
std::vector< unsigned int > colorsBuff
static void drawGL(ShaderBuffer &vertices, ShaderBuffer &uvs, glm::vec4 color, unsigned int texture, TextureStorage store=TextureStorage::SYSTEM, unsigned int mode=GL_TRIANGLES, ShaderTexture *target=nullptr, Shader &shader=textShader)
void display(glm::mat4 MVP, ShaderTexture *shaderTexture=nullptr)
std::vector< unsigned short > indicesColorBuff
#define assertEqual(x, y)
ShaderBuffer verticesColor
static glm::vec4 getPalette(int index)
std::vector< unsigned int > texturesBuff
ShaderBuffer indicesColor
std::vector< glm::vec3 > verticesBuff
std::vector< unsigned short > indicesBuff