BIG REFACTOR Part 2

This commit is contained in:
2022-02-16 18:34:49 +01:00
parent bdebabb79e
commit 97a33e5517
11 changed files with 98 additions and 106 deletions

View File

@@ -42,8 +42,8 @@ VertexBuffer::~VertexBuffer() {
VertexBuffer::VertexBuffer(const std::vector<float>& data, unsigned int stride) : m_DataStride(stride) {
glGenBuffers(1, &m_ID);
bind();
glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(float), nullptr, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, data.size() * sizeof(float), data.data());
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(data.size() * sizeof(float)), nullptr, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(data.size() * sizeof(float)), data.data());
unbind();
}
@@ -66,7 +66,7 @@ void VertexBuffer::addVertexAttribPointer(unsigned int index, unsigned int coord
void VertexBuffer::bindVertexAttribs() const {
for (const VertexAttribPointer& pointer : m_VertexAttribs) {
glEnableVertexAttribArray(pointer.m_Index);
glVertexAttribPointer(pointer.m_Index, pointer.m_Size, GL_FLOAT, false, m_DataStride * sizeof(float), (void*)(intptr_t)pointer.m_Offset);
glVertexAttribPointer(pointer.m_Index, static_cast<GLint>(pointer.m_Size), GL_FLOAT, false, m_DataStride * sizeof(float), reinterpret_cast<void*>(pointer.m_Offset));
}
}
}