forked from imindseye/WebGL-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsimple-triangles1.html
More file actions
49 lines (33 loc) · 1.12 KB
/
Copy pathsimple-triangles1.html
File metadata and controls
49 lines (33 loc) · 1.12 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
<!DOCTYPE html>
<html>
<head>
<title>hwshen WebGL — Simple Triangles </title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- ************** Fragment Shader ************* -->
<script id="shader-fs" type="x-shader/x-fragment">
void main(void) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // set all fragments to red
}
</script>
<!-- ************** Vertex Shader ************* -->
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
uniform float offX;
uniform float offY;
void main(void) {
gl_Position = vec4(
aVertexPosition.x + offX,
aVertexPosition.y + offY,
aVertexPosition.z,
1.0);
}
// by pass the vertex coordinates; all need to be in [-1,-1] to be vislble
</script>
<script type="text/javascript" src="shaders_setup.js"></script>
<script type="text/javascript" src="simple-triangles1.js"></script>
</head>
<body onload="webGLStart();">
<canvas id="code00-canvas" style="border: none;" width="700" height="500"></canvas>
<br/>
</body>
</html>