Is there any reason, except performance, for using WebGL instead of 2D-Canvas for 2D games/apps?
In other word what 2D functionalities are offered by WebGL which are not possible to achieve easily with 2D-Canvas?
Talking of the speed factor, Canvas slows down to its components. WebGL is greater than Canvas in terms of speed. Generally preferred for 2D rendering and works related. More preferred for 3d though it can also work on 2D.
Canvas is slower because it's generic and therefore is hard to optimize to the same level that you can optimize WebGL.
WebGL is blindingly fast and fully utilizes hardware acceleration, making it suitable for games or complex visualizations. Although other options can benefit from hardware acceleration, WebGL is written with performance in mind and should perform better than other options in many cases.
WebGL enables web content to use an API based on OpenGL ES 2.0 to perform 2D and 3D rendering in an HTML canvas in browsers that support it without the use of plug-ins.
Looking at this question from another side:
how does a developer choose one technology over another?
So I'll discuss the differences between canvas and webGL APIs regarding these qualities.
Both canvas and webGL are JavaScript APIs. They are pretty much the same regarding integration (binding). They are both supported by a number of libraries that could speed up your coding. Different libraries give you different ways to organize your code, so library choice dictates how your drawing APIs are structured, but it's still pretty much the same thing (how the rest of the code binds together with it). If you use library, the ease of writing code depends on the library itself.
If you write code from zero, the canvas API is much easier to learn and understand. It requires minimal math knowledge, and development is fast and straightforward.
Working with the WebGL API requires strong math skills and a full understanding of the rendering pipeline. People with these skills are harder to find, production is slower (due to the size and complexity of such a code base), and therefore it costs more.
WebGL is faster and it has more capabilities. No doubt about that. It's a native 3D API that gives you full access to the rendering pipeline, code and effects are executed faster and are more 'tweakable'. With webGL there really is no limit.
Both canvas and webGL are html5 goodies. Usually the devices that support one will support and the other.
So, to sum up:
Hope this helps.
P. S. Open for discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With