我正在使用以下代码尝试从我的着色器中检索属性。
这段代码正在检索制服而不是属性。
/*********** Get attribute locations. ***************/
// Dictionary to store each active attribute
NSMutableDictionary *m_attributes = [[NSMutableDictionary alloc] init];
int m_nAttributes = -1;
glGetProgramiv( _program, GL_ACTIVE_ATTRIBUTES, &m_nAttributes );
for(GLuint i = 0; i < m_nAttributes; i++) {
int name_len=-1, num=-1;
GLenum type = GL_ZERO;
char attributesName[100];
glGetActiveUniform( _program, i, sizeof(attributesName)-1, &name_len, &num, &type, attributesName );
attributesName[name_len] = 0;
GLuint attributes = glGetUniformLocation( _program, attributesName );
[m_attributes setObject:[NSNumber numberWithUnsignedInt:attributes]
forKey:[NSString stringWithUTF8String:attributesName]];
}
这是我的着色器:
attribute vec3 VertexPosition;
attribute vec3 VertexNormal;
attribute vec2 VertexTexCoord0;
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewProjMatrix;
varying vec3 Normal;
varying vec2 TexCoord0;
void main(void)
{
Normal = VertexNormal;
TexCoord0 = VertexTexCoord0;
gl_Position = ModelViewProjMatrix * vec4(VertexPosition, 1.0);
}
谁能看到我做错了什么?