overgroove's picture

Multiple "objects" in one VBO.

I'm working on a project that has some flocking particles. I'm coding it up using openTK and working with VAO's and VBO's. I've taken most of the code from the openGL3 example.

In advance, I'll start by asking your forgiveness for my lack of openGL knowledge. I'm sure the answers to some of my questions will be RTFM. If so, please point me to the appropriate page in the FM :).

Ok. I have x (x is smallish ~ 200) number of particles that have slightly different geometry. I've created a large VBO that contains the vertices for the 200ish particles and an IBO that contains the indices used in order to create my geometry. Now, the individual particles are all centered around the origin. What I want to do and haven't been able to do is , for each particle, change my modelviewmatrix uniform (to translate the particle) and then draw it.

I thought that perhaps messing with the pointer elements of DrawElements and DrawRangeElements might help me with this (my particles have 12 triangles, so 36 indices):

//foreach particle
                IntPtr ip = new IntPtr(36 * i);
                GL.DrawRangeElements(BeginMode.Triangles, (i * 36), ((i + 1) * 36) - 1, 36, 
                DrawElementsType.UnsignedInt, ip);

This didn't work. Just drew the same geometry 200 times. I'm guessing because the offset at the end is just ignored since the VAO is in context. Do I have to create 200 individual VAO's for this? How should I proceed?

Thanks in advance for your help.

Donny