Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to animate multiple(3) entities using one model(IQM format).

It's working but performance is really bad because I'm calling animate function for each entity in my game loop (I think problem is there).

What's the best way to animate multiple entities (with different animation ofc) in OpenGL? I think I can try build one VBO / entity for better performances but I don't think it's the best way to do it.

share|improve this question
up vote 1 down vote accepted

You can do skinning using shaders in OpenGL. The IQM format is designed with this in mind. Upload the skinning matrices to a uniform and use the blend index and blend weight vertex arrays in the shader to do the skinning.

That way you only have to update the array of skinning matrices per entity you want to animate.

uniform mat4 SkinMatrix[256];
in vec4 att_BlendIndex;
in vec4 att_BlendWeight;

main() {
    vec4 p = vec4(0);
    p += SkinMatrix[int(att_BlendIndex.x)] * gl_Vertex * att_BlendWeight.x;
    p += SkinMatrix[int(att_BlendIndex.y)] * gl_Vertex * att_BlendWeight.y;
    p += SkinMatrix[int(att_BlendIndex.z)] * gl_Vertex * att_BlendWeight.z;
    p += SkinMatrix[int(att_BlendIndex.w)] * gl_Vertex * att_BlendWeight.w;
    gl_Position = gl_ModelViewProjectionMatrix * p;
share|improve this answer
Thanks, im gonna do that. – Robert Dec 10 '12 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.