diff options
author | wm4 <wm4@nowhere> | 2014-12-23 14:27:47 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-23 14:27:47 +0100 |
commit | a71601231e43b588981081390225565b6a289177 (patch) | |
tree | 5261a6220914963265dd0a1511ca1d6112a6ce4f /video/out | |
parent | 759656d0babe4ee49a5929b8f2d3a735d51d29f9 (diff) | |
download | mpv-a71601231e43b588981081390225565b6a289177.tar.bz2 mpv-a71601231e43b588981081390225565b6a289177.tar.xz |
vo_opengl_cb: always setup/break vertex array bindings
Originally, this code was written to have full control over the OpenGL
state, rather than having to cooperate with unknown components by being
embeded like vo_opengl_cb is meant to be. As a consequence, it was
thought to be ok to setup a global binding (if the context is below
OpenGL 3.0, which guarantees VAOs).
This could break badly. Fix it by setting up and breaking the bindings
on entry/exit.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_video.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 320924c927..87d7eefda5 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -2253,8 +2253,6 @@ static int init_gl(struct gl_video *p) gl->BindVertexArray(p->vao); setup_vertex_array(gl); gl->BindVertexArray(0); - } else { - setup_vertex_array(gl); } gl->BindBuffer(GL_ARRAY_BUFFER, 0); @@ -2301,11 +2299,23 @@ void gl_video_set_gl_state(struct gl_video *p) } gl->PixelStorei(GL_PACK_ALIGNMENT, 4); gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4); + + if (!gl->BindVertexArray) { + gl->BindBuffer(GL_ARRAY_BUFFER, p->vertex_buffer); + setup_vertex_array(gl); + gl->BindBuffer(GL_ARRAY_BUFFER, 0); + } } void gl_video_unset_gl_state(struct gl_video *p) { - // nop + GL *gl = p->gl; + + if (!gl->BindVertexArray) { + gl->DisableVertexAttribArray(VERTEX_ATTRIB_POSITION); + gl->DisableVertexAttribArray(VERTEX_ATTRIB_COLOR); + gl->DisableVertexAttribArray(VERTEX_ATTRIB_TEXCOORD); + } } // dest = src.<w> (always using 4 components) |