Help with iOS instancing

I understand there’s a way to instance by sending the modelview matrix as an attribute. I’ve got the sample code, but I don’t understand it. Does anyone know how this works? I don’t know how to send multiple meshes at once.

http://nukecode.blogspot.com/2011/07/geometry-instancig-for-iphone-wip.html

Basically it saves on the CPU by only handling the meshes on the GPU.

[QUOTE=Rakehell;1255259]I understand there’s a way to instance by sending the modelview matrix as an attribute. I’ve got the sample code, but I don’t understand it. Does anyone know how this works? I don’t know how to send multiple meshes at once.
[/QUOTE]

  1. I believe you mean sending the model/viewprojection matrices as uniforms, attributes can only take vectors and scalars.
  2. To do instancing, you buffer in a single mesh, and use separate matrices to place each instance. For example:

glUniformMatrix4fv(uniforms[UNIFORM_MODEL_MATRIX_LIST], MAX_INSTANCE_COUNT, GL_FALSE, _modelMatrixList->m);

uploads an array of model matrices to use for each instance