0
\$\begingroup\$

For debug purposes I've minimised the shader to the following:

varying vec4 v_color;
varying vec2 v_texCoords;

uniform sampler2D u_texture;

void main() {
    // ivec2 size = textureSize(u_texture, 0);//throws error if this line is enabled

    gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
}

So don't mind what it actually does at the moment. With the line commented out it works fine, and other shaders work fine, but with the line in I get the errors:

[GLProfiler] Error GL_INVALID_OPERATION from glUniform2f

[GLProfiler] Error GL_INVALID_OPERATION from glUniform1f

[GLProfiler] Error GL_INVALID_OPERATION from glUniformMatrix4fv

\$\endgroup\$
2

1 Answer 1

1
\$\begingroup\$

The reason it does not work is because I'm using LibGDX and by default the opengl version is 2 which is not compatible with the function textureSize. A workaround is to input the texture size using a uniform variable.

varying vec4 v_color;
varying vec2 v_texCoords;

uniform sampler2D u_texture;
uniform vec2 resolution;//texture resolution is fed to the shader here


void main() {
    // ivec2 size = textureSize(u_texture, 0);//no need for this line

    gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .