From 1c2cbeabc270874c8f14e16c8f7a09c1f0a382d9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 15 Dec 2014 04:40:26 +0100 Subject: [PATCH] vo_opengl: remove quadbuffer/anaglyph stereo 3D rendering Obscure feature, and I've never heard of anyone using it. The anaglyph effects can be reproduced with vf_stereo3d. The only thing that can't be reproduced with it is "quadbuffer", which requires special and expensive hardware. --- DOCS/man/vo.rst | 15 ------- video/out/gl_common.c | 86 ------------------------------------ video/out/gl_common.h | 8 ---- video/out/gl_video.c | 42 +++--------------- video/out/gl_video.h | 1 - video/out/vo_opengl.c | 3 -- video/out/vo_opengl_old.c | 91 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 96 insertions(+), 150 deletions(-) diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst index 05d2acf39e..f133c04d76 100644 --- a/DOCS/man/vo.rst +++ b/DOCS/man/vo.rst @@ -362,21 +362,6 @@ Available video output drivers are: processing chain might do chroma scaling differently if ``lscale`` is disabled. - ``stereo=`` - Select a method for stereo display. You may have to use - ``--video-aspect`` to fix the aspect value. Experimental, do not expect - too much from it. - - no - Normal 2D display - red-cyan - Convert side by side input to full-color red-cyan stereo. - green-magenta - Convert side by side input to full-color green-magenta stereo. - quadbuffer - Convert side by side input to quad buffered stereo. Only supported - by very few OpenGL cards. - ``srgb`` Convert and color correct the output to sRGB before displaying it on the screen. This option enables linear light scaling. It also forces diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 6cc2d20a17..d9df1aa7ee 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -773,92 +773,6 @@ void glDownloadTex(GL *gl, GLenum target, GLenum format, GLenum type, gl->GetTexImage(target, 0, format, type, dataptr); } -void glEnable3DLeft(GL *gl, int type) -{ - GLint buffer; - switch (type) { - case GL_3D_RED_CYAN: - gl->ColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); - break; - case GL_3D_GREEN_MAGENTA: - gl->ColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); - break; - case GL_3D_QUADBUFFER: - gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); - switch (buffer) { - case GL_FRONT: - case GL_FRONT_LEFT: - case GL_FRONT_RIGHT: - buffer = GL_FRONT_LEFT; - break; - case GL_BACK: - case GL_BACK_LEFT: - case GL_BACK_RIGHT: - buffer = GL_BACK_LEFT; - break; - } - gl->DrawBuffer(buffer); - break; - } -} - -void glEnable3DRight(GL *gl, int type) -{ - GLint buffer; - switch (type) { - case GL_3D_RED_CYAN: - gl->ColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE); - break; - case GL_3D_GREEN_MAGENTA: - gl->ColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE); - break; - case GL_3D_QUADBUFFER: - gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); - switch (buffer) { - case GL_FRONT: - case GL_FRONT_LEFT: - case GL_FRONT_RIGHT: - buffer = GL_FRONT_RIGHT; - break; - case GL_BACK: - case GL_BACK_LEFT: - case GL_BACK_RIGHT: - buffer = GL_BACK_RIGHT; - break; - } - gl->DrawBuffer(buffer); - break; - } -} - -void glDisable3D(GL *gl, int type) -{ - GLint buffer; - switch (type) { - case GL_3D_RED_CYAN: - case GL_3D_GREEN_MAGENTA: - gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - break; - case GL_3D_QUADBUFFER: - gl->DrawBuffer(GL_BACK); - gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); - switch (buffer) { - case GL_FRONT: - case GL_FRONT_LEFT: - case GL_FRONT_RIGHT: - buffer = GL_FRONT; - break; - case GL_BACK: - case GL_BACK_LEFT: - case GL_BACK_RIGHT: - buffer = GL_BACK; - break; - } - gl->DrawBuffer(buffer); - break; - } -} - mp_image_t *glGetWindowScreenshot(GL *gl) { GLint vp[4]; //x, y, w, h diff --git a/video/out/gl_common.h b/video/out/gl_common.h index 951d2efefb..3f86d74036 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -67,14 +67,6 @@ void glDownloadTex(GL *gl, GLenum target, GLenum format, GLenum type, void glCheckError(GL *gl, struct mp_log *log, const char *info); mp_image_t *glGetWindowScreenshot(GL *gl); -#define GL_3D_RED_CYAN 1 -#define GL_3D_GREEN_MAGENTA 2 -#define GL_3D_QUADBUFFER 3 - -void glEnable3DLeft(GL *gl, int type); -void glEnable3DRight(GL *gl, int type); -void glDisable3D(GL *gl, int type); - enum { MPGL_CAP_GL = (1 << 0), // GL was successfully loaded MPGL_CAP_GL_LEGACY = (1 << 1), // GL 1.1 (but not 3.x) diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 2b99200f4f..89572c9011 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -315,11 +315,6 @@ const struct m_sub_options gl_video_conf = { OPT_FLAG("approx-gamma", approx_gamma, 0), OPT_FLAG("npot", npot, 0), OPT_FLAG("pbo", pbo, 0), - OPT_CHOICE("stereo", stereo_mode, 0, - ({"no", 0}, - {"red-cyan", GL_3D_RED_CYAN}, - {"green-magenta", GL_3D_GREEN_MAGENTA}, - {"quadbuffer", GL_3D_QUADBUFFER})), OPT_STRING_VALIDATE("lscale", scalers[0], 0, validate_scaler_opt), OPT_STRING_VALIDATE("cscale", scalers[1], 0, validate_scaler_opt), OPT_STRING_VALIDATE("lscale-down", dscalers[0], 0, validate_scaler_opt), @@ -1574,7 +1569,6 @@ struct pass { bool use_dst; struct mp_rect dst; int flags; // for write_quad - bool render_stereo; }; // *chain contains the source, and is overwritten with a copy of the result @@ -1613,36 +1607,11 @@ static void handle_pass(struct gl_video *p, struct pass *chain, fbo->vp_x, fbo->vp_y, fbo->vp_w, fbo->vp_h, fbo->tex_w, fbo->tex_h, chain->flags); - if (chain->render_stereo && p->opts.stereo_mode) { - int w = src.x1 - src.x0; - int imgw = p->image_w; - - glEnable3DLeft(gl, p->opts.stereo_mode); - - write_quad(vb, - dst.x0, dst.y0, dst.x1, dst.y1, - src.x0 / 2, src.y0, - src.x0 / 2 + w / 2, src.y1, - tex_w, tex_h, NULL, p->gl_target, chain->flags); - draw_triangles(p, vb, VERTICES_PER_QUAD); - - glEnable3DRight(gl, p->opts.stereo_mode); - - write_quad(vb, - dst.x0, dst.y0, dst.x1, dst.y1, - src.x0 / 2 + imgw / 2, src.y0, - src.x0 / 2 + imgw / 2 + w / 2, src.y1, - tex_w, tex_h, NULL, p->gl_target, chain->flags); - draw_triangles(p, vb, VERTICES_PER_QUAD); - - glDisable3D(gl, p->opts.stereo_mode); - } else { - write_quad(vb, - dst.x0, dst.y0, dst.x1, dst.y1, - src.x0, src.y0, src.x1, src.y1, - tex_w, tex_h, NULL, p->gl_target, chain->flags); - draw_triangles(p, vb, VERTICES_PER_QUAD); - } + write_quad(vb, + dst.x0, dst.y0, dst.x1, dst.y1, + src.x0, src.y0, src.x1, src.y1, + tex_w, tex_h, NULL, p->gl_target, chain->flags); + draw_triangles(p, vb, VERTICES_PER_QUAD); *chain = (struct pass){ .num = chain->num + 1, @@ -1719,7 +1688,6 @@ void gl_video_render_frame(struct gl_video *p, int fbo) chain.dst = p->dst_rect; chain.flags = (p->image_params.rotate % 90 ? 0 : p->image_params.rotate / 90) | (vimg->image_flipped ? 4 : 0); - chain.render_stereo = true; handle_pass(p, &chain, &screen, p->final_program); diff --git a/video/out/gl_video.h b/video/out/gl_video.h index 52f4b0c16b..c11fb51cab 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -47,7 +47,6 @@ struct gl_video_opts { int dither_size; int temporal_dither; int fbo_format; - int stereo_mode; int alpha_mode; int chroma_location; int use_rectangle; diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 567f83be97..0728223415 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -404,9 +404,6 @@ static int preinit(struct vo *vo) int vo_flags = 0; - if (p->renderer_opts->stereo_mode == GL_3D_QUADBUFFER) - vo_flags |= VOFLAG_STEREO; - if (p->renderer_opts->alpha_mode == 1) vo_flags |= VOFLAG_ALPHA; diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index fb0831202e..a3a8b69c0a 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -200,6 +200,97 @@ static void glSetupYUVConversion(struct vo *vo, GL *gl, static void glEnableYUVConversion(GL *gl, GLenum target, int type); static void glDisableYUVConversion(GL *gl, GLenum target, int type); + +#define GL_3D_RED_CYAN 1 +#define GL_3D_GREEN_MAGENTA 2 +#define GL_3D_QUADBUFFER 3 + +static void glEnable3DLeft(GL *gl, int type) +{ + GLint buffer; + switch (type) { + case GL_3D_RED_CYAN: + gl->ColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); + break; + case GL_3D_GREEN_MAGENTA: + gl->ColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); + break; + case GL_3D_QUADBUFFER: + gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); + switch (buffer) { + case GL_FRONT: + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + buffer = GL_FRONT_LEFT; + break; + case GL_BACK: + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + buffer = GL_BACK_LEFT; + break; + } + gl->DrawBuffer(buffer); + break; + } +} + +static void glEnable3DRight(GL *gl, int type) +{ + GLint buffer; + switch (type) { + case GL_3D_RED_CYAN: + gl->ColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE); + break; + case GL_3D_GREEN_MAGENTA: + gl->ColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE); + break; + case GL_3D_QUADBUFFER: + gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); + switch (buffer) { + case GL_FRONT: + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + buffer = GL_FRONT_RIGHT; + break; + case GL_BACK: + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + buffer = GL_BACK_RIGHT; + break; + } + gl->DrawBuffer(buffer); + break; + } +} + +static void glDisable3D(GL *gl, int type) +{ + GLint buffer; + switch (type) { + case GL_3D_RED_CYAN: + case GL_3D_GREEN_MAGENTA: + gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + break; + case GL_3D_QUADBUFFER: + gl->DrawBuffer(GL_BACK); + gl->GetIntegerv(GL_DRAW_BUFFER, &buffer); + switch (buffer) { + case GL_FRONT: + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + buffer = GL_FRONT; + break; + case GL_BACK: + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + buffer = GL_BACK; + break; + } + gl->DrawBuffer(buffer); + break; + } +} + //! always return this format as internal texture format in glFindFormat #define TEXTUREFORMAT_ALWAYS GL_RGB8 #undef TEXTUREFORMAT_ALWAYS