Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DrawParabol.h"
- DrawParabol::DrawParabol(const ShaderClass *shader) : shader(shader)
- {
- glGenVertexArrays(1, &this->VAO);
- glGenBuffers(1, &this->VBO);
- }
- DrawParabol::~DrawParabol()
- {
- glDeleteVertexArrays(1, &this->VAO);
- glDeleteBuffers(1, &this->VBO);
- }
- void DrawParabol::clear() noexcept
- {
- }
- void DrawParabol::init(std::vector<glm::vec3> & points) noexcept
- {
- glBindVertexArray(this->VAO);
- glBindBuffer(GL_ARRAY_BUFFER, this->VBO);
- glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(glm::vec3), &points[0].x, GL_DYNAMIC_DRAW);
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
- glEnableVertexAttribArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindVertexArray(0);
- size = points.size();
- }
- void DrawParabol::draw() const noexcept
- {
- this->shader->use();
- this->shader->setVec3("color", glm::vec3(10.0f, 0.0f, 0.0f)); //red one
- glBindVertexArray(VAO);
- glLineWidth(5.0f);
- glDrawArrays(GL_LINES, 0, this->size);
- glLineWidth(1.0f);
- glBindVertexArray(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement