Skip to content

Commit c4b11a3

Browse files
authored
Fix DrawMeshInstanced breaking if instanceTransform is unused (#5469)
1 parent a44157c commit c4b11a3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/rmodels.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,11 +1762,14 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
17621762
instancesVboId = rlLoadVertexBuffer(instanceTransforms, instances*sizeof(float16), false);
17631763

17641764
// Instances transformation matrices are sent to shader attribute location: SHADER_LOC_VERTEX_INSTANCE_TX
1765-
for (unsigned int i = 0; i < 4; i++)
1765+
if (material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] != -1)
17661766
{
1767-
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i);
1768-
rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4));
1769-
rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 1);
1767+
for (unsigned int i = 0; i < 4; i++)
1768+
{
1769+
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i);
1770+
rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4));
1771+
rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 1);
1772+
}
17701773
}
17711774

17721775
rlDisableVertexBuffer();

0 commit comments

Comments
 (0)