diff options
Diffstat (limited to 'src/buffer')
-rw-r--r-- | src/buffer/vertex/fluid_cell_buffer.cc | 12 | ||||
-rw-r--r-- | src/buffer/vertex/fluid_cell_buffer.h | 1 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/buffer/vertex/fluid_cell_buffer.cc b/src/buffer/vertex/fluid_cell_buffer.cc index 8fdc579..d9af989 100644 --- a/src/buffer/vertex/fluid_cell_buffer.cc +++ b/src/buffer/vertex/fluid_cell_buffer.cc @@ -5,11 +5,8 @@ FluidCellBuffer::FluidCellBuffer(GLuint nX, GLuint nY, std::function<int(int,int)>&& geometry): _nX(nX), _nY(nY) { glGenBuffers(1, &_buffer); - glBindVertexArray(_array); + enable(); init(std::forward<decltype(geometry)>(geometry)); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - } FluidCellBuffer::~FluidCellBuffer() { @@ -17,9 +14,14 @@ FluidCellBuffer::~FluidCellBuffer() { glDeleteVertexArrays(1, &_array); } -void FluidCellBuffer::init(std::function<int(int,int)>&& geometry) { +void FluidCellBuffer::enable() { + glBindVertexArray(_array); glBindBuffer(GL_ARRAY_BUFFER, _buffer); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); +} +void FluidCellBuffer::init(std::function<int(int,int)>&& geometry) { std::vector<GLfloat> data(3*_nX*_nY, GLfloat{}); for ( int x = 0; x < _nX; ++x ) { diff --git a/src/buffer/vertex/fluid_cell_buffer.h b/src/buffer/vertex/fluid_cell_buffer.h index 791ebea..5148606 100644 --- a/src/buffer/vertex/fluid_cell_buffer.h +++ b/src/buffer/vertex/fluid_cell_buffer.h @@ -16,6 +16,7 @@ public: FluidCellBuffer(GLuint nX, GLuint nY, std::function<int(int,int)>&& geometry); ~FluidCellBuffer(); + void enable(); void init(std::function<int(int,int)>&& geometry); GLuint getBuffer() const; |