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) void VertexArray::addVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer)
{ {
const auto& layout = vertexBuffer->getLayout();
ASSERT(layout.getElements().size(), "VertexBuffer has no layout");
this->bind(); this->bind();
vertexBuffer->bind(); vertexBuffer->bind();
uint32_t index = 0; uint32_t index = 0;
for (const auto& element : vertexBuffer->getLayout()) { for (const auto& element : layout) {
glEnableVertexAttribArray(index); glEnableVertexAttribArray(index);
glVertexAttribPointer( glVertexAttribPointer(
index, index,
element.getTypeCount(), element.getTypeCount(),
element.getTypeGL(), element.getTypeGL(),
element.getNormalized() ? GL_TRUE : GL_FALSE, element.getNormalized() ? GL_TRUE : GL_FALSE,
vertexBuffer->getLayout().getStride(), layout.getStride(),
reinterpret_cast<const void*>(element.getOffset())); reinterpret_cast<const void*>(element.getOffset()));
index++; index++;

Loading…
Cancel
Save