From 34566b28a82869cbf004d91c6d658ba71d40ed97 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 18 Apr 2019 22:15:39 +0200 Subject: Bind key to reset lattice buffers i.e. restarting the simulation without clearing the geometry --- src/buffer/vertex/lattice_cell_buffer.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/buffer/vertex/lattice_cell_buffer.cc') diff --git a/src/buffer/vertex/lattice_cell_buffer.cc b/src/buffer/vertex/lattice_cell_buffer.cc index 2011b14..f3ef47d 100644 --- a/src/buffer/vertex/lattice_cell_buffer.cc +++ b/src/buffer/vertex/lattice_cell_buffer.cc @@ -20,13 +20,15 @@ std::vector makeLattice(GLuint nX, GLuint nY) { return data; } -LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY) { - glGenVertexArrays(1, &_array); +LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY): + _nX(nX), _nY(nY) { glGenBuffers(1, &_buffer); + init(); +} - const std::vector data = makeLattice(nX, nY); +void LatticeCellBuffer::init() { + const std::vector data = makeLattice(_nX, _nY); - glBindVertexArray(_array); glBindBuffer(GL_ARRAY_BUFFER, _buffer); glBufferData( GL_ARRAY_BUFFER, @@ -34,14 +36,10 @@ LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY) { data.data(), GL_DYNAMIC_DRAW ); - - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, nullptr); } LatticeCellBuffer::~LatticeCellBuffer() { glDeleteBuffers(1, &_buffer); - glDeleteVertexArrays(1, &_array); } GLuint LatticeCellBuffer::getBuffer() const { -- cgit v1.2.3