From d8c56edc93974be7d71486261b13c2f21aca071b Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 31 Mar 2019 23:40:10 +0200 Subject: [PATCH] Add glutil helper for making the post-prosessing shader mesh --- src/utilities/glutils.cpp | 28 ++++++++++++++++++++++++++++ src/utilities/glutils.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/utilities/glutils.cpp b/src/utilities/glutils.cpp index bba761a..3377d5b 100644 --- a/src/utilities/glutils.cpp +++ b/src/utilities/glutils.cpp @@ -135,3 +135,31 @@ uint generateTexture(const PNGImage& texture) { return id; } + +uint generatePostQuadBuffer() { + static const GLfloat post_vertices[] = { + -1,-1,0.5, 1,-1,0.5, -1,1,0.5, + -1, 1,0.5, 1,-1,0.5, 1,1,0.5, + }; + static const uint post_indexes[] = { + 0, 1, 2, 3, 4, 5 + }; + + GLuint postVAO; + glGenVertexArrays(1, &postVAO); + glBindVertexArray(postVAO); + + GLuint verticeID; + glGenBuffers(1, &verticeID); + glBindBuffer(GL_ARRAY_BUFFER, verticeID); + glBufferData(GL_ARRAY_BUFFER, sizeof(post_vertices), post_vertices, GL_STATIC_DRAW); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); + glEnableVertexAttribArray(0); + + uint indexBufferID; + glGenBuffers(1, &indexBufferID); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(post_indexes), post_indexes, GL_STATIC_DRAW); + + return postVAO; +} diff --git a/src/utilities/glutils.h b/src/utilities/glutils.h index 1583687..941a347 100644 --- a/src/utilities/glutils.h +++ b/src/utilities/glutils.h @@ -9,3 +9,5 @@ unsigned int generateBuffer(const Mesh &mesh, bool doAddTangents=false); void addTangents(unsigned int vaoID, const Mesh& mesh); unsigned int generateTexture(const PNGImage& texture); + +uint generatePostQuadBuffer();