From a71601231e43b588981081390225565b6a289177 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 23 Dec 2014 14:27:47 +0100 Subject: 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. --- video/out/gl_video.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'video/out') 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. (always using 4 components) -- cgit v1.2.3