diff options
Diffstat (limited to 'src/buffer/vertex')
-rw-r--r-- | src/buffer/vertex/fluid_cell_buffer.cc | 12 |
1 files changed, 8 insertions, 4 deletions
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 <vector> + 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<GLfloat> 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); } |