mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
759656d0ba
commit
a71601231e
|
@ -2253,8 +2253,6 @@ static int init_gl(struct gl_video *p)
|
||||||
gl->BindVertexArray(p->vao);
|
gl->BindVertexArray(p->vao);
|
||||||
setup_vertex_array(gl);
|
setup_vertex_array(gl);
|
||||||
gl->BindVertexArray(0);
|
gl->BindVertexArray(0);
|
||||||
} else {
|
|
||||||
setup_vertex_array(gl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gl->BindBuffer(GL_ARRAY_BUFFER, 0);
|
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_PACK_ALIGNMENT, 4);
|
||||||
gl->PixelStorei(GL_UNPACK_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)
|
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)
|
// dest = src.<w> (always using 4 components)
|
||||||
|
|
Loading…
Reference in New Issue