About the usage of glUniform{2|3|4}iv

As clarified in the reference, the glUniform{2|3|4}iv takes three parameters, location, count and v. But when count is greater than 1, what is the structure of v?
Suppose I call it as the following.


Which way should I set v?

int v={{somevalue,somevalue},{somevalue,somevalue}};


int v={somevalue,somevalue,somevalue,somevalue};

Thanks in advance!


The count parameter is the number of elements in the array you’re modifying, or 1 if you’re not modifying an array. The number in the function name is the size of an element. 1 means scalar (float, int, uint, etc). 2 means 2-element vector (vec2, ivec2, uvec2, etc). And so on.

If you’re modifying a single vec2, you use glUniform2fv(…, 1, <array of two floats>);. If you’re modifying a vec2[3], then you use glUniform2fv(…, 3, <array of 2 * 3 floats>);

Thanks for your great help!

Best regards,


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.