What is WebGL?
WebGL, short for Web Graphics Library, is the part of a browser that lets a web page draw interactive flat and three-dimensional graphics on the device's graphics chip, with no plug-in to install. It is an open standard that the Khronos Group keeps and every modern browser has. After Bingo, a free top-down arena brawler in the browser, draws with WebGL 2.
What WebGL does
WebGL is an interface a browser gives a page's canvas. The canvas is the box on a page that a script draws into, and WebGL is how the script draws graphics there.
Its maker describes it as a cross-platform, royalty-free open web standard for a low-level 3D graphics API based on OpenGL ES. It brings plugin-free 3D on the web, implemented right into the browser.
Because it closely follows OpenGL ES, it can use the graphics acceleration of the device's own hardware. The drawing runs on the graphics chip, the GPU, which handles that work at very high speed.
What WebGL draws mixes with the rest of the page, so text and buttons can sit over it.
How a page draws with WebGL
A WebGL program has two parts. One is control code written in JavaScript. The other is shader code, written in a language much like C.
The shaders reach the browser as text. The browser compiles them for the graphics chip, and the chip runs them for every corner of every shape and every pixel on the screen.
Writing WebGL by hand is complex, so libraries built on top of it make the job easier.
On Windows, Chrome and Firefox run WebGL through ANGLE, an open source layer that translates its calls into the graphics interface the system has.
Who keeps WebGL
WebGL is designed and maintained by the Khronos Group, a non-profit group. The browser makers are there too: Apple, Google, Microsoft and Mozilla, the makers of Safari, Chrome, Edge and Firefox, all members of its working group.
WebGL grew out of experiments with a three-dimensional canvas at Mozilla, before the Khronos Group took it on.
The two versions
They are WebGL 1.0, which exposes the OpenGL ES 2.0 feature set, and WebGL 2.0, which exposes the OpenGL ES 3.0 API.
The second version guarantees many features that were optional in the first, and adds new ones. Its specification took about four years to finish, and Firefox, Chrome and Opera were the first browsers to ship it.
All the major browsers support the second version now.
What a device needs for WebGL
Every modern browser has WebGL, but the device's graphics chip must support it as well.
So a page that draws with WebGL can fail to start on a device whose graphics chip lacks it, even in a new browser.
Keeping the browser up to date is the other half. Making a browser game run faster has that step and the others.
WebGL and WebGPU
WebGPU is the successor to WebGL. It works better with modern graphics chips, lets a page run general computations on the chip, works faster and reaches more advanced features of the chip.
Since WebGL appeared, the systems have gained newer graphics interfaces of their own, such as Apple's Metal and the Khronos Group's Vulkan, with many new features. No more updates are planned to OpenGL, and so to WebGL, so it will not gain those features. WebGPU will gain new features from here on.
WebGL is built wholly around drawing graphics to a canvas and handles general computations on the chip poorly. Those computations matter more and more, for example for machine learning.
WebGPU makes drawing each object much cheaper for the processor, and brings effects such as sharpening and depth of field.
How After Bingo uses WebGL
After Bingo is made with Unity, which builds the whole game for the browser, and its code runs there as WebAssembly.
It draws with WebGL 2 alone, so a browser or a device without the second version cannot run it.
Every frame of the arena, its fighters and their effects is drawn through WebGL on the device's graphics chip. The game makes its frames as often as the browser draws the page, with no frame rate of the game's own. Thirty or sixty frames a second says what the count of frames changes.
After Bingo draws every frame with WebGL, in the browser you already have: play a round.
Common questions
Do I need to install WebGL?
No. It is built into the browser, so a page draws with it with no plug-in to install.
Does every browser support WebGL?
Every modern browser does, but the device's graphics chip must support it too.
Does WebGL use the graphics card?
Yes. Its drawing runs on the device's graphics chip, the GPU, and it uses that hardware's graphics acceleration.
What is the difference between the two versions of WebGL?
The second version is based on a newer version of OpenGL ES, guarantees many features the first left optional, and adds new ones.
Is WebGL being replaced?
WebGPU is its successor, and no more updates are planned to WebGL, but every modern browser still has it.
Is WebGL only for games?
No. Pages use it for games, music videos, training and modelling tools, and virtual and augmented reality.
Sources
- WebGL, the Wikipedia article, checked on
- The Khronos Group, WebGL, checked on
- MDN Web Docs, WebGL: two- and three-dimensional graphics for the web, checked on
- MDN Web Docs, WebGPU API, checked on
Keep reading
- Guides to playing games in the browserPlain answers on games in the browser: saves, data, lag and speed, WebGL, controllers, touch, join codes, game nights, friends abroad and what words mean.
- Browser game vs app: what each costs youA browser game opens from a link with nothing to install; an app installs from a store and keeps its saves inside. Six ways they differ.
- Thirty or sixty frames a secondThirty or sixty frames a second: sixty look smoother and react sooner, thirty ask less of the device. Both side by side, as checked in November.
- Making a browser game run fasterClose the tabs and apps you are not using, turn off extensions, update the browser and play a laptop plugged in: what makes a browser game run faster.
- What a browser game isA browser game is a video game you play in a web browser with nothing to install, and most are free. What it is made of and what replaced Flash.
