forked from efredericks/CIS367-ComputerGraphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotatingSquare2.html
More file actions
51 lines (40 loc) · 1.2 KB
/
rotatingSquare2.html
File metadata and controls
51 lines (40 loc) · 1.2 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
<!DOCTYPE html>
<html>
<title>Rotating Square</title>
<script id="vertex-shader" type="x-shader/x-vertex">
attribute vec4 vPosition;
uniform float theta;
void main()
{
float s = sin( theta );
float c = cos( theta );
gl_Position.x = -s * vPosition.y + c * vPosition.x;
gl_Position.y = s * vPosition.x + c * vPosition.y;
gl_Position.z = 0.0;
gl_Position.w = 1.0;
}
</script>
<script id="fragment-shader" type="x-shader/x-fragment">
precision mediump float;
void main()
{
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}
</script>
<script type="text/javascript" src="../Common/webgl-utils.js"></script>
<script type="text/javascript" src="../Common/initShaders.js"></script>
<script type="text/javascript" src="../Common/MV.js"></script>
<script type="text/javascript" src="rotatingSquare2.js"></script>
</head>
<body>
<button id="Direction">Change Rotation Direction</button>
<select id="Controls" size="3">
<option value="0">Toggle Rotation Direction</option>
<option value="1">Spin Faster</option>
<option value="2">Spin Slower</option>
</select>
<canvas id="gl-canvas" width="512" height="512">
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>
</body>
</html>