square.html
1.45 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
<html>
<head>
<title>First very simple WebGL example...</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/square.js"></script>
<script id="square-vertex-shader" type="x-shader/x-vertex">
attribute vec3 vertexPos;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main(void) {
// Return the transformed and projected vertex value
gl_Position =
projectionMatrix * modelViewMatrix * vec4(vertexPos, 1.0);
}
</script>
<script id="square-fragment-shader" type="x-shader/x-fragment">
void main(void) {
// Return the pixel color: always output white
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
</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>First very simple WebGL example...</h1>
<p>
This is the beginning, not even 3D. Just initialize the
GL context and draw a square.
</p>
<h2>Result</h2>
<div class="gl">
<canvas id="square" width="200" height="200"></canvas>
</div>
<p class="result_container"></p>
</div>
</div>
</body>
</html>
<!-- vim: set ts=4 sw=4: -->