-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathglsl-quad-uv-demo.js
44 lines (41 loc) · 1012 Bytes
/
glsl-quad-uv-demo.js
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
const resl = require('resl');
const regl = require('regl')();
const quad = require('./glsl-quad.js');
resl({
manifest: {
texture: {
type: 'image',
// quad provides a bitmap as a uri to display; the "directions" bitmap shows two
// axis with up/down/right/left lines/arrows.
src: quad.bitmaps.directions.uri,
parser: (data) => regl.texture({
data: data,
mag: 'nearest',
min: 'nearest',
flipY: true
})
}
},
onDone: ({texture}) => {
const drawTexture = regl({
vert: quad.show.uvs.vert,
frag: quad.show.uvs.frag,
attributes: {
a_position: quad.verts,
a_uv: quad.uvs
},
elements: quad.indices,
frontFace: 'ccw',
cull: {
enable: true,
face: 'back'
},
uniforms: {
u_tex: regl.prop('texture'),
// Use a negative y, webgl display works upside down. I think.
u_clip_y: 1
}
});
drawTexture({texture});
}
});