-
Notifications
You must be signed in to change notification settings - Fork 0
/
webGL.html
executable file
·244 lines (189 loc) · 11.2 KB
/
webGL.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="description" content="These are the personal webpages of Michiel Kleinnijenhuis: researcher in the field of MRI methods and brain plasticity"/>
<meta name="keywords" content="Michiel Kleinnijenhuis, Magnetic Resonance Imaging, MRI, Diffusion Weighted Imaging, DWI, diffusion MRI, dMRI, Susceptibility, Structure Tensor Informed Fiber Tractography, STIFT, neuroanatomy, neuroscience"/>
<meta name=viewport content="width=device-width, initial-scale=1">
<link href="style/style.css" rel="stylesheet" type="text/css"/>
<link href="http://fonts.googleapis.com/css?family=Prosto+One&subset=latin,latin-ext" rel="stylesheet" type="text/css"/>
<link href="MKleinnijenhuis-icon.jpg" rel="shortcut icon" type="icon" />
<title>projects - Michiel Kleinnijenhuis</title>
<!--Google Analytics-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41119042-1', 'diskstation.me');
ga('send', 'pageview');
</script>
<!--Menu-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<!--<link rel="stylesheet" type="text/css" href="jkmegamenu.css" />-->
<script type="text/javascript" src="jkmegamenu.js">
/***********************************************
* jQuery Mega Menu- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("menuLinkActive", "megamenu1", "mouseover")
</script>
<script type="text/javascript">
//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("menuLinkPublications", "megamenu2", "mouseover")
</script>
<script type="text/javascript">
//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("menuLinkPhDThesis", "megamenu3", "mouseover")
</script>
<!-- Start WOWSlider.com HEAD section -->
<link rel="stylesheet" type="text/css" href="engine1//style.css" media="screen" />
<script type="text/javascript" src="engine1//jquery.js"></script>
<!-- End WOWSlider.com HEAD section -->
</head>
<body id="pagetop">
<div id="page">
<div id="header">
<img id="header-img" src="hdr/MKleinnijenhuis_Portrait.jpg" alt="Michiel" width="80" height="74"/>
<div id="header-quote">
<i>Learning never exhausts the mind.</i> --- Leonardo da Vinci
</div>
<h1 id="header-title">Michiel Kleinnijenhuis</h1>
<div id="header-menu">
<a class="menuLink" id="menuLinkActive" href="projects.html">projects</a>
<div id="megamenu1" class="megamenu">
<div class="column"><ul>
<li><a href="projects.html#Project16" title="Jump to Project16">3D electron microscopy</a></li>
<li><a href="projects.html#Project15" title="Jump to Project15">polarized light imaging</a></li>
<li><a href="projects.html#Project14" title="Jump to Project14">cerebellar white matter atlas</a></li>
<li><a href="projects.html#Project13" title="Jump to Project13">diffusion along axons</a></li>
<li><a href="projects.html#Project12" title="Jump to Project12">MR methods for plasticity</a></li>
<li><a href="projects.html#Project11" title="Jump to Project11">DTI of gyrencephaly</a></li>
<li><a href="projects.html#Project10" title="Jump to Project10">tractography validation</a></li>
<li><a href="projects.html#Project09" title="Jump to Project09">cortical fibre architecture</a></li>
<li><a href="projects.html#Project08" title="Jump to Project08">dissection and plastination for education</a></li>
<li><a href="projects.html#Project07" title="Jump to Project07">diffusion MR microscopy of the neocortex</a></li>
<li><a href="projects.html#Project06" title="Jump to Project06">mouse brain diffusion imaging</a></li>
<li><a href="projects.html#Project05" title="Jump to Project05">structure tensor informed fibre tractography (STIFT)</a></li>
<li><a href="projects.html#Project04" title="Jump to Project04">real-life neurofeedback</a></li>
<li><a href="projects.html#Project03" title="Jump to Project03">brain-computer interfacing</a></li>
<li><a href="projects.html#Project02" title="Jump to Project02">high definition encephalography</a></li>
<li><a href="projects.html#Project01" title="Jump to Project01">photoacoustic mammography</a></li>
</ul></div>
</div>
<a class="menuLink" id="menuLinkPublications" href="publications.html">publications</a>
<div id="megamenu2" class="megamenu">
<div class="column"><ul>
<li><a href="publications.html#Papers" title="Jump to Papers">papers</a></li>
<li><a href="publications.html#Proceedings" title="Jump to Proceedings">proceedings</a></li>
<li><a href="publications.html#BookChapters" title="Jump to Book chapters">book chapters</a></li>
<li><a href="publications.html#Patents" title="Jump to Patents">patents</a></li>
<li><a href="publications.html#Theses" title="Jump to Theses">theses</a></li>
</ul></div>
</div>
<a class="menuLink" id="menuLinkPhDThesis" href="phdthesis.html">phd thesis</a>
<div id="megamenu3" class="megamenu">
<div class="column"><ul>
<li><a href="phdthesis.html#Cover" title="Jump to Cover">cover and title pages</a></li>
<li><a href="phdthesis.html#Chapter01" title="Jump to Chapter 1">chapter 1: introduction</a></li>
<li><a href="phdthesis.html#Chapter02" title="Jump to Chapter 2">chapter 2: history of connectional neuroanatomy</a></li>
<li><a href="phdthesis.html#Chapter03" title="Jump to Chapter 3">chapter 3: MRI of fibre architecture</a></li>
<li><a href="phdthesis.html#Chapter04" title="Jump to Chapter 4">chapter 4: STIFT</a></li>
<li><a href="phdthesis.html#Chapter05" title="Jump to Chapter 5">chapter 5: layer-specific DWI in human V1</a></li>
<li><a href="phdthesis.html#Chapter06" title="Jump to Chapter 6">chapter 6: fibres in the gyrus</a></li>
<li><a href="phdthesis.html#Chapter07" title="Jump to Chapter 7">chapter 7: DTI of gyrencephaly at 7T</a></li>
<li><a href="phdthesis.html#Chapter08" title="Jump to Chapter 8">chapter 8: dissection, plastination, tractography</a></li>
<li><a href="phdthesis.html#Chapter09" title="Jump to Chapter 9">chapter 9: discussion and conclusions</a></li>
<li><a href="phdthesis.html#Bibliography" title="Jump to Bibliography">bibliography</a></li>
<li><a href="phdthesis.html#Summary" title="Jump to Summary">summary</a></li>
<li><a href="phdthesis.html#NederlandseSamenvatting" title="Jump to Nederlandse samenvatting">nederlandse samenvatting</a></li>
<li><a href="phdthesis.html#AcknowledgementsDankwoord" title="Jump to Acknowledgements / Dankwoord">acknowledgements / dankwoord</a></li>
<li><a href="phdthesis.html#ListOfPublications" title="Jump to List of publications">list of publications</a></li>
<li><a href="phdthesis.html#CurriculumVitae" title="Jump to Curriculum Vitae">curriculum vitae</a></li>
<li><a href="phdthesis.html#DondersSeries" title="Jump to Donders Series">donders series</a></li>
<li><a href="phdthesis.html#SupplementaryMaterial" title="Jump to Supplementary Material">supplementary material</a></li>
</ul></div>
</div>
<a class="menuLink" href="contact.html">about me</a>
<div style="clear:both;"></div>
</div>
</div>
<hr>
<div id="content">
<canvas width = "300" height = "300" id = "my_Canvas"></canvas>
<script>
/* Step1: Prepare the canvas and get WebGL context */
var canvas = document.getElementById('my_Canvas');
var gl = canvas.getContext('experimental-webgl');
/* Step2: Define the geometry and store it in buffer objects */
var vertices = [-0.5, 0.5, -0.5, -0.5, 0.0, -0.5,];
// Create a new buffer object
var vertex_buffer = gl.createBuffer();
// Bind an empty array buffer to it
gl.bindBuffer(gl.ARRAY_BUFFER, vertex_buffer);
// Pass the vertices data to the buffer
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
// Unbind the buffer
gl.bindBuffer(gl.ARRAY_BUFFER, null);
/* Step3: Create and compile Shader programs */
// Vertex shader source code
var vertCode =
'attribute vec2 coordinates;' +
'void main(void) {' + ' gl_Position = vec4(coordinates,0.0, 1.0);' + '}';
//Create a vertex shader object
var vertShader = gl.createShader(gl.VERTEX_SHADER);
//Attach vertex shader source code
gl.shaderSource(vertShader, vertCode);
//Compile the vertex shader
gl.compileShader(vertShader);
//Fragment shader source code
var fragCode = 'void main(void) {' + 'gl_FragColor = vec4(0.0, 0.0, 0.0, 0.1);' + '}';
// Create fragment shader object
var fragShader = gl.createShader(gl.FRAGMENT_SHADER);
// Attach fragment shader source code
gl.shaderSource(fragShader, fragCode);
// Compile the fragment shader
gl.compileShader(fragShader);
// Create a shader program object to store combined shader program
var shaderProgram = gl.createProgram();
// Attach a vertex shader
gl.attachShader(shaderProgram, vertShader);
// Attach a fragment shader
gl.attachShader(shaderProgram, fragShader);
// Link both programs
gl.linkProgram(shaderProgram);
// Use the combined shader program object
gl.useProgram(shaderProgram);
/* Step 4: Associate the shader programs to buffer objects */
//Bind vertex buffer object
gl.bindBuffer(gl.ARRAY_BUFFER, vertex_buffer);
//Get the attribute location
var coord = gl.getAttribLocation(shaderProgram, "coordinates");
//point an attribute to the currently bound VBO
gl.vertexAttribPointer(coord, 2, gl.FLOAT, false, 0, 0);
//Enable the attribute
gl.enableVertexAttribArray(coord);
/* Step5: Drawing the required object (triangle) */
// Clear the canvas
gl.clearColor(0.5, 0.5, 0.5, 0.9);
// Enable the depth test
gl.enable(gl.DEPTH_TEST);
// Clear the color buffer bit
gl.clear(gl.COLOR_BUFFER_BIT);
// Set the view port
gl.viewport(0,0,canvas.width,canvas.height);
// Draw the triangle
gl.drawArrays(gl.TRIANGLES, 0, 3);
</script>
</canvas>
</div>
<div id="footer">
<address><hr>© Michiel Kleinnijenhuis --- edited: 2016/04/07 --- </address>
</div>
</div>
</body>
</html>