Skip to content

Commit

Permalink
Unbind existing meshes before binding new (#1299)
Browse files Browse the repository at this point in the history
Minor improvement to GlslProgram to unbind existing meshes before binding new meshes.
  • Loading branch information
ashwinbhat authored Mar 22, 2023
1 parent 9f2f220 commit 2626933
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/MaterialXRenderGlsl/GlslMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void GlslMaterial::bindMesh(MeshPtr mesh)
return;
}

if (_boundMesh && mesh->getName() != _boundMesh->getName())
if (mesh != _boundMesh)
{
_glProgram->unbindGeometry();
}
Expand Down
6 changes: 6 additions & 0 deletions source/MaterialXRenderGlsl/GlslProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ void GlslProgram::bindMesh(MeshPtr mesh)
throw ExceptionRenderError("No mesh to bind");
}

if (mesh != _boundMesh)
{
unbindGeometry();
}
_boundMesh = mesh;

GlslProgram::InputMap foundList;
const GlslProgram::InputMap& attributeList = getAttributesList();

Expand Down
3 changes: 3 additions & 0 deletions source/MaterialXRenderGlsl/GlslProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ class MX_RENDERGLSL_API GlslProgram
// Attribute vertex array handle
unsigned int _vertexArray;

// Currently bound mesh
MeshPtr _boundMesh;

// Program texture map
std::unordered_map<string, unsigned int> _programTextures;

Expand Down

0 comments on commit 2626933

Please sign in to comment.