...Back to blog index

Using glMatrix 2.0+ with the Book Code

The version of the glMatrix library I used when writing the book was 1.3.2. The current version which you grabbed is 2.0+. It is mentioned at http://glmatrix.net/ that the newer version is unfortunately not backwards compatible.

The fixes to use the new version is usually adding an extra function argument such as changing:

function setupWebGL()
{
    ...
    mat4.perspective(45, canvas.width / canvas.height, 0.1, 100.0, pMatrix);
    mat4.identity(mvMatrix);
    mat4.translate(mvMatrix, [0, 0, -2.0]);              
    ...
}

To:

function setupWebGL()
{
    ...
    mat4.perspective(pMatrix, 45, canvas.width / canvas.height, 0.1, 100.0, pMatrix);
    mat4.identity(mvMatrix);
    mat4.translate(mvMatrix, mvMatrix, [0, 0, -2.0]);
    ...
}

I will list multiple versions of the code when I get a chance.

...Back to blog index

comments powered by Disqus