Has anyone tried using generic vertex attributes with a VBO and glDrawElements? I currently have a app which renders objects from VBOs. Each object has it’s own VBO, which objects having the same geometry reusing a VBO. I am looking for an example of how to do that, and pass an array of data to the GPU for use as a generic vertex attribute.
Has anyone tried using generic vertex attributes with a VBO and glDrawElements?
Yes.
I am looking for an example of how to do that, and pass an array of data to the GPU for use as a generic vertex attribute.
You do it the same way you used non-generic vertex attributes. Except that you have to assign glslang names to them, or let the system auto-assign them.
Originally posted by Korval:
[b] [quote]Has anyone tried using generic vertex attributes with a VBO and glDrawElements?
Yes.
I am looking for an example of how to do that, and pass an array of data to the GPU for use as a generic vertex attribute.
You do it the same way you used non-generic vertex attributes. Except that you have to assign glslang names to them, or let the system auto-assign them. [/b][/QUOTE]
glVertexAttribPointer(MATERIAL_CODE_ARRAY, 1, GL_INT, GL_FALSE, 0, m_MaterialCodes);
Where does MATERIAL_CODE_ARRAY come from? Are you telling glslang that this is the value you want to give to the attribute named “MaterialCode”?
int MaterialCode;
You need to tell OpenGL that it is an attribute. By using the attribute keyword.
Originally posted by Korval:
[b] [quote]glVertexAttribPointer(MATERIAL_CODE_ARRAY, 1, GL_INT, GL_FALSE, 0, m_MaterialCodes);
Where does MATERIAL_CODE_ARRAY come from? Are you telling glslang that this is the value you want to give to the attribute named “MaterialCode”?
int MaterialCode;
You need to tell OpenGL that it is an attribute. By using the attribute keyword. [/b][/QUOTE]