Consider the following code in an OpenGL shader:
struct PointLight {
vec3 position;
float constant;
float linear;
float quadratic;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform PointLight pointLights[4];
How can I query the size of pointLights
using interface query?
I tried this:
auto idx = glGetProgramResourceIndex(prog, GL_UNIFORM, "pointLights");
auto blockProperty = (GLenum)GL_ARRAY_SIZE;
auto arraySize = GLint{};
glGetProgramResourceiv(prog, GL_UNIFORM, idx, 1, &blockProperty, 1, nullptr, &arraySize);
It returns 0, which corresponds to the documentation of glGetProgramResourceiv
:
For active variables not corresponding to an array of basic types, the value zero is written to params.
Well, what should I do for non-basic types?
pointLights
is an array ofPointLight
structures which contain certain fields with certain names, right? Adding one number to this list is hardly out of left field. $\endgroup$