aboutsummaryrefslogtreecommitdiff
path: root/src/buffer/vertex
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-22 21:49:07 +0100
committerAdrian Kummerlaender2019-02-22 21:49:07 +0100
commitf0b536ac93b3a9a49dfff8a7637f09b153a3b955 (patch)
treedbddeb503d50276fcee06d889d8c8b1edfd36a02 /src/buffer/vertex
parent1870b510acb351b5956402a21572835aa0d2dee0 (diff)
downloadcompustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar.gz
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar.bz2
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar.lz
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar.xz
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.tar.zst
compustream-f0b536ac93b3a9a49dfff8a7637f09b153a3b955.zip
Improvise interactive wall drawing
Internal wall cells need to be disabled to prevent delayed propagation of the reflected populations. This is just quickly thrown together - both the visual drawing and the backend's material handling remain to be improved.
Diffstat (limited to 'src/buffer/vertex')
-rw-r--r--src/buffer/vertex/material_buffer.cc51
-rw-r--r--src/buffer/vertex/material_buffer.h18
2 files changed, 69 insertions, 0 deletions
diff --git a/src/buffer/vertex/material_buffer.cc b/src/buffer/vertex/material_buffer.cc
new file mode 100644
index 0000000..82ccea2
--- /dev/null
+++ b/src/buffer/vertex/material_buffer.cc
@@ -0,0 +1,51 @@
+#include "material_buffer.h"
+
+#include <vector>
+
+MaterialBuffer::MaterialBuffer(GLuint nX, GLuint nY):
+ _nX(nX), _nY(nY) {
+ glGenVertexArrays(1, &_array);
+ glGenBuffers(1, &_buffer);
+
+ glBindVertexArray(_array);
+ glBindBuffer(GL_ARRAY_BUFFER, _buffer);
+
+ std::vector<GLint> data(nX*nY, GLint{1});
+
+ for ( int x = 0; x < nX; ++x ) {
+ data[ 0*nX + x] = 0;
+ data[(nY-1)*nX + x] = 0;
+ }
+ for ( int y = 0; y < nY; ++y ) {
+ data[y*nX + 0] = 0;
+ data[y*nX + nX-1] = 0;
+ }
+
+ for ( int x = 1; x < nX-1; ++x ) {
+ data[ 1*nX + x] = 2;
+ data[(nY-2)*nX + x] = 2;
+ }
+ for ( int y = 1; y < nY-1; ++y ) {
+ data[y*nX + 1] = 2;
+ data[y*nX + nX-2] = 2;
+ }
+
+ glBufferData(
+ GL_ARRAY_BUFFER,
+ data.size() * sizeof(GLint),
+ data.data(),
+ GL_STATIC_DRAW
+ );
+
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 1, GL_INT, GL_FALSE, 0, nullptr);
+}
+
+MaterialBuffer::~MaterialBuffer() {
+ glDeleteBuffers(1, &_buffer);
+ glDeleteVertexArrays(1, &_array);
+}
+
+GLuint MaterialBuffer::getBuffer() const {
+ return _buffer;
+}
diff --git a/src/buffer/vertex/material_buffer.h b/src/buffer/vertex/material_buffer.h
new file mode 100644
index 0000000..eccf008
--- /dev/null
+++ b/src/buffer/vertex/material_buffer.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <GL/glew.h>
+
+class MaterialBuffer {
+private:
+ const GLuint _nX;
+ const GLuint _nY;
+
+ GLuint _array;
+ GLuint _buffer;
+
+public:
+ MaterialBuffer(GLuint nX, GLuint nY);
+ ~MaterialBuffer();
+
+ GLuint getBuffer() const;
+};