Browse Source

Add VertexBuffer layout ASSERT check

master
Riyyi 4 years ago
parent
commit
1254a8f0fe
  1. 7
      inferno/src/inferno/render/buffer.cpp

7
inferno/src/inferno/render/buffer.cpp

@ -191,18 +191,21 @@ namespace Inferno {
void VertexArray::addVertexBuffer(const std::shared_ptr<VertexBuffer>& 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<const void*>(element.getOffset()));
index++;

Loading…
Cancel
Save