LWJGL: Getting a "Unrecognized profile specifier "mediump" fragment shader error

Here’s the fragment shader code:

		this.fragmentShaderCode = ""
				+ "precision mediump float;\n"
				+ "\n"
				+ "uniform sampler2D u_tex;\n"
				+ "uniform vec3 u_color;\n"
				+ "\n"
				+ "varying vec2 v_texcoord;\n"
				+ "\n"
				+ "void main(){\n"
				+ "		vec4 color = texture2D(u_tex, v_texcoord);\n"
				+ "		color = vec4(1.0, 0.0, 1.0, 1.0);\n"
				+ "		if (color.a>0.0){\n"
				+ "			gl_FragColor = color*u_color;\n"
				+ "		} else {\n"
				+ "			discard;\n"
				+ "		}\n"
				+ "}\n"
				+ "\n"
				+ "\n";

And here’s the error dump:

Anyone knows what’s going on?

I believe that you only use [icode]precision mediump float;[/icode] if you are using GL ES. Also, I think that since u_color is a vec3, that you have to cast the result to a vec4 when you multiply then? Not sure on that one though.

For compatibility with GL ES you can use this for your precision specifier:
[icode]#ifdef GL_ES
precision mediump float;
#endif[/icode]

Longarmx is right; you shouldn’t mix and match types like that. You can do stuff like this, though:

float f = 0.5;
vec3 v = vec3(0.5, 2.0, 10);
vec3 o = v * f; // multiplies a vector by a scalar

vec4 t = vec4(o, 1.0); //uses o.xyz for the vec4

If I’m not programming for OpenGL ES, then should I use [icode]precision highp float;[/icode]? Or the whole [icode]precision blahblahblah;[/icode] is not used for regular OpenGL stuffs?

And yeah, I saw the vec4 implicit cast to vec3 error, I fixed the error after posting the screenshot. Thanks for the heads-up.

If you have no intention of supporting GL ES, then you can remove it without any problems.

Ok, thanks.