PDA

View Full Version : Has anyone tried using generic vertex attributes with a VBO and glDrawElements?



CelticDaddio
06-14-2007, 10:20 AM
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.

Thanks,
Ed

Korval
06-14-2007, 10:43 AM
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.

CelticDaddio
06-14-2007, 11:24 AM
In my shader setup, I have this:


Originally posted by Korval:

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.

Korval
06-14-2007, 01:02 PM
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.

CelticDaddio
06-14-2007, 01:04 PM
Yes, I have MATERIAL_CODE_ARRAY deffed

#define MATERIAL_CODE_ARRAY 6

Ed


Originally posted by Korval:

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.