PDA

View Full Version : Generic vertex attributes



bunny
02-06-2004, 08:51 AM
Can anyone tell me how to access generic vertex attributes with the GLSL. The spec only mentions standard attributes.

jeremyz
02-06-2004, 09:04 AM
// Get the attribute index for the
// monkey parameter
monkeyAttrib = glGetAttribLocationARB(myVertexProgram, "monkey");

glVertexAttribPointerARB(monkeyAttrib, 1, GL_FLOAT, GL_FALSE, 1234, monkeyData);
http://www.3dlabs.com/support/developer/ogl2/slapi/GetAttribLocationARB.htm http://www.3dlabs.com/support/developer/ogl2/slapi/VertexAttribPointerARB.htm

bunny
02-06-2004, 09:08 AM
I understand how to set generic attributes. I just don't know how to get at them from within a vertex shader.

For example, to get the normal, I can use gl_Normal, but how do I get attribute 6?

bunny
02-06-2004, 09:11 AM
Scratch that. I see what you mean. There's no way to access a specific attrib because the GLSL determines the number for me. Thanks!

jeremyz
02-06-2004, 12:19 PM
You can tell GLSL which attrib index you want a given variable to have using glBindAttribLocationARB().

http://www.3dlabs.com/support/developer/ogl2/slapi/BindAttribLocationARB.htm

bunny
02-06-2004, 03:05 PM
That's useful. I should really RTFM at some point. I hadn't realised 3DLabs' documentation was so good. Thanks again.