How to draw a triangle
Draw a single triangle with a gradient fill.
Draw a single triangle with a gradient fill.
Vertice | Index | x | y |
---|---|---|---|
0 | 0 | 10 | 5 |
1 | 1 | 44 | 10 |
2 | 2 | 24 | 20 |
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);}
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);}