diff options
author | wm4 <wm4@nowhere> | 2014-12-02 20:11:20 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-02 20:36:55 +0100 |
commit | ef1c7563c530bebf01493d494b960da4a06fa242 (patch) | |
tree | 47fbe4cc06912205d679ddbd6e483ff7b7769aae /video/out/gl_video.c | |
parent | 33a6b8df46f514a450d34dd74e20f4124426fe13 (diff) | |
download | mpv-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/gl_video.c')
-rw-r--r-- | video/out/gl_video.c | 16 |
1 files changed, 9 insertions, 7 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) |