diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-07-07 23:12:04 -0300 |
---|---|---|
committer | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-07-07 23:12:04 -0300 |
commit | ab30228b1a57053323363674fa7f137c0329a180 (patch) | |
tree | 50849a3680d61a2428665cc1035f1f4215870acb /Project/VertexArray.cpp | |
parent | 6c0e98a2727d07e1fbb38b78c27d68e98ad09465 (diff) | |
download | PSP.git-ab30228b1a57053323363674fa7f137c0329a180.tar.gz PSP.git-ab30228b1a57053323363674fa7f137c0329a180.tar.xz PSP.git-ab30228b1a57053323363674fa7f137c0329a180.zip |
Voltage heat map implemented
Voltage heat map implemented using modern OpenGL =)
New external library required:
-GLEW
-GLFW
-GLM (incorporeted at the source)
Old memory leaks fixed =)
Diffstat (limited to 'Project/VertexArray.cpp')
-rw-r--r-- | Project/VertexArray.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Project/VertexArray.cpp b/Project/VertexArray.cpp new file mode 100644 index 0000000..2ae8725 --- /dev/null +++ b/Project/VertexArray.cpp @@ -0,0 +1,44 @@ +#include "VertexArray.h" +#include "Renderer.h" +#include "VertexBufferLayout.h" + +VertexArray::VertexArray() +{ + GLCall(glGenVertexArrays(1, &m_rendererID)); +} + +VertexArray::~VertexArray() +{ + GLCall(glDeleteVertexArrays(1, &m_rendererID)); +} + +void VertexArray::AddBuffer(const VertexBuffer& vb, const VertexBufferLayout& layout) +{ + Bind(); + vb.Bind(); + const auto& elements = layout.GetElements(); + unsigned int offset = 0; + for (unsigned int i = 0; i < elements.size(); ++i) { + const auto& element = elements[i]; + GLCall(glEnableVertexAttribArray(i)); + GLCall(glVertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset)); + offset += element.count * VertexBufferElement::GetSizeOfType(element.type); + } +} + +void VertexArray::UpdateBuffer(const VertexBuffer& vb, const void* newVBData, const unsigned int& newVBSize) +{ + Bind(); + vb.Bind(); + vb.SetSubData(newVBData, newVBSize); +} + +void VertexArray::Bind() const +{ + GLCall(glBindVertexArray(m_rendererID)); +} + +void VertexArray::Unbind() const +{ + GLCall(glBindVertexArray(0)); +} |