forked from jsx/JSX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello-webgl.html
More file actions
101 lines (91 loc) · 2.91 KB
/
Copy pathhello-webgl.html
File metadata and controls
101 lines (91 loc) · 2.91 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello, WebGL!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="../jsx.combined.js"></script>
<script src="../assets/js/jsx-browser-platform.js"></script>
<script src="../assets/js/jsx-script-loader.js"></script>
<script type="application/jsx" src="hello-webgl.jsx"></script>
<script>
window.addEventListener("DOMContentLoaded", function(e) {
document.getElementById("run").addEventListener("click", function(e) {
e.preventDefault();
e.stopPropagation();
JSX.require("hello-webgl.jsx").Hello.main$();
});
});
</script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">JSX</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="/">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span8">
<h2>Hello, WebGL!</h2>
</div>
</div>
<div class="row">
<div class="span8">
<p><a class="btn btn-primary btn-large" id="run">Run the script</a></p>
</div>
</div>
<!-- for WebGL -->
<canvas id='webgl-canvas' width='256px' height='256px'></canvas>
<script id='vshader' type='x-shader/x-vertex'>
precision mediump float;
uniform float angle;
attribute vec2 position;
attribute vec2 texcoord;
varying vec2 v_texcoord;
void main() {
v_texcoord = texcoord;
float x = position.x;
float y = position.y;
float s = sin(angle);
float c = cos(angle);
gl_Position = vec4(x*c-y*s, x*s+y*c, 0.0, 1.0);
}
</script>
<script id='fshader' type='x-shader/x-fragment'>
precision mediump float;
uniform sampler2D tex;
varying vec2 v_texcoord;
void main() {
gl_FragColor = texture2D(tex, v_texcoord.xy);
}
</script>
</div> <!-- /container -->
</body>
</html>