From 85ad73153d1193e51e77ca825416df3794443fa4 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 17 Dec 2018 19:08:50 +0100 Subject: Fix glDrawArray call --- src/buffer/vertex/fluid_cell_buffer.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/buffer') diff --git a/src/buffer/vertex/fluid_cell_buffer.cc b/src/buffer/vertex/fluid_cell_buffer.cc index c602e0c..a0bfcc3 100644 --- a/src/buffer/vertex/fluid_cell_buffer.cc +++ b/src/buffer/vertex/fluid_cell_buffer.cc @@ -1,16 +1,20 @@ #include "fluid_cell_buffer.h" +#include + FluidCellBuffer::FluidCellBuffer(GLuint nX, GLuint nY): - _data(3*nX*nY, GLfloat{}) { + _nX(nX), _nY(nY) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); glBindVertexArray(_array); glBindBuffer(GL_ARRAY_BUFFER, _buffer); + + const std::vector data(3*nX*nY, GLfloat{}); glBufferData( GL_ARRAY_BUFFER, - _data.size() * sizeof(GLfloat), - _data.data(), + data.size() * sizeof(GLfloat), + data.data(), GL_DYNAMIC_DRAW ); @@ -29,5 +33,5 @@ GLuint FluidCellBuffer::getBuffer() const { void FluidCellBuffer::draw() const { glBindVertexArray(_array); - glDrawArrays(GL_POINTS, 0, _data.size()); + glDrawArrays(GL_POINTS, 0, _nX*_nY); } -- cgit v1.2.3