Base vertex and VertexAttribBinding

Hi everyone,

I have a struct Vertex{glm::vec4 t,n,v;}. I have written a obj loader that takes two parameters, obj file path as string and reference to a vector of 'Vertex’es. This function populates my vector and returns the number of indices(In my case indices are just sequential numbers, anyway).

As I have 6 objects to render, after using that function 6 times I have the following

vector<Vertex> objects[6];

filled. SIZES are number of 'Vertex’es(object[i].size()) and SIZES_I are number of indices. The offsets are calculated as below

for(int i=0;i<6;i++)

I transferred vectors of Vertex into a single VBO all back to back. Similarly for indices, transferred into buffer bound to element array buffer. That part is shown below.

for(int i=0;i<6;i++)

Now comes my problem. Of the two rendering codes shown below the first one doesn’t work but the second works perfectly.

for(int i=0;i<6;i++)


for(int i=0;i<6;i++)

The second code is more elegant (may be, you guys have much more elegant solution?), but I am concerned as to why my first code is not working. May be I dint understand bindings. They are so useful that eventually I may have to work with them. It’s drawing partially finished models and some models not at all. To summarily say what I have done so u guys can understand whats going on here, in the first case i created 6 buffer bindings on the same buffer with 6 offsets. In the second case there is only one binding, but I used base vertex to offset 6 times. Btw both are compiling, so ignore any typos as I typed all this in my tab.

Are you using any attributes other than zero? If you are, you need to set the binding for each one. If you’re using glVertexPointer(), that will change the binding point whose index matches the attribute index.

Hmm… I would be happy if the above code is conceptually correct. I always thought that base vertex is designed exactly to take away those binding calls unless the binding call changes the buffer itself.

By itself, it appears to be; but that’s not the entire program. There are things which might occur in the rest of the program which would cause the first approach not to work while the second approach works.