PDA

View Full Version : Switching from glVertexAttribPointer to glVertexAttribFormat



Sylvain Rochette
08-01-2013, 05:56 PM
Hi I just switched to use glVertexAttribFormat instead of glVertexAttribPointer for my vertex array object.

I use this glBindVertexBuffer to bind my VBO to it, it is possible to bind also the index buffer?

In my game, I only use one big VBO, the problem is I store 3 differents attributes, but always use the same index buffer object as well, in order to not crash I always need to call this glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ...);

Since it is always the same buffer, its a pure waste of opengl call, but each time I change my vertex attrib, it unbind my index buffer...

Maybe I miss something?

Alfonse Reinheart
08-01-2013, 06:29 PM
each time I change my vertex attrib, it unbind my index buffer...

If by "change my vertex attrib" you mean "bind a new vertex array object", then of course it does. GL_ELEMENT_ARRAY_BUFFER is part of the VAO state. You shouldn't need to change it at all. You set it once, in your VAO, then leave it there.

Sylvain Rochette
08-01-2013, 06:39 PM
ah, thank you, I did not do the proper way. I was setting up my IBO before the creation of my vertex attr, I needed to bind it after! I was sure it was using the current binded object, i was wrong...