aboutsummaryrefslogtreecommitdiff
path: root/src/buffer/vertex/material_buffer.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-23 16:10:08 +0100
committerAdrian Kummerlaender2019-02-23 16:10:08 +0100
commit389da8159978571e8156ff7692bc595d957e846e (patch)
treebd40ebff4b5f917a2d25ce76b973709922aa7b59 /src/buffer/vertex/material_buffer.cc
parent9779fd7484f7af6d10ae28ca3763c6d938c341e3 (diff)
downloadcompustream-389da8159978571e8156ff7692bc595d957e846e.tar
compustream-389da8159978571e8156ff7692bc595d957e846e.tar.gz
compustream-389da8159978571e8156ff7692bc595d957e846e.tar.bz2
compustream-389da8159978571e8156ff7692bc595d957e846e.tar.lz
compustream-389da8159978571e8156ff7692bc595d957e846e.tar.xz
compustream-389da8159978571e8156ff7692bc595d957e846e.tar.zst
compustream-389da8159978571e8156ff7692bc595d957e846e.zip
Store material in fluid buffer and improve visualization
Replaces the density value which is actually not that useful for visualization. Encoding integer values as floats by casting and comparing them using exact floating point comparison is not very safe but works out for now.
Diffstat (limited to 'src/buffer/vertex/material_buffer.cc')
-rw-r--r--src/buffer/vertex/material_buffer.cc39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/buffer/vertex/material_buffer.cc b/src/buffer/vertex/material_buffer.cc
deleted file mode 100644
index d193318..0000000
--- a/src/buffer/vertex/material_buffer.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "material_buffer.h"
-
-#include <vector>
-
-MaterialBuffer::MaterialBuffer(GLuint nX, GLuint nY, std::function<int(int,int)>&& geometry):
- _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 ) {
- for ( int y = 0; y < nY; ++y ) {
- data[y*nX + x] = geometry(x,y);
- }
- }
-
- 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;
-}