summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-02 20:11:20 +0100
committerwm4 <wm4@nowhere>2014-12-02 20:36:55 +0100
commitef1c7563c530bebf01493d494b960da4a06fa242 (patch)
tree47fbe4cc06912205d679ddbd6e483ff7b7769aae /video/out
parent33a6b8df46f514a450d34dd74e20f4124426fe13 (diff)
downloadmpv-ef1c7563c530bebf01493d494b960da4a06fa242.tar.bz2
mpv-ef1c7563c530bebf01493d494b960da4a06fa242.tar.xz
vo_opengl: minor changes
Always set the viewport on entry. The way the viewport is tracked is a bit complicated in my opinion, and in fact it doesn't even reduce the number of GL calls. Setting it on entry is actually redundant if video covers the screen fully, because the handle_pass() unconditionally sets it anyway, but avoiding it would complicate the cases gl->Clear() is actually needed. Add a fbo argument to gl_video_render_frame(). This allows you to render into a FBO rather than the default framebuffer. It will be useful for providing an API to render on an external GL context. (If that will actually be added.)
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_video.c16
-rw-r--r--video/out/gl_video.h2
-rw-r--r--video/out/vo_opengl.c4
3 files changed, 12 insertions, 10 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index fd4e3c5173..65cdf90d42 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1642,11 +1642,15 @@ static void handle_pass(struct gl_video *p, struct pass *chain,
};
}
-void gl_video_render_frame(struct gl_video *p)
+// (fbo==0 makes BindFramebuffer select the screen backbuffer)
+void gl_video_render_frame(struct gl_video *p, int fbo)
{
GL *gl = p->gl;
struct video_image *vimg = &p->image;
+ gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
+ gl->Viewport(p->vp_x, p->vp_y, p->vp_w, p->vp_h);
+
if (p->opts.temporal_dither)
change_dither_trafo(p);
@@ -1693,7 +1697,7 @@ void gl_video_render_frame(struct gl_video *p)
.vp_y = p->vp_y,
.vp_w = p->vp_w,
.vp_h = p->vp_h,
- .texture = 0, //makes BindFramebuffer select the screen backbuffer
+ .fbo = fbo,
};
// For Y direction, use the whole source viewport; it has been fit to the
@@ -1712,8 +1716,6 @@ void gl_video_render_frame(struct gl_video *p)
handle_pass(p, &chain, &screen, p->final_program);
gl->UseProgram(0);
- gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
- gl->Viewport(p->vp_x, p->vp_y, p->vp_w, p->vp_h);
unset_image_textures(p);
@@ -1723,6 +1725,8 @@ void gl_video_render_frame(struct gl_video *p)
draw_osd:
draw_osd(p);
+
+ gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
}
static void update_window_sized_objects(struct gl_video *p)
@@ -1798,7 +1802,6 @@ void gl_video_resize(struct gl_video *p, struct mp_rect *window,
p->vp_w = window->x1 - window->x0;
p->vp_h = window->y1 - window->y0;
- p->gl->Viewport(p->vp_x, p->vp_y, p->vp_w, p->vp_h);
check_resize(p);
}
@@ -2473,10 +2476,9 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt,
// gl_video_resize() should be called when user interaction is done.
void gl_video_resize_redraw(struct gl_video *p, int w, int h)
{
- p->gl->Viewport(p->vp_x, p->vp_y, w, h);
p->vp_w = w;
p->vp_h = h;
- gl_video_render_frame(p);
+ gl_video_render_frame(p, 0);
}
void gl_video_set_hwdec(struct gl_video *p, struct gl_hwdec *hwdec)
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index a28109a5a2..bba24e364a 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -65,7 +65,7 @@ void gl_video_config(struct gl_video *p, struct mp_image_params *params);
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d);
void gl_video_upload_image(struct gl_video *p, struct mp_image *img);
-void gl_video_render_frame(struct gl_video *p);
+void gl_video_render_frame(struct gl_video *p, int fbo);
struct mp_image *gl_video_download_image(struct gl_video *p);
void gl_video_resize(struct gl_video *p, struct mp_rect *window,
struct mp_rect *src, struct mp_rect *dst,
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index c7d274ec72..d3fdf88372 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -164,7 +164,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mpgl_lock(p->glctx);
gl_video_upload_image(p->renderer, mpi);
- gl_video_render_frame(p->renderer);
+ gl_video_render_frame(p->renderer, 0);
// The playloop calls this last before waiting some time until it decides
// to call flip_page(). Tell OpenGL to start execution of the GPU commands
@@ -402,7 +402,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
return true;
case VOCTRL_REDRAW_FRAME:
mpgl_lock(p->glctx);
- gl_video_render_frame(p->renderer);
+ gl_video_render_frame(p->renderer, 0);
mpgl_unlock(p->glctx);
return true;
case VOCTRL_SET_COMMAND_LINE: {