From 84bcd409a3743e933d039a9b3e073030fd2630df Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 23 May 2018 19:06:47 +0200 Subject: Implement particle trails using overlaying textures --- src/texture_display_buffer.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/texture_display_buffer.h') diff --git a/src/texture_display_buffer.h b/src/texture_display_buffer.h index 530b99d..25fd319 100644 --- a/src/texture_display_buffer.h +++ b/src/texture_display_buffer.h @@ -6,12 +6,11 @@ class TextureDisplayBuffer { private: const std::vector _data; - GLuint _texture; GLuint _array; GLuint _buffer; public: - TextureDisplayBuffer(GLuint texture): + TextureDisplayBuffer(): _data{ -1.f, 1.f, 0.f, 1.f, -1.f, -1.f, 0.f, 0.f, @@ -20,8 +19,7 @@ public: -1.f, 1.f, 0.f, 1.f, 1.f, -1.f, 1.f, 0.f, 1.f, 1.f, 1.f, 1.f - }, - _texture(texture) { + } { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); @@ -47,9 +45,14 @@ public: glDeleteVertexArrays(1, &_array); } - void draw() const { + void draw(const std::vector& textures) const { glBindVertexArray(_array); - glBindTexture(GL_TEXTURE_2D, _texture); + + for ( unsigned int i = 0; i < textures.size(); ++i ) { + glActiveTexture(GL_TEXTURE0+i); + glBindTexture(GL_TEXTURE_2D, textures[i]); + } + glDrawArrays(GL_TRIANGLES, 0, 6); } -- cgit v1.2.3