summaryrefslogtreecommitdiffstats
path: root/video/out/vo_opengl_cb.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-05 15:17:18 +0200
committerwm4 <wm4@nowhere>2017-08-05 16:27:09 +0200
commitdddda6e4a5353f1e5518bca175b523f1231fa700 (patch)
tree7b3181c5b8a3497b96ae0bc4d5f5184ee810c0ae /video/out/vo_opengl_cb.c
parent333cae74ef0fa62e0355e85d21f0f41ced3963e7 (diff)
downloadmpv-dddda6e4a5353f1e5518bca175b523f1231fa700.tar.bz2
mpv-dddda6e4a5353f1e5518bca175b523f1231fa700.tar.xz
vo_opengl: move GL state resetting to vo_opengl_cb
This code is pretty much for the sake of vo_opengl_cb API users. It resets certain state that either the user or our code doesn't reset correctly. This is somewhat outdated. With GL implicit state being so awfully large, it seems more reasonable require that any code restores the default state when returning to the caller. Some exceptions are defined in opengl_cb.h.
Diffstat (limited to 'video/out/vo_opengl_cb.c')
-rw-r--r--video/out/vo_opengl_cb.c16
1 files changed, 13 insertions, 3 deletions
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);