summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmpv/opengl_cb.h3
-rw-r--r--video/out/opengl/video.c18
-rw-r--r--video/out/opengl/video.h2
-rw-r--r--video/out/vo_opengl_cb.c16
4 files changed, 16 insertions, 23 deletions
diff --git a/libmpv/opengl_cb.h b/libmpv/opengl_cb.h
index fb8b928889..7d3a64e604 100644
--- a/libmpv/opengl_cb.h
+++ b/libmpv/opengl_cb.h
@@ -69,6 +69,9 @@ extern "C" {
* standard defaults. The following state is excluded from this:
*
* - the current viewport (can have/is set to an arbitrary value)
+ * - the glScissor state (but GL_SCISSOR_TEST is expected disabled)
+ * - glBlendFuncSeparate() state (but GL_BLEND is expected disabled)
+ * - mpv always disables GL_DITHER at init
*
* Messing with the state could be avoided by creating shared OpenGL contexts,
* but this is avoided for the sake of compatibility and interoperability.
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 1fbea4fa8c..e8dd57bc2f 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -3492,8 +3492,6 @@ static void init_gl(struct gl_video *p)
debug_check_gl(p, "before init_gl");
- gl_video_set_gl_state(p);
-
p->upload_timer = gl_timer_create(gl);
p->blit_timer = gl_timer_create(gl);
@@ -3540,22 +3538,6 @@ void gl_video_uninit(struct gl_video *p)
talloc_free(p);
}
-void gl_video_set_gl_state(struct gl_video *p)
-{
- // This resets certain important state to defaults.
- gl_video_unset_gl_state(p);
-}
-
-void gl_video_unset_gl_state(struct gl_video *p)
-{
- GL *gl = p->gl;
-
- gl->ActiveTexture(GL_TEXTURE0);
- if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH)
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
-}
-
void gl_video_reset(struct gl_video *p)
{
gl_video_reset_surfaces(p);
diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h
index ea9f7b0746..8b6ca6e98f 100644
--- a/video/out/opengl/video.h
+++ b/video/out/opengl/video.h
@@ -176,8 +176,6 @@ bool gl_video_icc_auto_enabled(struct gl_video *p);
bool gl_video_gamma_auto_enabled(struct gl_video *p);
struct mp_colorspace gl_video_get_output_colorspace(struct gl_video *p);
-void gl_video_set_gl_state(struct gl_video *p);
-void gl_video_unset_gl_state(struct gl_video *p);
void gl_video_reset(struct gl_video *p);
bool gl_video_showing_interpolated_frame(struct gl_video *p);
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 3dd8a03101..171b96406b 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -144,6 +144,16 @@ void mpv_opengl_cb_set_update_callback(struct mpv_opengl_cb_context *ctx,
pthread_mutex_unlock(&ctx->lock);
}
+// Reset some GL attributes the user might clobber. For mid-term compatibility
+// only - we expect both user code and our code to do this correctly.
+static void reset_gl_state(GL *gl)
+{
+ gl->ActiveTexture(GL_TEXTURE0);
+ if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH)
+ gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
+}
+
int mpv_opengl_cb_init_gl(struct mpv_opengl_cb_context *ctx, const char *exts,
mpv_opengl_cb_get_proc_address_fn get_proc_address,
void *get_proc_address_ctx)
@@ -184,7 +194,7 @@ int mpv_opengl_cb_init_gl(struct mpv_opengl_cb_context *ctx, const char *exts,
ctx->initialized = true;
pthread_mutex_unlock(&ctx->lock);
- gl_video_unset_gl_state(ctx->renderer);
+ reset_gl_state(ctx->gl);
return 0;
}
@@ -222,7 +232,7 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
{
assert(ctx->renderer);
- gl_video_set_gl_state(ctx->renderer);
+ reset_gl_state(ctx->gl);
pthread_mutex_lock(&ctx->lock);
@@ -307,7 +317,7 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
MP_STATS(ctx, "glcb-render");
gl_video_render_frame(ctx->renderer, frame, fbo);
- gl_video_unset_gl_state(ctx->renderer);
+ reset_gl_state(ctx->gl);
if (frame != &dummy)
talloc_free(frame);