diff --git a/townengine/rendering/quad_element_buffer.h b/townengine/rendering/quad_element_buffer.h index 4f832ee..617e094 100644 --- a/townengine/rendering/quad_element_buffer.h +++ b/townengine/rendering/quad_element_buffer.h @@ -2,6 +2,8 @@ #ifndef QUAD_ELEMENT_BUFFER_H #define QUAD_ELEMENT_BUFFER_H +#include "townengine/util.h" + #include #include @@ -16,12 +18,14 @@ static void bind_quad_element_buffer(void) { glGenBuffers(1, &buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, - QUAD_ELEMENT_BUFFER_LENGTH * 6, + QUAD_ELEMENT_BUFFER_LENGTH * 6 * sizeof(uint16_t), NULL, GL_STATIC_DRAW); uint16_t *const indices = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); + if (!indices) + CRY("Quad indices generation", "glMapBuffer() failed"); for (uint16_t i = 0; i < QUAD_ELEMENT_BUFFER_LENGTH; ++i) { indices[i * 6 + 0] = (uint16_t)(i * 4 + 0);