0
我使用以下代碼嘗試從我的着色器中檢索屬性。Open GL ES着色器 - 獲取屬性
這段代碼是檢索制服而不是屬性。
/*********** 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);
}
有人能看到anythng我做錯了嗎?
@ samb90一個緩衝,這是否回答這個問題? – Kimi 2013-03-06 14:00:29
是的,非常非常。感謝您的幫助! – samb90 2013-03-06 23:39:38