diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index 5e69321467..343a8598fb 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -672,7 +672,8 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id, "texture %i", src, src_tex_id, tex_id); /* FIXME: try and avoid creating and destroying fbo's every copy... */ - if (!gl->BlitFramebuffer) { + if (!gl->BlitFramebuffer || (!gl->DrawBuffer && !gl->DrawBuffers) + || !gl->ReadBuffer) { /* create a framebuffer object */ n_fbos = 1; gl->GenFramebuffers (n_fbos, &fbo[0]); @@ -696,6 +697,12 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id, gl->DeleteFramebuffers (n_fbos, &fbo[0]); } else { + GLenum multipleRT[] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2 + }; + /* create a framebuffer object */ n_fbos = 2; gl->GenFramebuffers (n_fbos, &fbo[0]); @@ -719,7 +726,10 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id, gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (src)->query, GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "BlitFramebuffer took"); gl->ReadBuffer (GL_COLOR_ATTACHMENT0); - gl->DrawBuffer (GL_COLOR_ATTACHMENT0); + if (gl->DrawBuffers) + gl->DrawBuffers (1, multipleRT); + else + gl->DrawBuffer (GL_COLOR_ATTACHMENT0); gl->BlitFramebuffer (0, 0, out_width, out_height, 0, 0, out_width, out_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (src)->query); @@ -729,6 +739,9 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id, gl->BindFramebuffer (GL_READ_FRAMEBUFFER, 0); gl->DeleteFramebuffers (n_fbos, &fbo[0]); + + if (gl->DrawBuffer) + gl->DrawBuffer (GL_NONE); } gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);