How to draw a triangle

Draw a single triangle with a gradient fill.

data

Vertice Index x y
0 0 10 5
1 1 44 10
2 2 24 20

pixel

r
0
g
0
b
0
a
0
x
0
y
0

Fragment Shader

precision mediump float;uniform vec2 u_resolution;void main() { vec2 uv = gl_FragCoord.xy / u_resolution.xy; gl_FragColor = vec4(uv.x, uv.y, 0.7, 1.0);}

Vertex Shader

precision mediump float;attribute vec2 a_position;uniform vec2 u_resolution;void main() { vec2 pos = a_position / u_resolution * 2.0 - 1.0; gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);}