createDrawCommand = regl =>
regl({
frag: `
precision mediump float;
uniform sampler2D texture;
varying vec2 uv;
void main () {
gl_FragColor = texture2D(texture, uv);
}`,
vert: `
precision mediump float;
attribute vec2 position;
uniform vec2 aspectRatio;
uniform float zoom;
varying vec2 uv;
void main () {
uv = 0.5 + 0.5 * vec2(position) * aspectRatio;
gl_Position = vec4(position, 0, 1.0 / zoom);
}`,
attributes: {
position: [[-2, -4], [-2, 4], [4, 0]]
},
depth: { enable: false },
uniforms: {
texture: regl.texture({ data: image, flipY: true }),
aspectRatio: ctx => {
const ar = ctx.viewportWidth / ctx.viewportHeight;
return ar > 1 ? [ar, 1] : [1, 1 / ar];
},
zoom: regl.prop('zoom')
},
count: 3
})