Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebGL: INVALID_OPERATION: uniform1i: location not for current program

I'm trying to setup two textures in my fragment shader but am getting this error if I try setup the corresponding uniform variables with:

gl.uniform1i(getUniformLocation(program, "uTextureOne"), 0); and gl.uniform1i(getUniformLocation(program, "uTextureTwo"), 1);.

What does it mean? (I'm using Chrome)

My shader looks like this:

        "#ifdef GL_ES                       \r\n" +
        "precision mediump float;           \r\n" + 
        "#endif                             \r\n" +
        "uniform sampler2D uTextureOne;     \r\n" +
        "uniform sampler2D uTextureTwo;     \r\n" +
        "varying vec3 vOrgNormal;           \r\n" +
        "void main(void) {                  \r\n" +
like image 269
georgij Avatar asked Jan 19 '13 11:01

georgij


1 Answers

“Location not for current program” means that the active shader program (gl.useProgram) is not the program which you obtained the uniform locations from.

If you are using only one shader program, then simply make sure that in your initialization you do gl.useProgram before you do any gl.uniform….

If you are using multiple shader programs, make sure that the correct one is selected before you attempt to set uniform values. Note that uniforms are specific to programs and they are remembered by the programs, so you don't have to re-set them every time you switch programs!

like image 59
Kevin Reid Avatar answered Jan 04 '23 12:01

Kevin Reid