From: yu.dongliang <18588496441@163.com> Date: Sun, 16 Apr 2023 14:21:33 +0000 (+0800) Subject: gtk gl X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=simplay.git gtk gl --- diff --git a/main.c b/main.c index 1d61294..7ff4cf2 100644 --- a/main.c +++ b/main.c @@ -70,7 +70,7 @@ static gboolean render(GtkGLArea* self, GdkGLContext* context, gpointer user_dat if (gtk_gl_area_get_error (self) != NULL) return FALSE; - glViewport(0, 0, 1920, 1080); +// glViewport(0, 0, 1920, 1080); glClearColor (1.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT); diff --git a/simp_gtk_gl.c b/simp_gtk_gl.c index 16a6107..62b967a 100644 --- a/simp_gtk_gl.c +++ b/simp_gtk_gl.c @@ -131,7 +131,7 @@ static int init_texture(GLuint* ptex, GLenum format, int w, int h, uint8_t* data return 0; } -int _gtk_gl_open(simp_avio_t* io, const char* in, const char* out) +static int _gtk_gl_open(simp_avio_t* io, const char* in, const char* out) { simp_gl_t* gl = calloc(1, sizeof(simp_gl_t)); if (!gl) @@ -142,6 +142,28 @@ int _gtk_gl_open(simp_avio_t* io, const char* in, const char* out) return 0; } +static int _gtk_gl_close(simp_avio_t* io) +{ + simp_gl_t* gl; + + if (io && io->priv) { + gl = io->priv; + + glDeleteTextures(1, &gl->texture_y); + glDeleteTextures(1, &gl->texture_u); + glDeleteTextures(1, &gl->texture_v); + + glDeleteBuffers (2, gl->buffers); + + glDeleteVertexArrays(1, &gl->vao); + + free(gl); + io->priv = NULL; + } + + return 0; +} + static int _gl_init(simp_gl_t* gl) { init_buffers(gl); @@ -178,7 +200,6 @@ static int _gl_init(simp_gl_t* gl) static int _gtk_gl_run(simp_avio_t* io) { - scf_loge("%s(),%d\n", __func__, __LINE__); simp_frame_t* f; scf_list_t* l; simp_gl_t* gl = io->priv; @@ -207,6 +228,9 @@ static int _gtk_gl_run(simp_avio_t* io) for (i = 0; i < SIMP_GL_HEIGHT / 2; i++) memcpy(gl->v + i * SIMP_GL_WIDTH / 2, f->frame->data[2] + i * f->frame->linesize[2], SIMP_GL_WIDTH / 2); + + simp_frame_free(f); + f = NULL; } else pthread_mutex_unlock(&io->mutex); @@ -255,5 +279,6 @@ simp_avio_ops_t simp_avio_gtk_gl = { .type = "gtk_gl", .open = _gtk_gl_open, + .close = _gtk_gl_close, .run = _gtk_gl_run, };