renderer: Add damage renderer

shader-damage-experiments
Andri Yngvason 2020-03-25 23:17:00 +00:00
parent 6536cbd56f
commit 7e709c23e9
2 changed files with 23 additions and 0 deletions

View File

@ -85,3 +85,4 @@ GLuint renderer_next_tex(struct renderer* self);
GLuint renderer_last_tex(const struct renderer* self); GLuint renderer_last_tex(const struct renderer* self);
void render(struct renderer* self); void render(struct renderer* self);
void render_damage(struct renderer* self);

View File

@ -409,6 +409,8 @@ void gl_draw(void)
void render(struct renderer* self) void render(struct renderer* self)
{ {
glBindFramebuffer(GL_FRAMEBUFFER, self->frame_fbo.fbo);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(self->tex_target, renderer_current_tex(self)); glBindTexture(self->tex_target, renderer_current_tex(self));
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
@ -425,6 +427,26 @@ void render(struct renderer* self)
gl_draw(); 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) void destroy_fbo(struct renderer_fbo* fbo)
{ {
glDeleteFramebuffers(1, &fbo->fbo); glDeleteFramebuffers(1, &fbo->fbo);