Advertisement
Guest User

VertexArray.cpp

a guest
Aug 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include "VertexArray.h"
  2.  
  3. VertexArray::VertexArray()
  4. {
  5.     glGenVertexArrays(1, &vao_);
  6.     glBindVertexArray(vao_);
  7.     unbind();
  8. }
  9.  
  10. VertexArray::~VertexArray()
  11. {
  12.     unbind();
  13.     glDeleteVertexArrays(1, &vao_);
  14. }
  15.  
  16. void VertexArray::bind() const
  17. {
  18.     glBindVertexArray(vao_);
  19. }
  20.  
  21. void VertexArray::unbind() const
  22. {
  23.     glBindVertexArray(0);
  24. }
  25.                            //layout location, whether the vert attr is a vec3(so 3 values) etc.., then type of data(GL_FLOAT), dont normalize values, then stride, then offset
  26. void VertexArray::addVertexBufferData(int location, int sizeOfVertexAttr, int dataType, int stride, int offset)
  27. {
  28.     glEnableVertexAttribArray(location); //vertex attrib loc to enable in the vertex shader
  29.     glVertexAttribPointer(location, sizeOfVertexAttr, dataType, GL_FALSE, stride, (void*)offset);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement