1 #include <GLES2/gl2.h>
2 #include "render/gles2.h"
3 
4 // Colored quads
5 const GLchar quad_vertex_src[] =
6 "uniform mat3 proj;\n"
7 "uniform vec4 color;\n"
8 "attribute vec2 pos;\n"
9 "attribute vec2 texcoord;\n"
10 "varying vec4 v_color;\n"
11 "varying vec2 v_texcoord;\n"
12 "\n"
13 "void main() {\n"
14 "	gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
15 "	v_color = color;\n"
16 "	v_texcoord = texcoord;\n"
17 "}\n";
18 
19 const GLchar quad_fragment_src[] =
20 "precision mediump float;\n"
21 "varying vec4 v_color;\n"
22 "varying vec2 v_texcoord;\n"
23 "\n"
24 "void main() {\n"
25 "	gl_FragColor = v_color;\n"
26 "}\n";
27 
28 // Colored ellipses
29 const GLchar ellipse_fragment_src[] =
30 "precision mediump float;\n"
31 "varying vec4 v_color;\n"
32 "varying vec2 v_texcoord;\n"
33 "\n"
34 "void main() {\n"
35 "	float l = length(v_texcoord - vec2(0.5, 0.5));\n"
36 "	if (l > 0.5) {\n"
37 "		discard;\n"
38 "	}\n"
39 "	gl_FragColor = v_color;\n"
40 "}\n";
41 
42 // Textured quads
43 const GLchar tex_vertex_src[] =
44 "uniform mat3 proj;\n"
45 "uniform bool invert_y;\n"
46 "attribute vec2 pos;\n"
47 "attribute vec2 texcoord;\n"
48 "varying vec2 v_texcoord;\n"
49 "\n"
50 "void main() {\n"
51 "	gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
52 "	if (invert_y) {\n"
53 "		v_texcoord = vec2(texcoord.x, 1.0 - texcoord.y);\n"
54 "	} else {\n"
55 "		v_texcoord = texcoord;\n"
56 "	}\n"
57 "}\n";
58 
59 const GLchar tex_fragment_src_rgba[] =
60 "precision mediump float;\n"
61 "varying vec2 v_texcoord;\n"
62 "uniform sampler2D tex;\n"
63 "uniform float alpha;\n"
64 "\n"
65 "void main() {\n"
66 "	gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
67 "}\n";
68 
69 const GLchar tex_fragment_src_rgbx[] =
70 "precision mediump float;\n"
71 "varying vec2 v_texcoord;\n"
72 "uniform sampler2D tex;\n"
73 "uniform float alpha;\n"
74 "\n"
75 "void main() {\n"
76 "	gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
77 "}\n";
78 
79 const GLchar tex_fragment_src_external[] =
80 "#extension GL_OES_EGL_image_external : require\n\n"
81 "precision mediump float;\n"
82 "varying vec2 v_texcoord;\n"
83 "uniform samplerExternalOES texture0;\n"
84 "uniform float alpha;\n"
85 "\n"
86 "void main() {\n"
87 "	gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
88 "}\n";
89