summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl/context.c')
-rw-r--r--video/out/opengl/context.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
index cdaf6320cd..8f44119210 100644
--- a/video/out/opengl/context.c
+++ b/video/out/opengl/context.c
@@ -251,16 +251,21 @@ struct mp_image *ra_gl_ctx_screenshot(struct ra_swapchain *sw)
{
struct priv *p = sw->priv;
+ struct mp_image *screen = mp_image_alloc(IMGFMT_RGB24, p->wrapped_fb->params.w,
+ p->wrapped_fb->params.h);
+ if (!screen)
+ return NULL;
+
+ int dir = p->params.flipped ? 1 : -1;
+
assert(p->wrapped_fb);
- struct mp_image *screen = gl_read_fbo_contents(p->gl, p->main_fb,
- p->wrapped_fb->params.w,
- p->wrapped_fb->params.h);
-
- // OpenGL FB is also read in flipped order, so we need to flip when the
- // rendering is *not* flipped, which in our case is whenever
- // p->params.flipped is true. I hope that made sense
- if (screen && p->params.flipped)
- mp_image_vflip(screen);
+ if (!gl_read_fbo_contents(p->gl, p->main_fb, dir, GL_RGB, GL_UNSIGNED_BYTE,
+ p->wrapped_fb->params.w, p->wrapped_fb->params.h,
+ screen->planes[0], screen->stride[0]))
+ {
+ talloc_free(screen);
+ return NULL;
+ }
return screen;
}