1

Just wondering if anyone could help me with the following piece of code:

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

I want to assign uniforms with a subscript of type 'char* uiformName' for every iteration of the for-loop. I'm receiving the error "Array subscript is not an integer".

How can I use a char as an array subscript?

Thank you

0

1 Answer 1

3

What you want then is a dictionary where both the key and value are strings:

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]];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.