WebGL: INVALID_OPERATION: uniform1i: location not for current program

I am trying to set up two textures in my fragment shader, but I get this error if I try to set the corresponding uniform variables with

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

What does it mean? (I am 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" + 
+4
source share
1 answer

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

If you use only one program for shaders, just make sure that you execute gl.useProgram in your initialization before you execute gl.uniform…

If you use several shader programs, make sure that the correct one is selected before trying to set the same values. Please note that uniforms are specific to programs, and they are remembered by programs, so you do not need to reinstall them each time you switch programs!

+12
source

All Articles