gpt4 book ai didi

ios - 数组下标不是整数错误

转载 作者:行者123 更新时间:2023-12-01 19:12:55 26 4
gpt4 key购买 nike

只是想知道是否有人可以通过以下代码帮助我:

// 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]];
}

关于ios - 数组下标不是整数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15202682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com