aboutsummaryrefslogtreecommitdiff
path: root/src/buffer/vertex/lattice_cell_buffer.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-04-18 22:15:39 +0200
committerAdrian Kummerlaender2019-04-18 22:15:39 +0200
commit34566b28a82869cbf004d91c6d658ba71d40ed97 (patch)
tree5322ec9bf7f48a96390d638d410aff0abfe21348 /src/buffer/vertex/lattice_cell_buffer.cc
parent1ad4daa0289c56e3d6b896d5037002aa6b461674 (diff)
downloadcompustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar.gz
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar.bz2
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar.lz
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar.xz
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.tar.zst
compustream-34566b28a82869cbf004d91c6d658ba71d40ed97.zip
Bind key to reset lattice buffers
i.e. restarting the simulation without clearing the geometry
Diffstat (limited to 'src/buffer/vertex/lattice_cell_buffer.cc')
-rw-r--r--src/buffer/vertex/lattice_cell_buffer.cc14
1 files changed, 6 insertions, 8 deletions
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<GLfloat> 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<GLfloat> data = makeLattice(nX, nY);
+void LatticeCellBuffer::init() {
+ const std::vector<GLfloat> 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 {