Skip to Main Content
WebGL Insights
book

WebGL Insights

by Patrick Cozzi
August 2015
Intermediate to advanced content levelIntermediate to advanced
416 pages
16h 58m
English
A K Peters/CRC Press
Content preview from WebGL Insights
112 7. Teaching an Introductory Computer Graphics Course with WebGL
where gl is our WebGL context, we will get an error message because WebGL expects
asimple C-like array comprising oating-point numbers.
ere are two main ways to get around this problem. One is to use JS typed arrays,
which are equivalent to C-type arrays, as in the code:
var vertices = new Float32Array([
-0.5, -0.5,
-0.5, 0.5,
0.5, 0.5,
0.5, -0.5
]);
is method works with gl.buffe rData(). Typed arrays have become standard for
doing numerical applications with JavaScript as they are more ecient. ere are packages
such as glMatrix.js
*
for doing basic linear algebra with typed a
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

James L. Williams

Publisher Resources

ISBN: 9781498716079