Fixed OpenGL ES Shaders for systems that don't understand precision keywords
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c
index f9a8ce3..b6c187d 100644
--- a/src/render/opengles2/SDL_shaders_gles2.c
+++ b/src/render/opengles2/SDL_shaders_gles2.c
@@ -27,6 +27,16 @@
#include "SDL_shaders_gles2.h"
#include "SDL_stdinc.h"
+#define SHADER_PRELOGUE "\n\
+#if GL_FRAGMENT_PRECISION_HIGH\n\
+ precision mediump float;\n\
+#else\n\
+ #define mediump\n\
+ #define highp\n\
+ #define lowp\n\
+#endif\n\
+"
+
/*************************************************************************************************
* Vertex/fragment shader source *
*************************************************************************************************/
@@ -47,8 +57,7 @@ static const Uint8 GLES2_Vertex_Default[] = " \
} \
";
-static const Uint8 GLES2_Fragment_Solid[] = " \
- precision mediump float; \
+static const Uint8 GLES2_Fragment_Solid[] = SHADER_PRELOGUE" \
varying vec4 v_color; \
\
void main() \
@@ -57,8 +66,7 @@ static const Uint8 GLES2_Fragment_Solid[] = " \
} \
";
-static const Uint8 GLES2_Fragment_TextureABGR[] = " \
- precision mediump float; \
+static const Uint8 GLES2_Fragment_TextureABGR[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
@@ -75,8 +83,7 @@ static const Uint8 GLES2_Fragment_TextureABGR[] = " \
";
/* ARGB to ABGR conversion */
-static const Uint8 GLES2_Fragment_TextureARGB[] = " \
- precision mediump float; \
+static const Uint8 GLES2_Fragment_TextureARGB[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
@@ -96,8 +103,7 @@ static const Uint8 GLES2_Fragment_TextureARGB[] = " \
";
/* RGB to ABGR conversion */
-static const Uint8 GLES2_Fragment_TextureRGB[] = " \
- precision mediump float; \
+static const Uint8 GLES2_Fragment_TextureRGB[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
@@ -118,8 +124,7 @@ static const Uint8 GLES2_Fragment_TextureRGB[] = " \
";
/* BGR to ABGR conversion */
-static const Uint8 GLES2_Fragment_TextureBGR[] = " \
- precision mediump float; \
+static const Uint8 GLES2_Fragment_TextureBGR[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
@@ -168,7 +173,7 @@ static const Uint8 GLES2_Fragment_TextureBGR[] = " \
#define YUV_SHADER_PROLOGUE \
-"precision mediump float;\n" \
+SHADER_PRELOGUE \
"uniform sampler2D u_texture;\n" \
"uniform sampler2D u_texture_u;\n" \
"uniform sampler2D u_texture_v;\n" \
@@ -396,3 +401,4 @@ const Uint8 *GLES2_GetShader(GLES2_ShaderType type)
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
+