Q:

OpenGL/GLSL precision error

I have a simple vertex shader:
precision mediump float;

attribute vec4 position;

attribute vec4 color;
varying vec4 f_color;

uniform mat4 projection;
uniform mat4 modelView;

void main(void) {
    gl_Position = projection * modelView * position;
    f_color = color;
    f_texCoord = texCoord;
}

This fails to compile, stating (using getShaderInfoLog()):
ERROR: 0:1: 'precision' : syntax error syntax error

It compiles fine if i remove the line with the precision specifier.
System:
OS: Mac OX 10.9.2 
GPU: NVIDIA GeForce 320M 256 MB
GLSL Ver.: 1.20

Someone help me out.

A:

You have already figured out how to solve your problem: just remove the line with the precision qualifier.
The bigger issue is that you haven't decided what version of OpenGL you are using. The GLSL sample you provided seems to be for an old version of the GLSL associated with OpenGL ES, which is designed for mobile devices. Since you are actually running on a desktop/laptop, you want "normal" OpenGL. The error you observed is a result of the differences between the two.
In general you want to go with the latest version of OpenGL that is support by the systems you are targeting. Right now that is probably OpenGL 3.3 (along with GLSL 3.3).

