From b73b812bf8f00843c0eaa6a7f0814073c986f667 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 26 Oct 2019 21:12:15 +0000 Subject: [PATCH] Keep the last texture --- include/render.h | 1 + src/render.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/render.h b/include/render.h index 2f13790..e07abe3 100644 --- a/include/render.h +++ b/include/render.h @@ -25,6 +25,7 @@ struct renderer { EGLDisplay display; EGLSurface surface; EGLContext context; + GLuint last_texture; GLuint dmabuf_shader_program; GLuint texture_shader_program; uint32_t width; diff --git a/src/render.c b/src/render.c index 02cccc4..0c89e4c 100644 --- a/src/render.c +++ b/src/render.c @@ -271,6 +271,9 @@ void gl_render(void) void renderer_destroy(struct renderer* self) { + if (self->last_texture) + glDeleteTextures(1, &self->last_texture); + glDeleteProgram(self->dmabuf_shader_program); glDeleteProgram(self->texture_shader_program); eglMakeCurrent(self->display, EGL_NO_SURFACE, EGL_NO_SURFACE, @@ -429,8 +432,11 @@ int render_dmabuf_frame(struct renderer* self, struct dmabuf_frame* frame) glUseProgram(self->dmabuf_shader_program); gl_render(); + if (self->last_texture) + glDeleteTextures(1, &self->last_texture); + self->last_texture = tex; + glBindTexture(GL_TEXTURE_2D, 0); - glDeleteTextures(1, &tex); eglDestroyImageKHR(self->display, image); return 0; @@ -457,8 +463,11 @@ int render_framebuffer(struct renderer* self, const void* addr, uint32_t format, glUseProgram(self->texture_shader_program); gl_render(); + if (self->last_texture) + glDeleteTextures(1, &self->last_texture); + self->last_texture = tex; + glBindTexture(GL_TEXTURE_2D, 0); - glDeleteTextures(1, &tex); return 0; }