aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-06-18 15:16:29 +0200
committerGravatar wm4 <wm4@nowhere>2016-06-18 15:16:29 +0200
commit4a15bc6d737a34d232675ee6078813a84efe4d9c (patch)
tree79900e4fd903e3c9b1dc4b27918c2a724d4589d6
parent9215a9e59889c7a2f600c618501ace1360bf810d (diff)
vo_opengl: add ability to render to an arbitrary backing framebuffer
Most of the functionality already exists for the sake of vo_opengl_cb. We only have to use it. This will be used by dxinterop in the following commit.
-rw-r--r--video/out/opengl/common.h1
-rw-r--r--video/out/opengl/video.c7
-rw-r--r--video/out/vo_opengl.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index 7427befe99..71129ac320 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -91,6 +91,7 @@ struct GL {
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
+ GLuint main_fb; // framebuffer to render to (normally 0)
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 0bbc979476..6282d296cc 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -3342,7 +3342,12 @@ static void init_gl(struct gl_video *p)
}
if ((gl->es >= 300 || gl->version) && (gl->mpgl_caps & MPGL_CAP_FB)) {
+ gl->BindFramebuffer(GL_FRAMEBUFFER, gl->main_fb);
+
GLenum obj = gl->version ? GL_BACK_LEFT : GL_BACK;
+ if (gl->main_fb)
+ obj = GL_COLOR_ATTACHMENT0;
+
GLint depth_r = -1, depth_g = -1, depth_b = -1;
gl->GetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, obj,
@@ -3356,6 +3361,8 @@ static void init_gl(struct gl_video *p)
depth_r, depth_g, depth_b);
p->fb_depth = depth_g > 0 ? depth_g : 8;
+
+ gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
}
p->upload_timer = gl_timer_create(p->gl);
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 426236e436..08b9b11fe0 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -130,7 +130,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
p->vsync_fences[p->num_vsync_fences++] = fence;
}
- gl_video_render_frame(p->renderer, frame, 0);
+ gl_video_render_frame(p->renderer, frame, gl->main_fb);
if (p->use_glFinish)
gl->Finish();