Fix registration of colour buffer data

This commit is contained in:
Kienan Stewart 2020-02-25 23:46:56 -05:00
parent edb59de234
commit aa441eefe7
1 changed files with 3 additions and 2 deletions

View File

@ -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);