From ede5386d53a453cb56c9b1c80de0a80322ddc6f1 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 17 Dec 2018 19:09:25 +0100 Subject: Try out velocity norm color mapping --- src/buffer/vertex/fluid_cell_buffer.h | 5 ++--- src/buffer/vertex/lattice_cell_buffer.cc | 19 ++++++++++--------- src/buffer/vertex/lattice_cell_buffer.h | 4 ---- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'src/buffer') diff --git a/src/buffer/vertex/fluid_cell_buffer.h b/src/buffer/vertex/fluid_cell_buffer.h index f71c2cb..9e535cb 100644 --- a/src/buffer/vertex/fluid_cell_buffer.h +++ b/src/buffer/vertex/fluid_cell_buffer.h @@ -1,12 +1,11 @@ #pragma once -#include - #include class FluidCellBuffer { private: - std::vector _data; + const GLuint _nX; + const GLuint _nY; GLuint _array; GLuint _buffer; diff --git a/src/buffer/vertex/lattice_cell_buffer.cc b/src/buffer/vertex/lattice_cell_buffer.cc index c2b877b..ea4e103 100644 --- a/src/buffer/vertex/lattice_cell_buffer.cc +++ b/src/buffer/vertex/lattice_cell_buffer.cc @@ -1,19 +1,20 @@ #include "lattice_cell_buffer.h" -#include +#include -LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY): - _data(9*nX*nY, GLfloat{1./9.}) { +LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); - const int inset = 0.4*nX; + std::vector data(9*nX*nY, GLfloat{1./9.}); + const int insetX = 0.45*nX; + const int insetY = 0.45*nY; - for (int x = inset; x < nX-inset; x++) { - for (int y = inset; y < nY-inset; y++) { + for (int x = insetX; x < nX-insetX; x++) { + for (int y = insetY; y < nY-insetY; y++) { for ( int i = -1; i <= 1; ++i ) { for ( int j = -1; j <= 1; ++j ) { - _data[9*nX*y + 9*x + (i+1)*3 + j+1] = 1./64.; + data[9*nX*y + 9*x + (i+1)*3 + j+1] = 0.5; } } } @@ -23,8 +24,8 @@ LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY): glBindBuffer(GL_ARRAY_BUFFER, _buffer); glBufferData( GL_ARRAY_BUFFER, - _data.size() * sizeof(GLfloat), - _data.data(), + data.size() * sizeof(GLfloat), + data.data(), GL_DYNAMIC_DRAW ); diff --git a/src/buffer/vertex/lattice_cell_buffer.h b/src/buffer/vertex/lattice_cell_buffer.h index f6638c8..e5e00a4 100644 --- a/src/buffer/vertex/lattice_cell_buffer.h +++ b/src/buffer/vertex/lattice_cell_buffer.h @@ -1,13 +1,9 @@ #pragma once -#include - #include class LatticeCellBuffer { private: - std::vector _data; - GLuint _array; GLuint _buffer; -- cgit v1.2.3