forked from gpjt/webgl-lessons
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy path03-animation.html
53 lines (45 loc) · 1.58 KB
/
03-animation.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
<html>
<head>
<title>WebGL - 03 Animation</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/03-animation.js" type="text/javascript"></script>
<!-- Fragment shader program -->
<script id="shader-fs" type="x-shader/x-fragment">
// set medium percision
precision mediump float;
// uniform attribute for setting the color
varying vec4 vColor;
void main(void) {
// Setting color of fragments to input color
gl_FragColor = vColor;
}
</script>
<!-- Vertex shader program -->
<script id="shader-vs" type="x-shader/x-vertex">
// atributes for setting vertex position and color
attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
uniform mat4 uMVMatrix; // model-view matrix
uniform mat4 uPMatrix; // projection matrix
varying vec4 vColor; // variable for passing color value to the fragment shader
void main(void) {
// calculate the vertex position
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
vColor = aVertexColor;
}
</script>
</head>
<body onload="start()">
<h1>WebGL - 03 Animation</h1>
<div id="content">
<canvas id="glcanvas" width="1280px" height="720px">
No <code><canvas></code> suppport in your browser.
</canvas>
<br />
<br />
<a href="./"><- Back</a>
</div>
</body>
</html>