diff options
author | Adrian Kummerlaender | 2018-12-16 13:58:20 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2018-12-16 13:58:20 +0100 |
commit | 2eb7f9925315989735b4fb746cbd7bda6c9bd5bb (patch) | |
tree | 67e94d6898eac507a8a7c2c6cccf7f875f2979dc /src/buffer | |
parent | 44f5ac32a68a617f93704d44c4339f7db13b323e (diff) | |
download | compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.gz compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.bz2 compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.lz compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.xz compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.zst compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.zip |
Parametrize lattice resolution
Diffstat (limited to 'src/buffer')
-rw-r--r-- | src/buffer/vertex/fluid_cell_buffer.cc | 4 | ||||
-rw-r--r-- | src/buffer/vertex/fluid_cell_buffer.h | 2 | ||||
-rw-r--r-- | src/buffer/vertex/lattice_cell_buffer.cc | 12 | ||||
-rw-r--r-- | src/buffer/vertex/lattice_cell_buffer.h | 2 |
4 files changed, 11 insertions, 9 deletions
diff --git a/src/buffer/vertex/fluid_cell_buffer.cc b/src/buffer/vertex/fluid_cell_buffer.cc index 5056569..c602e0c 100644 --- a/src/buffer/vertex/fluid_cell_buffer.cc +++ b/src/buffer/vertex/fluid_cell_buffer.cc @@ -1,7 +1,7 @@ #include "fluid_cell_buffer.h" -FluidCellBuffer::FluidCellBuffer(): - _data(3*128*128, GLfloat{}) { +FluidCellBuffer::FluidCellBuffer(GLuint nX, GLuint nY): + _data(3*nX*nY, GLfloat{}) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); diff --git a/src/buffer/vertex/fluid_cell_buffer.h b/src/buffer/vertex/fluid_cell_buffer.h index b2b880a..f71c2cb 100644 --- a/src/buffer/vertex/fluid_cell_buffer.h +++ b/src/buffer/vertex/fluid_cell_buffer.h @@ -12,7 +12,7 @@ private: GLuint _buffer; public: - FluidCellBuffer(); + FluidCellBuffer(GLuint nX, GLuint nY); ~FluidCellBuffer(); GLuint getBuffer() const; diff --git a/src/buffer/vertex/lattice_cell_buffer.cc b/src/buffer/vertex/lattice_cell_buffer.cc index 7fb51d8..c2b877b 100644 --- a/src/buffer/vertex/lattice_cell_buffer.cc +++ b/src/buffer/vertex/lattice_cell_buffer.cc @@ -2,16 +2,18 @@ #include <fstream> -LatticeCellBuffer::LatticeCellBuffer(): - _data(9*128*128, GLfloat{1./9.}) { +LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY): + _data(9*nX*nY, GLfloat{1./9.}) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); - for (int x = 50; x < 128-50; x++) { - for (int y = 50; y < 128-50; y++) { + const int inset = 0.4*nX; + + for (int x = inset; x < nX-inset; x++) { + for (int y = inset; y < nY-inset; y++) { for ( int i = -1; i <= 1; ++i ) { for ( int j = -1; j <= 1; ++j ) { - _data[9*128*y + 9*x + (i+1)*3 + j+1] = 1./128.; + _data[9*nX*y + 9*x + (i+1)*3 + j+1] = 1./64.; } } } diff --git a/src/buffer/vertex/lattice_cell_buffer.h b/src/buffer/vertex/lattice_cell_buffer.h index c28319e..f6638c8 100644 --- a/src/buffer/vertex/lattice_cell_buffer.h +++ b/src/buffer/vertex/lattice_cell_buffer.h @@ -12,7 +12,7 @@ private: GLuint _buffer; public: - LatticeCellBuffer(); + LatticeCellBuffer(GLuint nX, GLuint nY); ~LatticeCellBuffer(); GLuint getBuffer() const; |