顶点属性信息
可以使用 OGL 函数 glGetProgram 和参数 GL_ACTIVE_ATTRIBUTES
和 GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
检索有关顶点属性的信息。
活动着色器属性的位置可以由 OGL 函数 glGetAttribLocation 通过属性的索引来确定。
GLuint shaderProg = ...;
std::map< std::string, GLint > attributeLocation;
GLint maxAttribLen, nAttribs;
glGetProgramiv( shaderProg, GL_ACTIVE_ATTRIBUTES, &nAttribs );
glGetProgramiv( shaderProg, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttribLen
GLint written, size;
GLenum type;
std::vector< GLchar >attrName( maxAttribLen );
for( int attribInx = 0; attribInx < nAttribs; attribInx++ )
{
glGetActiveAttrib( shaderProg, attribInx, maxAttribLen, &written, &size, &type, &attrName[0] );
attributeLocation[attrName] = glGetAttribLocation( shaderProg, attrName.data() );
}