diff options
author | Adrian Kummerlaender | 2019-02-22 22:24:30 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2019-02-22 22:24:30 +0100 |
commit | 9779fd7484f7af6d10ae28ca3763c6d938c341e3 (patch) | |
tree | 715245275169857f70d07d516bb0bc41e14fff45 /src/buffer/vertex | |
parent | f0b536ac93b3a9a49dfff8a7637f09b153a3b955 (diff) | |
download | compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.gz compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.bz2 compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.lz compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.xz compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.zst compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.zip |
Tidy up wall drawing and geometry initialization
Diffstat (limited to 'src/buffer/vertex')
-rw-r--r-- | src/buffer/vertex/material_buffer.cc | 20 | ||||
-rw-r--r-- | src/buffer/vertex/material_buffer.h | 4 |
2 files changed, 7 insertions, 17 deletions
diff --git a/src/buffer/vertex/material_buffer.cc b/src/buffer/vertex/material_buffer.cc index 82ccea2..d193318 100644 --- a/src/buffer/vertex/material_buffer.cc +++ b/src/buffer/vertex/material_buffer.cc @@ -2,7 +2,7 @@ #include <vector> -MaterialBuffer::MaterialBuffer(GLuint nX, GLuint nY): +MaterialBuffer::MaterialBuffer(GLuint nX, GLuint nY, std::function<int(int,int)>&& geometry): _nX(nX), _nY(nY) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); @@ -13,21 +13,9 @@ MaterialBuffer::MaterialBuffer(GLuint nX, GLuint nY): 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; + for ( int y = 0; y < nY; ++y ) { + data[y*nX + x] = geometry(x,y); + } } glBufferData( diff --git a/src/buffer/vertex/material_buffer.h b/src/buffer/vertex/material_buffer.h index eccf008..4c61c55 100644 --- a/src/buffer/vertex/material_buffer.h +++ b/src/buffer/vertex/material_buffer.h @@ -2,6 +2,8 @@ #include <GL/glew.h> +#include <functional> + class MaterialBuffer { private: const GLuint _nX; @@ -11,7 +13,7 @@ private: GLuint _buffer; public: - MaterialBuffer(GLuint nX, GLuint nY); + MaterialBuffer(GLuint nX, GLuint nY, std::function<int(int,int)>&& geometry); ~MaterialBuffer(); GLuint getBuffer() const; |