PDA

View Full Version : Uniform arrays and element location



tomcio
04-14-2011, 10:09 AM
Hi

Can I always assume that in case of uniform arrays (especially samplers) all subsequent elements have their location incremented by 1 from base element or is it compiler dependent and I have to keep trace of locations for all array elements?

Example :



in fragment shader
{
uniform sampler2D s_texture[3]
}


Uniform ----- Location
s_texture[0] -- 4
s_texture[1] -- 5
s_texture[2] -- 6

Thanks

Alfonse Reinheart
04-14-2011, 12:51 PM
No; you must query each individually. Or you can use the array forms of uploading (glUniformiv) to fill out an array.

BTW, sampler arrays have a number of limitations on them that may not be appropriate for your particular needs.

V-man
04-14-2011, 03:59 PM
Normally, one would just setup the samplers only once, after your shader is linked.

For other types of uniforms, yes, use glUniform or glUniformMatrix.

tomcio
04-15-2011, 01:14 AM
Ok so I will just use uniform array setting function.

Thanks