Wiki
Clarifications for Angel's Interactive Computer Graphics

Chapter 3 (Worksheet 2)
Page last edited by Jeppe Revall Frisvad (jerf) 18/09-2017

In Sec. 3.7, a vec2, vec3, or vec4 needs to be flattened before being supplied as an argument to gl.bufferSubData. The lines of code in Sec. 3.7 that call this GL function should have been

gl.bufferSubData(gl.ARRAY_BUFFER, sizeof['vec2']*index, flatten(t));

and

gl.bufferSubData(gl.ARRAY_BUFFER, sizeof['vec4']*index, flatten(t));

as in Sec. 3.10.

In the same section, the function for requesting an animation frame need not be

window.requestAnimFrame(render, canvas);

but can simply be

requestAnimFrame(render);

as in Sec. 3.1.5.

Finally, some browsers (such as Firefox) require that event is added as an argument in the definition of the event listener function. To do this, use

canvas.addEventListener("click", function(event) { [your code] });

instead of the function with an empty argument list prescribed in the book. When doing this, you can also decide yourself what the event object should be called.

Support: +45 45 25 74 43