Allow triangle class to draw multiple gl triangles
This commit is contained in:
parent
862833fc71
commit
625ba885c5
|
@ -46,24 +46,20 @@ int main(int argc, char *argv[]) {
|
||||||
glm::vec3(0.5f, -0.5f, 0.f),
|
glm::vec3(0.5f, -0.5f, 0.f),
|
||||||
glm::vec3(0.f, 0.5f, 0.f),
|
glm::vec3(0.f, 0.5f, 0.f),
|
||||||
}; */
|
}; */
|
||||||
/* std::vector<glm::vec3> vertices = {
|
std::vector<glm::vec3> vertices = {
|
||||||
glm::vec3(0.5f, 0.5f, 0.0f),
|
glm::vec3(0.5f, 0.5f, 0.0f),
|
||||||
glm::vec3(0.5f, -0.5f, 0.0f),
|
glm::vec3(0.5f, -0.5f, 0.0f),
|
||||||
glm::vec3(-0.5f, 0.5f, 0.0f),
|
glm::vec3(-0.5f, 0.5f, 0.0f),
|
||||||
|
|
||||||
|
glm::vec3(0.5f, -0.5f, 0.0f),
|
||||||
|
glm::vec3(-0.5f, -0.5f, 0.0f),
|
||||||
|
glm::vec3(-0.5f, 0.5f, 0.0f),
|
||||||
};
|
};
|
||||||
|
|
||||||
std::shared_ptr<simpleengine::Event> tri(new simpleengine::shapes_2d::Triangle(base_shader_program, vertices));
|
std::shared_ptr<simpleengine::Event> tri(new simpleengine::shapes_2d::Triangle(base_shader_program, vertices));
|
||||||
game.add_event(tri); */
|
game.add_event(tri);
|
||||||
|
|
||||||
/* 0.5f, 0.5f, 0.0f, // top right
|
/* std::vector<glm::vec3> vertices = {
|
||||||
0.5f, -0.5f, 0.0f, // bottom right
|
|
||||||
-0.5f, 0.5f, 0.0f, // top left
|
|
||||||
// second triangle
|
|
||||||
0.5f, -0.5f, 0.0f, // bottom right
|
|
||||||
-0.5f, -0.5f, 0.0f, // bottom left
|
|
||||||
-0.5f, 0.5f, 0.0f */
|
|
||||||
|
|
||||||
std::vector<glm::vec3> vertices = {
|
|
||||||
glm::vec3(0.5f, 0.5f, 0.f), // top right
|
glm::vec3(0.5f, 0.5f, 0.f), // top right
|
||||||
glm::vec3(0.5f, -0.5f, 0.f), // bottom right
|
glm::vec3(0.5f, -0.5f, 0.f), // bottom right
|
||||||
glm::vec3(-0.5f, -0.5f, 0.f), // bottom left
|
glm::vec3(-0.5f, -0.5f, 0.f), // bottom left
|
||||||
|
@ -76,7 +72,7 @@ int main(int argc, char *argv[]) {
|
||||||
};
|
};
|
||||||
|
|
||||||
std::shared_ptr<simpleengine::Event> square(new simpleengine::shapes_2d::Square(base_shader_program, vertices, indicies));
|
std::shared_ptr<simpleengine::Event> square(new simpleengine::shapes_2d::Square(base_shader_program, vertices, indicies));
|
||||||
game.add_event(square);
|
game.add_event(square); */
|
||||||
|
|
||||||
return game.run();
|
return game.run();
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@ namespace simpleengine::shapes_2d {
|
||||||
|
|
||||||
vao.bind();
|
vao.bind();
|
||||||
vbo.buffer(vertices.data(), 0, vertices.size() * sizeof(float) * 3); // 3 floats are in each "row" of the vector.
|
vbo.buffer(vertices.data(), 0, vertices.size() * sizeof(float) * 3); // 3 floats are in each "row" of the vector.
|
||||||
vao.enable_attrib(vbo, 0, vertices.size(), GL_FLOAT, 3 * sizeof(float), 0);
|
vao.enable_attrib(vbo, 0, 3, GL_FLOAT, 3 * sizeof(float), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Triangle() = default;
|
virtual ~Triangle() = default;
|
||||||
|
@ -52,7 +52,7 @@ namespace simpleengine::shapes_2d {
|
||||||
glUseProgram(*shader_program);
|
glUseProgram(*shader_program);
|
||||||
|
|
||||||
vao.bind();
|
vao.bind();
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawArrays(GL_TRIANGLES, 0, vertices.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue