Improve framebuffer handling
This commit is contained in:
parent
9c50aa394c
commit
163cdd63d4
2 changed files with 7 additions and 8 deletions
11
src/main.c
11
src/main.c
|
@ -57,7 +57,6 @@ int main(int argc, char *argv[]) {
|
|||
glUniform1i(glGetUniformLocation(buffer_shader, "u_texture"), 0);
|
||||
|
||||
/* Framebuffer */
|
||||
framebuffer = 0;
|
||||
glGenFramebuffers(1, &framebuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
/* color attachment texture */
|
||||
|
@ -108,6 +107,7 @@ int main(int argc, char *argv[]) {
|
|||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* Setup uniforms */
|
||||
glUseProgram(buffer_shader);
|
||||
glUniform1ui(glGetUniformLocation(buffer_shader, "u_frame"), frame);
|
||||
glUniform1f(glGetUniformLocation(buffer_shader, "u_time"), time);
|
||||
glUniform2f(glGetUniformLocation(buffer_shader, "u_resolution"),
|
||||
|
@ -117,19 +117,19 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
/* Draw the vertices */
|
||||
glBindVertexArray(VAO);
|
||||
glUseProgram(buffer_shader);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_color_buffer);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
/* bind back to default framebuffer */
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/* bind back to default framebuffer */
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* Setup uniforms */
|
||||
glUseProgram(screen_shader);
|
||||
glUniform1ui(glGetUniformLocation(screen_shader, "u_frame"), frame);
|
||||
glUniform1f(glGetUniformLocation(screen_shader, "u_time"), time);
|
||||
glUniform2f(glGetUniformLocation(screen_shader, "u_resolution"),
|
||||
|
@ -139,7 +139,6 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
/* Draw the vertices */
|
||||
glBindVertexArray(VAO);
|
||||
glUseProgram(screen_shader);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_color_buffer);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
|
|
|
@ -88,12 +88,12 @@ unsigned int initialize_vertices() {
|
|||
GL_STATIC_DRAW);
|
||||
|
||||
/* position attribute */
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)0);
|
||||
/* texture coord attribute */
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
|
||||
(void *)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(1);
|
||||
|
||||
log_debug("Vertex data initialized successfully");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue