-
Notifications
You must be signed in to change notification settings - Fork 1
/
reVisualGL.html
111 lines (88 loc) · 3.36 KB
/
reVisualGL.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<title>Uint16 Texture</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link type="text/css" href="style.css" rel="stylesheet"/>
<script type="text/javascript" src="glMatrix095.js"></script>
<script type="text/javascript" src="webGL-utils.js"></script>
<script type="text/javascript" src="gl-preview.js"></script>
<script src="glue.js"></script>
<script src="makeSamples.js"></script>
<script src="benmu-riff.js"></script>
<script src="benmu-dataurl.js"></script>
<script id="shader-fs" type="text/x-fragment">
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
void main(void) {
vec4 samples = texture2D(uSampler, vec2(vTextureCoord.t, vTextureCoord.s));
float sample = samples.a;
float adjusted = sample > .5 ? sample -.5 : .5+sample;
gl_FragColor = vec4(adjusted, 0.0, 0.0, 1.0);
}
</script>
<script id="shader-vs" type="text/x-vertex">
attribute vec2 aTextureCoord;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying vec2 vTextureCoord;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aTextureCoord,0.0,1.0);
vTextureCoord = aTextureCoord;
}
</script>
</head>
<body onload="webGLStart();">
<form onsubmit="return false;">
<input type="text" id="oneliner" value="t>>7|t>>22|t"/>
<label for="autoPlay">Automatically play</label> <input type="checkbox" id='autoPlay' checked='false'/>
<input type="button" value="Play" id="gen" onclick="play()" /> <input type="button" value="Stop" id="stop" onclick="stop()" />
</form>
<div id="error"></div>
<canvas id="canvas" width="256" height="1024"></canvas>
<audio id="player" autoplay="true" controls="true"/>
<canvas width="1024" height="512" id="canvas" ></canvas>
<p>[enter] play, [esc] stop</p>
<script>
var keyMap = {
13: function() { cbAutoPlay.checked = true; onPlayButton();},
27: function(){ cbAutoPlay.checked = false; stop(); oneLinerElt.focus();}
}; //keyMap
var sampleFunction = null;
var errDiv = document.getElementById("error");
var oneLinerElt = document.getElementById('oneliner');
var cbAutoPlay = document.getElementById("autoPlay");
cbAutoPlay.checked = false;
function onKey(event) {
var fn = keyMap[event.keyCode];
if(fn) fn();
else {
updateAndMaybePlay(cbAutoPlay.checked);
}
}
function updateFunction() {
var oneLiner = oneLinerElt.value;
sampleFunction = makeSampleFunction(oneLiner,errDiv);
}
function onPlayButton() {
updateAndMaybePlay(true);
}
var sampleData;
function updateAndMaybePlay(playSound) {
var oneLiner = oneLinerElt.value;
var sampleFunction = makeSampleFunction(oneLiner);
sampleData = sampleData || new Uint8Array(256*1024);
sampleData = makeSampleData(sampleFunction,256,1024);
if(playSound)
play(sampleData);
gl.updateTexture(backBuffer);
drawScene();
oneLinerElt.focus();
}
document.getElementById("oneliner").focus();
document.getElementById("oneliner").onkeyup = onKey;
document.getElementById("gen").onclick = onPlayButton;
</script>
</body>
</html>