Ensure Mesh attachments are unmapped before drawing;

This commit is contained in:
bjorn 2018-06-12 02:05:19 -07:00
parent f4b9552052
commit d71eccfd0b
2 changed files with 9 additions and 4 deletions

View File

@ -1104,10 +1104,6 @@ void lovrGraphicsDraw(Mesh* mesh, mat4 transform, DefaultShader defaultShader, i
lovrGraphicsUseProgram(shader->program);
lovrShaderBind(shader);
lovrGraphicsBindVertexArray(mesh->vao);
lovrMeshUnmapVertices(mesh);
lovrMeshUnmapIndices(mesh);
lovrMeshBind(mesh, shader);
size_t start = mesh->rangeStart;

View File

@ -77,12 +77,21 @@ void lovrMeshBind(Mesh* mesh, Shader* shader) {
MeshAttachment layout[MAX_ATTACHMENTS];
memset(layout, 0, MAX_ATTACHMENTS * sizeof(MeshAttachment));
lovrGraphicsBindVertexArray(mesh->vao);
lovrMeshUnmapVertices(mesh);
lovrMeshUnmapIndices(mesh);
if (mesh->indexCount > 0) {
lovrGraphicsBindIndexBuffer(mesh->ibo);
}
while ((key = map_next(&mesh->attachments, &iter)) != NULL) {
int location = lovrShaderGetAttributeId(shader, key);
if (location >= 0) {
MeshAttachment* attachment = map_get(&mesh->attachments, key);
layout[location] = *attachment;
lovrMeshUnmapVertices(attachment->mesh);
lovrMeshUnmapIndices(attachment->mesh);
}
}