Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include "DrawParabol.h"
  2.  
  3. DrawParabol::DrawParabol(const ShaderClass *shader) : shader(shader)
  4. {
  5. glGenVertexArrays(1, &this->VAO);
  6. glGenBuffers(1, &this->VBO);
  7. }
  8.  
  9. DrawParabol::~DrawParabol()
  10. {
  11. glDeleteVertexArrays(1, &this->VAO);
  12. glDeleteBuffers(1, &this->VBO);
  13. }
  14.  
  15. void DrawParabol::clear() noexcept
  16. {
  17.  
  18. }
  19.  
  20.  
  21. void DrawParabol::init(std::vector<glm::vec3> & points) noexcept
  22. {
  23. glBindVertexArray(this->VAO);
  24. glBindBuffer(GL_ARRAY_BUFFER, this->VBO);
  25. glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(glm::vec3), &points[0].x, GL_DYNAMIC_DRAW);
  26. glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
  27. glEnableVertexAttribArray(0);
  28. glBindBuffer(GL_ARRAY_BUFFER, 0);
  29.  
  30. glBindVertexArray(0);
  31. size = points.size();
  32. }
  33.  
  34. void DrawParabol::draw() const noexcept
  35. {
  36. this->shader->use();
  37. this->shader->setVec3("color", glm::vec3(10.0f, 0.0f, 0.0f)); //red one
  38. glBindVertexArray(VAO);
  39. glLineWidth(5.0f);
  40. glDrawArrays(GL_LINES, 0, this->size);
  41. glLineWidth(1.0f);
  42. glBindVertexArray(0);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement