aboutsummaryrefslogtreecommitdiff
path: root/src/buffer
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer')
-rw-r--r--src/buffer/vertex/fluid_cell_buffer.h5
-rw-r--r--src/buffer/vertex/lattice_cell_buffer.cc19
-rw-r--r--src/buffer/vertex/lattice_cell_buffer.h4
3 files changed, 12 insertions, 16 deletions
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 <vector>
-
#include <GL/glew.h>
class FluidCellBuffer {
private:
- std::vector<GLfloat> _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 <fstream>
+#include <vector>
-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<GLfloat> 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 <vector>
-
#include <GL/glew.h>
class LatticeCellBuffer {
private:
- std::vector<GLfloat> _data;
-
GLuint _array;
GLuint _buffer;