Claire
Claire

Reputation: 97

openGL not drawing mesh when I pass parameters to a function to draw

so I'm an openGL beginner and am attempting to draw 'Bones' recursively.

I can draw my mesh fine within my 'do' loop however when I try to pass the 'Bone' object to a function to draw the mesh it doesn't draw?

void drawBone(Bone &bone, mat4 ProjectionMatrix, mat4 ViewMatrix)
{
    ModelMatrix = bone.getBoneModel();
    MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;

    glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
    glDrawArrays(GL_TRIANGLES, 0, vertices.size());
}

If I paste those 4 lines back into my 'do' loop in place of 'drawBone()' the mesh draws just fine.

Any help would be appreciated! :)

Upvotes: 2

Views: 153

Answers (1)

cianmce
cianmce

Reputation: 494

You have a few global variables like MatrixID and vertices. make sure these are globally accessible and you are not redeclaring them within your "do" loop

Upvotes: 2

Related Questions