1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-30 15:29:56 +00:00

vo_opengl: fix dangling pointers when VAOs are not available

This is for legacy GL: if VAOs are not available, the helper has to
specify vertex attributes again on every rendering. gl_vao_init() keeps
the vertex array for this purpose. Unfortunately, a temporary argument
was passed to the function, instead of the permanent copy.

Also, it didn't use num_entries (instead expected the array being
terminated by a {0} entry). Fix that source code indentation too.
This commit is contained in:
wm4 2017-08-15 18:45:22 +02:00
parent 72a8120daa
commit b44e81d9c3
2 changed files with 4 additions and 4 deletions

View File

@ -139,7 +139,7 @@ static void gl_vao_enable_attribs(struct gl_vao *vao)
GLenum type = 0;
bool normalized = false;
switch (e->type) {
case RA_VARTYPE_INT:
case RA_VARTYPE_INT:
type = GL_INT;
break;
case RA_VARTYPE_FLOAT:
@ -221,7 +221,7 @@ static void gl_vao_unbind(struct gl_vao *vao)
if (gl->BindVertexArray) {
gl->BindVertexArray(0);
} else {
for (int n = 0; vao->entries[n].name; n++)
for (int n = 0; n < vao->num_entries; n++)
gl->DisableVertexAttribArray(n);
}
}

View File

@ -810,8 +810,8 @@ static struct ra_renderpass *gl_renderpass_create(struct ra *ra,
}
gl->UseProgram(0);
gl_vao_init(&pass_gl->vao, gl, params->vertex_stride, params->vertex_attribs,
params->num_vertex_attribs);
gl_vao_init(&pass_gl->vao, gl, pass->params.vertex_stride,
pass->params.vertex_attribs, pass->params.num_vertex_attribs);
return pass;
}