Spinning Cube in WebGL

My favourite first OpenGL program, this time in JavaScript. Based on code from the wonderful Learning WebGL site, with extras from the book OpenGL Insights.

When I wrote this in 2012 I had a list of which platforms and browsers would work, which would work if you tinkered with config settings, and which would not. Now in 2016 most browsers run WebGL out of the box.

Does it have to be this hard?

In the 1990s, a 3D cube in VRML needed 32 lines of code.

In the 2000s, a 3D cube in Microsoft XAML needed 76 lines of code.

With WebGL we need 2,277 lines of code. This is not progress!

Thankfully there is an excellent higher level library three.js which everyone seems to use now. It's really good. (I was pleasantly surprised to find that a more recent WebGL tutorial used my cube code as a cautionary example of how hard things are if you don't use three.js!)

I gave a talk about the past and possible future of the 3D Web back in 2013. Reviewing it in 2016, most of it is still valid.