diff options
author | wm4 <wm4@nowhere> | 2017-03-20 13:31:28 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-03-20 13:31:28 +0100 |
commit | 8fb9cc253457a58c39013906643e8dc92171adbe (patch) | |
tree | cd78041d0ea61c580c628d15eb90d5ae2433b8b8 /video/out/opengl/utils.c | |
parent | 03fe50651baeb506ca8b6fb2b597598a096be2f6 (diff) | |
download | mpv-8fb9cc253457a58c39013906643e8dc92171adbe.tar.bz2 mpv-8fb9cc253457a58c39013906643e8dc92171adbe.tar.xz |
vo_opengl: read framebuffer depth from actual FBO used for rendering
In some cases, such as when using the libmpv opengl-cb API, or with
certain vo_opengl backends, the main framebuffer is never accessed.
Instead, rendering is done to a FBO that acts as back buffer. This meant
an incorrect/broken bit depth could be used for dithering.
Change it to read the framebuffer depth lazily on the first render call.
Also move the main FBO field out of the GL struct to MPGLContext,
because the renderer's init function does not need to access it anymore.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r-- | video/out/opengl/utils.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 420df369f0..2ec8f43898 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -100,15 +100,15 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4); } -mp_image_t *gl_read_window_contents(GL *gl, int w, int h) +mp_image_t *gl_read_fbo_contents(GL *gl, int fbo, int w, int h) { if (gl->es) return NULL; // ES can't read from front buffer mp_image_t *image = mp_image_alloc(IMGFMT_RGB24, w, h); if (!image) return NULL; - gl->BindFramebuffer(GL_FRAMEBUFFER, gl->main_fb); - GLenum obj = gl->main_fb ? GL_COLOR_ATTACHMENT0 : GL_FRONT; + gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); + GLenum obj = fbo ? GL_COLOR_ATTACHMENT0 : GL_FRONT; gl->PixelStorei(GL_PACK_ALIGNMENT, 1); gl->ReadBuffer(obj); //flip image while reading (and also avoid stride-related trouble) |