summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-09 21:34:01 +0100
committerwm4 <wm4@nowhere>2014-12-09 21:55:27 +0100
commit0125fb671478708b4e2a11931756f79e35d77e06 (patch)
tree5cd874508635afd9079f13031a0d4b26bc05d674
parentef709d19d4ece978c13908ca2cafdf194585b426 (diff)
downloadmpv-0125fb671478708b4e2a11931756f79e35d77e06.tar.bz2
mpv-0125fb671478708b4e2a11931756f79e35d77e06.tar.xz
vo_opengl: make background color configurable
This mainly affects the black bars that are drawn if the window and video aspect ratios mismatch.
-rw-r--r--DOCS/man/vo.rst4
-rw-r--r--video/out/gl_video.c11
-rw-r--r--video/out/gl_video.h3
3 files changed, 15 insertions, 3 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index 09cafaac7b..174b10105b 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -604,6 +604,10 @@ Available video output drivers are:
have any advantages over normal textures. Note that hardware decoding
overrides this flag.
+ ``background=<color>``
+ Color used to draw parts of the mpv window not covered by video.
+ See ``--osd-color`` option how colors are defined.
+
``opengl-hq``
Same as ``opengl``, but with default settings for high quality rendering.
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9a762118c3..8ea895d22e 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -276,7 +276,7 @@ static const char *const osd_shaders[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = "frag_osd_rgba",
};
-static const struct gl_video_opts gl_video_opts_def = {
+const struct gl_video_opts gl_video_opts_def = {
.npot = 1,
.dither_depth = -1,
.dither_size = 6,
@@ -286,6 +286,7 @@ static const struct gl_video_opts gl_video_opts_def = {
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
.scaler_radius = {NAN, NAN},
.alpha_mode = 2,
+ .background = {0, 0, 0, 255},
};
const struct gl_video_opts gl_video_opts_hq_def = {
@@ -299,6 +300,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
.scaler_radius = {NAN, NAN},
.alpha_mode = 2,
+ .background = {0, 0, 0, 255},
};
static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt,
@@ -360,6 +362,7 @@ const struct m_sub_options gl_video_conf = {
{"yes", 1}, {"", 1},
{"blend", 2})),
OPT_FLAG("rectangle-textures", use_rectangle, 0),
+ OPT_COLOR("background", background, 0),
{0}
},
.size = sizeof(struct gl_video_opts),
@@ -2063,7 +2066,7 @@ static bool test_fbo(struct gl_video *p, GLenum format)
}
fbotex_uninit(p, &fbo);
glCheckError(gl, p->log, "FBO test");
- gl->ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ gl_video_set_gl_state(p);
return success;
}
@@ -2223,7 +2226,8 @@ void gl_video_set_gl_state(struct gl_video *p)
{
GL *gl = p->gl;
- gl->ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ struct m_color c = p->opts.background;
+ gl->ClearColor(c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0);
gl->ActiveTexture(GL_TEXTURE0);
}
@@ -2454,6 +2458,7 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts)
p->opts.gamma = 1.0f;
check_gl_features(p);
+ gl_video_set_gl_state(p);
reinit_rendering(p);
}
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 3d733c8a80..52f4b0c16b 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -19,6 +19,7 @@
#include <stdbool.h>
+#include "options/m_option.h"
#include "sub/osd.h"
#include "gl_common.h"
@@ -50,10 +51,12 @@ struct gl_video_opts {
int alpha_mode;
int chroma_location;
int use_rectangle;
+ struct m_color background;
};
extern const struct m_sub_options gl_video_conf;
extern const struct gl_video_opts gl_video_opts_hq_def;
+extern const struct gl_video_opts gl_video_opts_def;
struct gl_video;