只是想知道是否有人可以通过以下代码帮助我:
// Get uniform locations.
GLint m_nUniforms = 0;
glUniformMatrix4fv(uniforms, 1, 0, _modelViewProjectionMatrix.m);
glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &m_nUniforms);
for(unsigned i = 0; i < m_nUniforms; i++)
{
char *uniformName = NULL;
GLint size;
GLenum type;
glGetActiveUniform(_program, i, max_length + 1, NULL, &size, &type, uniformName);
uniforms[uniformName] = glGetUniformLocation(_program, uniformName);
}
我想为for循环的每次迭代分配类型为'char * uiformName'的下标的制服。我收到错误“数组下标不是整数”。
如何使用char作为数组下标?
谢谢
最佳答案
然后,您想要的是一个字典,其中的键和值都是字符串:
NSMutableDictionary *uniforms = [[NSMutableDictionary alloc] init];
for (blah)
{
glGetActiveUniform(_program, i, max_length + 1, NULL, &size, &type, uniformName);
char *uniform = glGetUniformLocation(_program, uniformName);
[uniforms addObject:[NSString stringWithUTF8String:uniform]
forKey:[NSString stringWithUTF8String:uniformName]];
}