From 24478a8a72b17d54346fb8d648e53448c3819e9d Mon Sep 17 00:00:00 2001 From: quilloss Date: Sun, 26 Jun 2016 19:08:24 +0800 Subject: vo_opengl utils: use gl->main_fb when reading window content The main framebuffer is not the default framebuffer for the dxinterop backend. Bind the main framebuffer and use the appropriate attachment when reading the window content. Fix #3284 --- video/out/opengl/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 73b411e66c..8ddae33d8f 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -109,8 +109,10 @@ mp_image_t *gl_read_window_contents(GL *gl) mp_image_t *image = mp_image_alloc(IMGFMT_RGB24, vp[2], vp[3]); if (!image) return NULL; + gl->BindFramebuffer(GL_FRAMEBUFFER, gl->main_fb); + GLenum obj = gl->main_fb ? GL_COLOR_ATTACHMENT0 : GL_FRONT; gl->PixelStorei(GL_PACK_ALIGNMENT, 1); - gl->ReadBuffer(GL_FRONT); + gl->ReadBuffer(obj); //flip image while reading (and also avoid stride-related trouble) for (int y = 0; y < vp[3]; y++) { gl->ReadPixels(vp[0], vp[1] + vp[3] - y - 1, vp[2], 1, @@ -118,6 +120,7 @@ mp_image_t *gl_read_window_contents(GL *gl) image->planes[0] + y * image->stride[0]); } gl->PixelStorei(GL_PACK_ALIGNMENT, 4); + gl->BindFramebuffer(GL_FRAMEBUFFER, 0); return image; } -- cgit v1.2.3