Add glutil helper for making the post-prosessing shader mesh

This commit is contained in:
Peder Bergebakken Sundt 2019-03-31 23:40:10 +02:00
parent 5d07aba7c4
commit d8c56edc93
2 changed files with 30 additions and 0 deletions

View File

@ -135,3 +135,31 @@ uint generateTexture(const PNGImage& texture) {
return id; 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;
}

View File

@ -9,3 +9,5 @@ unsigned int generateBuffer(const Mesh &mesh, bool doAddTangents=false);
void addTangents(unsigned int vaoID, const Mesh& mesh); void addTangents(unsigned int vaoID, const Mesh& mesh);
unsigned int generateTexture(const PNGImage& texture); unsigned int generateTexture(const PNGImage& texture);
uint generatePostQuadBuffer();