mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
vo_gl: Add initial stereo support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31633 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a19ea9c966
commit
ccb6675fbd
@ -3995,6 +3995,27 @@ Select the scaling function to use for chrominance scaling.
|
||||
For details see lscale.
|
||||
.IPs filter-strength=<value>
|
||||
Set the effect strength for the lscale/cscale filters that support it.
|
||||
.IPs stereo=<value>
|
||||
Select a method for stereo display.
|
||||
You may have to use -aspect to fix the aspect value.
|
||||
Experimental, do not expect too much from it.
|
||||
.RSss
|
||||
0: Normal 2D display
|
||||
.br
|
||||
1: left-right split input to full-color red-cyan stereo.
|
||||
.br
|
||||
2: left-right split input to full-color red-cyan stereo.
|
||||
.br
|
||||
3: left-right split input to quadbuffered stereo.
|
||||
Only supported by very few OpenGL cards, thus untested and not working.
|
||||
.RE
|
||||
.RE
|
||||
.sp 1
|
||||
.RS
|
||||
The following options are only useful if writing your own fragment programs.
|
||||
.RE
|
||||
.sp 1
|
||||
.RSs
|
||||
.IPs customprog=<filename>
|
||||
Load a custom fragment program from <filename>.
|
||||
See TOOLS/edgedect.fp for an example.
|
||||
|
@ -93,6 +93,7 @@ void (GLAPIENTRY *mpglLightfv)(GLenum, GLenum, const GLfloat *);
|
||||
void (GLAPIENTRY *mpglColorMaterial)(GLenum, GLenum);
|
||||
void (GLAPIENTRY *mpglShadeModel)(GLenum);
|
||||
void (GLAPIENTRY *mpglGetIntegerv)(GLenum, GLint *);
|
||||
void (GLAPIENTRY *mpglColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
|
||||
|
||||
/**
|
||||
* \defgroup glextfunctions OpenGL extension functions
|
||||
@ -437,6 +438,7 @@ static const extfunc_desc_t extfuncs[] = {
|
||||
DEF_FUNC_DESC(ColorMaterial),
|
||||
DEF_FUNC_DESC(ShadeModel),
|
||||
DEF_FUNC_DESC(GetIntegerv),
|
||||
DEF_FUNC_DESC(ColorMask),
|
||||
|
||||
// here start the real extensions
|
||||
{&mpglGenBuffers, NULL, {"glGenBuffers", "glGenBuffersARB", NULL}},
|
||||
@ -1543,6 +1545,89 @@ void glDisableYUVConversion(GLenum target, int type) {
|
||||
}
|
||||
}
|
||||
|
||||
void glEnable3DLeft(int type) {
|
||||
GLint buffer;
|
||||
switch (type) {
|
||||
case GL_3D_RED_CYAN:
|
||||
mpglColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
break;
|
||||
case GL_3D_GREEN_MAGENTA:
|
||||
mpglColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
|
||||
break;
|
||||
case GL_3D_QUADBUFFER:
|
||||
mpglGetIntegerv(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;
|
||||
}
|
||||
mpglDrawBuffer(buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glEnable3DRight(int type) {
|
||||
GLint buffer;
|
||||
switch (type) {
|
||||
case GL_3D_RED_CYAN:
|
||||
mpglColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||
break;
|
||||
case GL_3D_GREEN_MAGENTA:
|
||||
mpglColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE);
|
||||
break;
|
||||
case GL_3D_QUADBUFFER:
|
||||
mpglGetIntegerv(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;
|
||||
}
|
||||
mpglDrawBuffer(buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glDisable3D(int type) {
|
||||
GLint buffer;
|
||||
switch (type) {
|
||||
case GL_3D_RED_CYAN:
|
||||
case GL_3D_GREEN_MAGENTA:
|
||||
mpglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
break;
|
||||
case GL_3D_QUADBUFFER:
|
||||
mpglDrawBuffer(vo_doublebuffering ? GL_BACK : GL_FRONT);
|
||||
mpglGetIntegerv(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;
|
||||
}
|
||||
mpglDrawBuffer(buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief draw a texture part at given 2D coordinates
|
||||
* \param x screen top coordinate
|
||||
|
@ -365,6 +365,14 @@ void glSetupYUVConversion(gl_conversion_params_t *params);
|
||||
void glEnableYUVConversion(GLenum target, int type);
|
||||
void glDisableYUVConversion(GLenum target, int type);
|
||||
|
||||
#define GL_3D_RED_CYAN 1
|
||||
#define GL_3D_GREEN_MAGENTA 2
|
||||
#define GL_3D_QUADBUFFER 3
|
||||
|
||||
void glEnable3DLeft(int type);
|
||||
void glEnable3DRight(int type);
|
||||
void glDisable3D(int type);
|
||||
|
||||
/** \addtogroup glcontext
|
||||
* \{ */
|
||||
//! could not set new window, will continue drawing into the old one.
|
||||
@ -462,6 +470,7 @@ extern void (GLAPIENTRY *mpglLightfv)(GLenum, GLenum, const GLfloat *);
|
||||
extern void (GLAPIENTRY *mpglColorMaterial)(GLenum, GLenum);
|
||||
extern void (GLAPIENTRY *mpglShadeModel)(GLenum);
|
||||
extern void (GLAPIENTRY *mpglGetIntegerv)(GLenum, GLint *);
|
||||
extern void (GLAPIENTRY *mpglColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
|
||||
|
||||
extern void (GLAPIENTRY *mpglGenBuffers)(GLsizei, GLuint *);
|
||||
extern void (GLAPIENTRY *mpglDeleteBuffers)(GLsizei, const GLuint *);
|
||||
|
@ -174,6 +174,7 @@ static char *custom_tex;
|
||||
static int custom_tlin;
|
||||
static int custom_trect;
|
||||
static int mipmap_gen;
|
||||
static int stereo_mode;
|
||||
|
||||
static int int_pause;
|
||||
static int eq_bri = 0;
|
||||
@ -807,11 +808,27 @@ static void do_render(void) {
|
||||
mpglColor3f(1,1,1);
|
||||
if (is_yuv || custom_prog)
|
||||
glEnableYUVConversion(gl_target, yuvconvtype);
|
||||
if (stereo_mode) {
|
||||
glEnable3DLeft(stereo_mode);
|
||||
glDrawTex(0, 0, image_width, image_height,
|
||||
0, 0, image_width >> 1, image_height,
|
||||
texture_width, texture_height,
|
||||
use_rectangle == 1, is_yuv,
|
||||
mpi_flipped ^ vo_flipped);
|
||||
glEnable3DRight(stereo_mode);
|
||||
glDrawTex(0, 0, image_width, image_height,
|
||||
image_width >> 1, 0, image_width >> 1, image_height,
|
||||
texture_width, texture_height,
|
||||
use_rectangle == 1, is_yuv,
|
||||
mpi_flipped ^ vo_flipped);
|
||||
glDisable3D(stereo_mode);
|
||||
} else {
|
||||
glDrawTex(0, 0, image_width, image_height,
|
||||
0, 0, image_width, image_height,
|
||||
texture_width, texture_height,
|
||||
use_rectangle == 1, is_yuv,
|
||||
mpi_flipped ^ vo_flipped);
|
||||
}
|
||||
if (is_yuv || custom_prog)
|
||||
glDisableYUVConversion(gl_target, yuvconvtype);
|
||||
}
|
||||
@ -1117,6 +1134,7 @@ static const opt_t subopts[] = {
|
||||
{"customtrect", OPT_ARG_BOOL, &custom_trect, NULL},
|
||||
{"mipmapgen", OPT_ARG_BOOL, &mipmap_gen, NULL},
|
||||
{"osdcolor", OPT_ARG_INT, &osd_color, NULL},
|
||||
{"stereo", OPT_ARG_INT, &stereo_mode, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@ -1148,6 +1166,7 @@ static int preinit_internal(const char *arg, int allow_sw)
|
||||
custom_trect = 0;
|
||||
mipmap_gen = 0;
|
||||
osd_color = 0xffffff;
|
||||
stereo_mode = 0;
|
||||
if (subopt_parse(arg, subopts) != 0) {
|
||||
mp_msg(MSGT_VO, MSGL_FATAL,
|
||||
"\n-vo gl command line help:\n"
|
||||
@ -1221,6 +1240,11 @@ static int preinit_internal(const char *arg, int allow_sw)
|
||||
" generate mipmaps for the video image (use with TXB in customprog)\n"
|
||||
" osdcolor=<0xAARRGGBB>\n"
|
||||
" use the given color for the OSD\n"
|
||||
" stereo=<n>\n"
|
||||
" 0: normal display\n"
|
||||
" 1: side-by-side to red-cyan stereo\n"
|
||||
" 2: side-by-side to green-magenta stereo\n"
|
||||
" 3: side-by-side to quadbuffer stereo (broken?)\n"
|
||||
"\n" );
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user