forked from gpjt/webgl-lessons
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy path06-keyboard.html
62 lines (54 loc) · 2.02 KB
/
06-keyboard.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
<html>
<head>
<title>WebGL - 06 Keyboard input and texture filters</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./style/webgl.css" type="text/css">
<script type="text/javascript" src="./scripts/glMatrix-0.9.5.min.js"></script>
<script src="./scripts/06-keyboard.js" type="text/javascript"></script>
<!-- Fragment shader program -->
<script id="shader-fs" type="x-shader/x-fragment">
// uniform attribute for setting texture coordinates
varying highp vec2 vTextureCoord;
// uniform attribute for setting 2D sampler
uniform sampler2D uSampler;
void main(void) {
// set color of fragment accordingly to the color in texture
gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
}
</script>
<!-- Vertex shader program -->
<script id="shader-vs" type="x-shader/x-vertex">
// atributes for setting vertex position and texture coordinates
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoord;
uniform mat4 uMVMatrix; // model-view matrix
uniform mat4 uPMatrix; // projection matrix
// variable for passing texture coordinates from vertex shader to fragment shader
varying highp vec2 vTextureCoord;
void main(void) {
// calculate the vertex position
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
vTextureCoord = aTextureCoord;
}
</script>
</head>
<body onload="start()">
<h1>WebGL - 06 Keyboard input and texture filters</h1>
<div id="content">
<canvas id="glcanvas" width="1280px" height="720px">
No <code><canvas></code> suppport in your browser.
</canvas>
<br />
<br />
<h2>Controls:</h2>
<ul>
<li><code>Page Up/Down</code> to zoom out/in</li>
<li>Cursor keys: change rotation velocity about x/y axis</li>
<li><code>F</code> to toggle through three kinds of texture filters (Neares, Linear, MipMap)</li>
</ul>
<br />
<br />
<a href="./"><- Back</a>
</div>
</body>
</html>