diff --git a/inferno/src/inferno/render/buffer.cpp b/inferno/src/inferno/render/buffer.cpp index bc7f675..d9f61ff 100644 --- a/inferno/src/inferno/render/buffer.cpp +++ b/inferno/src/inferno/render/buffer.cpp @@ -191,18 +191,21 @@ namespace Inferno { void VertexArray::addVertexBuffer(const std::shared_ptr& vertexBuffer) { + const auto& layout = vertexBuffer->getLayout(); + ASSERT(layout.getElements().size(), "VertexBuffer has no layout"); + this->bind(); vertexBuffer->bind(); uint32_t index = 0; - for (const auto& element : vertexBuffer->getLayout()) { + for (const auto& element : layout) { glEnableVertexAttribArray(index); glVertexAttribPointer( index, element.getTypeCount(), element.getTypeGL(), element.getNormalized() ? GL_TRUE : GL_FALSE, - vertexBuffer->getLayout().getStride(), + layout.getStride(), reinterpret_cast(element.getOffset())); index++;