Re:WebGL Water
by petercooper on Wednesday February 19, 2014 @11:45AM
(#7264476)
WebGL is essentially a specialized OpenGL-ES based context of canvas. HTML5 canvas in its usual context is only for 2D. You can render 3D on it but you'll essentially be creating your own software rendering engine from scratch.
[ Parent
| on HN ]
So then my question is what is the future of WebGL?
I could see canvas extended to have 3D operations. Like say draw point takes 3 coordinates now. I can see a third party library that does 3D but projects it down to 2D and uses regular 2D commands on the canvas, or I see supporting WebGL interface and writing OpenGL style code.
> I could see canvas extended to have 3D operations. Like say draw point takes 3 coordinates now.
I think that's the role WebGL essentially fulfills. It was just done in a way that uses OpenGL instead of reinventing the wheel, since a 3D rendering engine is a non-trivial thing to build. In other words, you can do either:
var ctx = myCanvas.getContext('2d');
// ctx has the 2d api
var ctx = myCanvas.getContext('webgl');
// ctx has the webgl 3d api
> I can see a third party library that does 3D but projects it down to 2D and uses regular 2D commands on the canvas.I think it would be a lot slower. Either way there's a 3D rendering engine. Embedding the engine natively and having GPU speedups is a dominating factor.
> or I see supporting WebGL interface and writing OpenGL style code.
See first point above.
I think the suggestions of using a lib to get higher level stuff are good ones. For simple enough stuff, d3, or more complex whole game engines are available.
http://threejs.org/ may be relevant.