HTML5 2D game webgl?

2

I am aware that most of the 3D game engines for HTML5 use WebGL technology, but I had a question when it comes to 2D. Some 2D gaming engines for HTML5 refer to the gl_xxx functions, that is, they use GPU resources to draw 2D, but I have seen some tutorials that use examples where they do not seem to use anything related to WebGL, as if the rendering were done by the CPU, that's right?

When developing a game in 2D for HTML5, will it run on the GPU (via WebGL) or CPU (software rendering)? Or programmer who defines this? Links with examples of different ways to implement a 2D platform would be useful.

    
asked by anonymous 18.07.2014 / 20:20

1 answer

4

<canvas> defines a drawable region of the screen. You can then get a context that will define how the drawing will be done. We currently have two contextual APIs, the "2d" and the "webgl" . Both are different APIs for the same effect of drawing on the screen and much of what is done with one can be done with another.

As for using the GPU, this depends entirely on implementation. WebGL can be perfectly implemented via the CPU if the browser detects that the graphics card does not exist or is not enough. In the same way, the 2D API can make use of the GPU for parts of rendering. There is no limitation on this, it's a matter of implementation.

Chromium has made some changes in this direction around 2012: link

    
18.07.2014 / 20:35