Question: I want to have same shader source for OpenGL ES and OpenGL (Windows). To do this I want to define custom data types and use only OpenGL ES functions. 

One approach is to define:

```
#define highp
#define mediump
#define lowp

```

for Windows shader and write the shader as it is for OpenGL ES.

Other approach is to define custom data types like this for OpenGL ES:

```
#define hvec2 highp vec2

```

and like this for Windows

```
#define hvec2 vec2

```

What do you think is better? Do you have other solutions for this problem?

Answer: 
My solution has been to write shader code that is compatible with both APIs, and then when uploading the fragment shader source code to OpenGL ES just prepend the following line:

```
precision mediump float;

```

That sets the default floating point precision to medium. In OpenGL ES fragment shaders there is no default precision level for floating point values, which means you either need to specify a precision on every floating point declaration, or explicitly set a default precision. You could use `lowp` or `highp` instead if that makes more sense for your application.

For more details see section 4.5.3 of the OpenGL ES Shading Language specification: <http://www.khronos.org/files/opengles_shading_language.pdf>

You could also mix this approach with your `#define` approach if you need finer control over precision in your shaders.
I managed it by just defining the following at the begin of each shader when the shader runs on windows:

```
#define lowp
#define mediump
#define highp

```

Additional i give the shader the information which plattform is used ( WINDOWS, MOBILE, IOS ) which can be used this way:

```
#ifdef WINDOWS
precision mediump float;
#endif

```