(bind-func gl_draw
(let ((drawbufs_ptr:GLenum* (zalloc)))
(pset! drawbufs_ptr 0 GL_COLOR_ATTACHMENT0)
(lambda ()
;; bind the second (render-to-texture) framebuffer
(glBindFramebuffer GL_FRAMEBUFFER (FBO_id fbo))
(glDrawBuffers 1 drawbufs_ptr)
;; clear the framebuffer's colour and depth buffers
(glClear (bor GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
;; render the triangle as normal
(glUseProgram sp)
(glBindVertexArray (VAO_id vao))
(glDrawArrays GL_TRIANGLES 0 3)
;; bind default framebuffer
(glBindFramebuffer GL_FRAMEBUFFER 0)
;; clear the framebuffer's colour and depth buffers
(glClear (bor GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
;; our post-processing shader for the screen-space quad
(glUseProgram post_process_sp)
;; bind the quad's VAO
(glBindVertexArray (VAO_id ss_quad_vao))
;; activate the first texture slot and put texture from previous pass in it
(glActiveTexture GL_TEXTURE0)
(glBindTexture GL_TEXTURE_2D (FBO_color_texture fbo))
;; draw the quad
(glDrawArrays GL_TRIANGLE_STRIP 0 4))))