diff --git a/glslUtil.c b/glslUtil.c index 15885b8..f151c4c 100644 --- a/glslUtil.c +++ b/glslUtil.c @@ -347,3 +347,13 @@ void guGetUniformLocations(GLuint program, guUniformLocation *locs) *locs[i].loc = glGetUniformLocation(program, locs[i].name); } } + +void guGetUniformLocationsArray(GLuint program, const char **names, + GLint *locations) +{ + int i; + for (i = 0; names[i] != NULL; i++) + { + locations[i] = glGetUniformLocation(program, names[i]); + } +} diff --git a/glslUtil.h b/glslUtil.h index 8062ca5..2584bb6 100644 --- a/glslUtil.h +++ b/glslUtil.h @@ -234,6 +234,19 @@ GLuint guMakeProgram(GLuint v_shader_id, GLuint f_shader_id, */ void guGetUniformLocations(GLuint program, guUniformLocation *locs); +/** + * Get the locations of uniform variables in an OpenGL program object. + * This function stores the locations found into an array of GLints. + * @param program the OpenGL program object + * @param names pointer to a NULL-terminated array of uniform names + * @param locations pointer to an array of GLints to store the locations in + * + * locations should point to an array with as many elements as names + * points to (minus the terminating NULL element). + */ +void guGetUniformLocationsArray(GLuint program, const char **names, + GLint *locations); + /** * Create an OpenGL buffer object containing contents from memory. * @param target the OpenGL buffer target (ex: GL_ARRAY_BUFFER).