diff --git a/include/render.h b/include/render.h index 5cc666a..02bfaaf 100644 --- a/include/render.h +++ b/include/render.h @@ -85,3 +85,4 @@ GLuint renderer_next_tex(struct renderer* self); GLuint renderer_last_tex(const struct renderer* self); void render(struct renderer* self); +void render_damage(struct renderer* self); diff --git a/src/render.c b/src/render.c index 04e18dd..f6d5f9f 100644 --- a/src/render.c +++ b/src/render.c @@ -409,6 +409,8 @@ void gl_draw(void) void render(struct renderer* self) { + glBindFramebuffer(GL_FRAMEBUFFER, self->frame_fbo.fbo); + glActiveTexture(GL_TEXTURE0); glBindTexture(self->tex_target, renderer_current_tex(self)); glActiveTexture(GL_TEXTURE1); @@ -425,6 +427,26 @@ void render(struct renderer* self) gl_draw(); } +void render_damage(struct renderer* self) +{ + glBindFramebuffer(GL_FRAMEBUFFER, self->damage_fbo.fbo); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(self->tex_target, renderer_current_tex(self)); + glActiveTexture(GL_TEXTURE1); + glBindTexture(self->tex_target, renderer_last_tex(self)); + + glUseProgram(self->damage_shader.program); + + glUniform1i(self->damage_shader.u_tex0, 0); + glUniform1i(self->damage_shader.u_tex1, 1); + + const float* proj = transforms[self->output->transform]; + glUniformMatrix2fv(self->damage_shader.u_proj, 1, GL_FALSE, proj); + + gl_draw(); +} + void destroy_fbo(struct renderer_fbo* fbo) { glDeleteFramebuffers(1, &fbo->fbo);