From aa441eefe766f765d14423a3a6517db8f81c7aeb Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Tue, 25 Feb 2020 23:46:56 -0500 Subject: [PATCH] Fix registration of colour buffer data --- src/client/renderable.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/renderable.hpp b/src/client/renderable.hpp index 8b02187..116ae8f 100644 --- a/src/client/renderable.hpp +++ b/src/client/renderable.hpp @@ -33,7 +33,7 @@ namespace Renderable { if (this->colour_buffer_data != 0) { glGenBuffers(1, &this->colour_buffer); glBindBuffer(GL_ARRAY_BUFFER, this->colour_buffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(this->colour_buffer_data), + glBufferData(GL_ARRAY_BUFFER, this->colour_buffer_data_size, this->colour_buffer_data, GL_STATIC_DRAW); } } @@ -55,8 +55,8 @@ namespace Renderable { 0, // stride (void*)0 // array buffer offset ); - glDrawArrays(GL_TRIANGLES, 0, this->vertex_buffer_data_size / sizeof(GLfloat) / 3); // Starting from vertex 0; 3 vertices total -> 1 triangle if (this->colour_buffer == 0) { + glDrawArrays(GL_TRIANGLES, 0, this->vertex_buffer_data_size / sizeof(GLfloat) / 3); // Starting from vertex 0; 3 vertices total -> 1 triangle glDisableVertexAttribArray(0); glUseProgram(0); return; @@ -71,6 +71,7 @@ namespace Renderable { 0, // stride (void*)0 // array buffer offset ); + glDrawArrays(GL_TRIANGLES, 0, this->vertex_buffer_data_size / sizeof(GLfloat) / 3); // Starting from vertex 0; 3 vertices total -> 1 triangle glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glUseProgram(0);