HTML5 2D game webgl?

Asked

Viewed 77 times

2

I am aware that a lot of the 3D game engines for HTML5 use Webgl technology, but I had a question when it comes to 2D. Some 2D game engines for HTML5 reference the functions gl_xxx, IE, use GPU resources to draw 2D, but I saw some tutorials that use examples where they do not seem to use anything related to Webgl, as if the rendering was done by the CPU, that’s right?

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

1 answer

4


The <canvas> define a sketch 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 the fact of using the GPU, it depends completely on the implementation. Webgl can perfectly be implemented via CPU if the browser detects that the graphics card is missing or not sufficient. Similarly, the 2D API can make use of the GPU for parts of the rendering. There is no limitation on that, it is a question of implementation.

Chromium made some modifications to this effect around 2012: http://blog.chromium.org/2012/02/gpu-accelerating-2d-canvas-and-enabling.html

  • Great! Now searching google for "2d context vs webgl" I can remove my doubts.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.