Saturday 15 August 2015

opengl - glGetUniformLocation unpredictable behavior -



opengl - glGetUniformLocation unpredictable behavior -

i've defined struct in fragment shader, below:

struct light_source{ vec4 ld, location; int type; float radii, specular_exponent; };

and i'm using uniform access struct members: uniform light_source light_sources[5];

now, c++ code, i'm getting uniform locations this:

ld = glgetuniformlocation(globals::programid, "light_sources[0].ld"); ls = glgetuniformlocation(globals::programid, "light_sources[0].ls"); location = glgetuniformlocation(globals::programid, "light_sources[0].location"); type = glgetuniformlocation(globals::programid, "light_sources[0].type"); radii = glgetuniformlocation(globals::programid, "light_sources[0].radii"); specular_exponent = glgetuniformlocation(globals::programid, "light_sources[0].specular_exponent");

when print above values, find values -1,1,2,-1,3,4 . so, couldn't locations ld , type . similarly, if add together new variable shader , times location, , -1 .

i don't problem here. variable definitions right , there no typos. can behavior remedied?

when uniform/attribute not beingness used or has no effect on output compiler/linker free remove exclusively results in getuniformlocation , glgetattributelocation returning invalid values.

opengl glsl

No comments:

Post a Comment