cube.html
1.53 KB
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
<html>
<head>
<title>Colored animated cube.</title>
<link rel="stylesheet" href="css/main.css">
<script type="text/javascript" src="js/parallax.js"></script>
<script type="text/javascript" src="js/gl-matrix-min.js"></script>
<script type="text/javascript" src="js/cube.js"></script>
<script id="cube-vertex-shader" type="x-shader/x-vertex">
attribute vec3 vertexPos;
attribute vec4 vertexColor;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
varying vec4 vColor;
void main(void) {
// Return the transformed and projected vertex value
gl_Position =
projectionMatrix * modelViewMatrix * vec4(vertexPos, 1.0);
// Output the vertexColor in vColor
vColor = vertexColor;
}
</script>
<script id="cube-fragment-shader" type="x-shader/x-fragment">
precision mediump float;
varying vec4 vColor;
void main(void) {
// Return the pixel color: always output white
gl_FragColor = vColor;
}
</script>
<style>
.result_container {
height: 200px;
}
</style>
</head>
<body onLoad="startGl();init()" onScroll="parallax()">
<div id="back" class="text">
<a href="index.html">back</a>
</div>
<div id="background">
<div id="content" class="text">
<h1>Colored animated cube.</h1>
<p>
An animated cube. Each side has a different color.
</p>
<h2>Result</h2>
<div class="gl">
<canvas id="cube" width="200" height="200"></canvas>
</div>
<p class="result_container"></p>
</div>
</div>
</body>
</html>
<!-- vim: set ts=4 sw=4: -->