Fragment shader: no uniform with a name in the shader

I have a problem with fragment shader in libgdx. Below is a fragment of a shader.

#ifdef GL_ES
precision mediump float;
#endif
uniform float u_aspectRatio;
varying vec2 v_texCoords;
uniform sampler2D u_texture;     
void main()                 
{                       
  gl_FragColor = texture2D(u_texture, v_texCoords);
}

In the program I do

shader.setUniformi("u_texture", 0); // work fine
shader.setUniformf("u_aspectRatio", 0.0f); //no uniform with name 'u_aspectRatio' in shader

shader.isCompiled () returns true, and the first set works fine, but in the second I have the error "there is no uniform named" u_aspectRatio "in the shader." If the delete line is:

uniform float u_aspectRatio;

everything works fine from shader, but when I add this line (in the function I want to work with this object) and try to install some data, I have an error.

0
source share
3 answers
+1

, ,

float .

 int a = shader.getUniformLocation("u_aspectRatio");
 shader.setUniformf(a ,0.0f);
+2

, - . . , , .

+1

All Articles