WebGL (short for Web Graphics Library) is a
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
for rendering interactive 2D and 3D graphics within any compatible
web browser
A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
without the use of
plug-ins.
WebGL is fully integrated with other
web standards, allowing
GPU-accelerated usage of physics, image processing, and effects in the
HTML
Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
canvas
Canvas is an extremely durable Plain weave, plain-woven Cloth, fabric used for making sails, tents, Tent#Marquees and larger tents, marquees, backpacks, Shelter (building), shelters, as a Support (art), support for oil painting and for other ite ...
. WebGL elements can be mixed with other HTML elements and composited with other parts of the page or page background.
WebGL programs consist of control code written in JavaScript, and
shader
In computer graphics, a shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene—a process known as '' shading''. Shaders have evolved to perform a variety of s ...
code written in
OpenGL ES Shading Language (GLSL ES, sometimes referred to as ESSL), a language similar to
C or
C++. WebGL code is executed on a computer's GPU.
WebGL is designed and maintained by the
non-profit
A nonprofit organization (NPO), also known as a nonbusiness entity, nonprofit institution, not-for-profit organization, or simply a nonprofit, is a non-governmental (private) legal entity organized and operated for a collective, public, or so ...
Khronos Group
The Khronos Group, Inc. is an open, non-profit, member-driven consortium of 170 organizations developing, publishing and maintaining royalty-free interoperability standards for 3D graphics, virtual reality, augmented reality, parallel computat ...
.
On February 9, 2022, Khronos Group announced WebGL 2.0 support from all major browsers.
From 2024, a new graphics API,
WebGPU
WebGPU API is a JavaScript, Rust, C++, and C API for cross-platform efficient graphics processing unit (GPU) access. Using a system's underlying Vulkan, Metal, or Direct3D 12 technologies, WebGPU allows for graphics processing, games, and mor ...
, is being developed to supersede WebGL. WebGPU provides extended capabilities, a more modern interface, and direct GPU access, which is useful for demanding graphics as well as AI applications.
Design
WebGL 1.0 is based on
OpenGL ES 2.0 and provides an
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
for 3D graphics.
[ It uses the ]HTML5
HTML5 (Hypertext Markup Language 5) is a markup language used for structuring and presenting hypertext documents on the World Wide Web. It was the fifth and final major HTML version that is now a retired World Wide Web Consortium (W3C) recommend ...
canvas element
The HTML canvas element allows for dynamic, scriptable rendering of 2D shapes and bitmap images. Introduced in HTML5, it is a low level, procedural model that updates a bitmap. The element also helps in making 2D games.
While the element ...
and is accessed using Document Object Model
The Document Object Model (DOM) is a cros s-platform and language-independent API that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with ...
(DOM) interfaces.
WebGL 2.0 is based on OpenGL ES 3.0. It guarantees the availability of many optional extensions of WebGL 1.0, and exposes new APIs.[ ]Automatic memory management
In computer science, garbage collection (GC) is a form of automatic memory management. The ''garbage collector'' attempts to reclaim memory that was allocated by the program, but is no longer referenced; such memory is called ''garbage''. Gar ...
is provided implicitly by JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
.
Like OpenGL ES 2.0, WebGL lacks the fixed-function APIs introduced in OpenGL 1.0 and deprecated in OpenGL 3.0. This functionality, if required, has to be implemented by the developer using shader code and JavaScript.
Shaders in WebGL are written in GLSL and passed to the WebGL API as text strings. The WebGL implementation compiles these strings to GPU code. This code is executed for each vertex sent through the API and for each pixel rasterized to the screen.
History
WebGL evolved out of the Canvas 3D experiments started by Vladimir Vukićević at Mozilla
Mozilla is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, publishes and supports Mozilla products, thereby promoting free software and open standards. The community is supported institution ...
. Vukićević first demonstrated a Canvas 3D prototype in 2006. By the end of 2007, both Mozilla and Opera had made their own separate implementations.
In early 2009, the non-profit
A nonprofit organization (NPO), also known as a nonbusiness entity, nonprofit institution, not-for-profit organization, or simply a nonprofit, is a non-governmental (private) legal entity organized and operated for a collective, public, or so ...
technology consortium
A consortium () is an association of two or more individuals, companies, organizations, or governments (or any combination of these entities) with the objective of participating in a common activity or pooling their resources for achieving a ...
Khronos Group
The Khronos Group, Inc. is an open, non-profit, member-driven consortium of 170 organizations developing, publishing and maintaining royalty-free interoperability standards for 3D graphics, virtual reality, augmented reality, parallel computat ...
started the WebGL Working Group, with initial participation from Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
, Google
Google LLC (, ) is an American multinational corporation and technology company focusing on online advertising, search engine technology, cloud computing, computer software, quantum computing, e-commerce, consumer electronics, and artificial ...
, Mozilla, Opera
Opera is a form of History of theatre#European theatre, Western theatre in which music is a fundamental component and dramatic roles are taken by Singing, singers. Such a "work" (the literal translation of the Italian word "opera") is typically ...
, and others.[ Version 1.0 of the WebGL specification was released March 2011.][
An early application of WebGL was Zygote Body. In November 2012 ]Autodesk
Autodesk, Inc. is an American multinational software corporation that provides software products and services for the architecture, engineering, construction, manufacturing, media, education, and entertainment industries. Autodesk is headquarte ...
announced that they ported most of their applications to the cloud running on local WebGL clients. These applications included Fusion 360 and AutoCAD 360.
Development of the WebGL 2 specification started in 2013 and finished in January 2017. The specification is based on OpenGL ES 3.0.
First implementations are in Firefox 51, Chrome 56 and Opera 43.
Implementations
Almost Native Graphics Layer Engine
Almost Native Graphics Layer Engine (ANGLE) is an open source graphic engine which implements WebGL 1.0 (2.0 which closely conforms to ES 3.0) and OpenGL ES
OpenGL for Embedded Systems (OpenGL ES or GLES) is a subset of the OpenGL computer graphics rendering application programming interface (API) for rendering 2D and 3D computer graphics such as those used by video games, typically hardware-accelerate ...
2.0 and 3.0 standards. It is a default backend for both Google Chrome and Mozilla Firefox on Windows platforms and works by translating WebGL and OpenGL calls to available platform-specific APIs. ANGLE currently provides access to OpenGL ES 2.0 and 3.0 to desktop OpenGL, OpenGL ES, Direct3D
Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
9, and Direct3D 11 APIs. ″ oogle''Chrome uses ANGLE for all graphics rendering on Windows, including the accelerated Canvas2D implementation and the Native Client sandbox environment.″''
Software
WebGL is widely supported by modern browsers. However, its availability depends on other factors, too, like whether the GPU supports it. The official WebGL website offers a simple test page. More detailed information (like what renderer the browser uses, and what extensions are available) can be found at third-party websites.
Desktop browsers
* Google Chrome
Google Chrome is a web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, iOS, iPadOS, an ...
– WebGL 1.0 has been enabled on all platforms that have a capable graphics card with updated drivers since version 9, released in February 2011. By default on Windows, Chrome uses the ANGLE
In Euclidean geometry, an angle can refer to a number of concepts relating to the intersection of two straight Line (geometry), lines at a Point (geometry), point. Formally, an angle is a figure lying in a Euclidean plane, plane formed by two R ...
(Almost Native Graphics Layer Engine) renderer to translate OpenGL ES to Direct X 9.0c or 11.0, which have better driver support. However, on Linux and Mac OS X, the default renderer is OpenGL. It is also possible to force OpenGL as the renderer on Windows. Since September 2013, Chrome also has a newer Direct3D
Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
11 renderer, which requires a newer graphics card. Chrome 56+ supports WebGL 2.0.
* Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
– WebGL 1.0 has been enabled on all platforms that have a capable graphics card with updated drivers since version 4.0. Since 2013 Firefox also uses DirectX
Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct" ...
on the Windows platform via ANGLE
In Euclidean geometry, an angle can refer to a number of concepts relating to the intersection of two straight Line (geometry), lines at a Point (geometry), point. Formally, an angle is a figure lying in a Euclidean plane, plane formed by two R ...
. Firefox 51+ supports WebGL 2.0.
* Safari
A safari (; originally ) is an overland journey to observe wildlife, wild animals, especially in East Africa. The so-called big five game, "Big Five" game animals of Africa – lion, African leopard, leopard, rhinoceros, African elephant, elep ...
– Safari 6.0 and newer versions installed on OS X Mountain Lion
OS X Mountain Lion (version 10.8) is the ninth major release of macOS, Apple Inc.'s desktop and server operating system for Macintosh computers. OS X Mountain Lion was released on July 25, 2012, for purchase and download through the Mac App S ...
, Mac OS X Lion and Safari 5.1 on Mac OS X Snow Leopard
Mac OS X Snow Leopard (version 10.6) (also referred to as OS X Snow Leopard) is the seventh major release of macOS, Apple's desktop and server operating system for Macintosh computers.
Snow Leopard was publicly unveiled on June 8, 2009, at A ...
implemented support for WebGL 1.0, which was disabled by default before Safari 8.0. Safari version 12 (available in MacOS Mojave) has available support for WebGL 2.0 as an "Experimental" feature. Safari 15 enables WebGL 2.0 for all users.
* Opera
Opera is a form of History of theatre#European theatre, Western theatre in which music is a fundamental component and dramatic roles are taken by Singing, singers. Such a "work" (the literal translation of the Italian word "opera") is typically ...
– WebGL 1.0 has been implemented in Opera 11 and 12, but was disabled by default in 2014. Opera 43+ supports WebGL 2.0.
* Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated as IE or MSIE) is a deprecation, retired series of graphical user interface, graphical web browsers developed by Microsoft that were u ...
– WebGL 1.0 is partially supported in Internet Explorer 11
Internet Explorer 11 (IE11) is the eleventh and final version of the Internet Explorer web browser, by now retired. It was initially included in the release of Windows 8.1, Windows RT, Windows RT 8.1 and Windows Server 2012 R2 on October 17, 2013 ...
. Internet Explorer initially failed most of the official WebGL conformance tests, but Microsoft later released several updates. The latest 0.94 WebGL engine currently passes ≈97% of Khronos tests. WebGL support can also be manually added to earlier versions of Internet Explorer using third-party plugins such as IEWebGL.
* Microsoft Edge
Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
– For Microsoft Edge Legacy, the initial stable release supports WebGL version 0.95 (context name: "experimental-webgl") with an open source GLSL to HLSL
The High-Level Shader Language or High-Level Shading Language (HLSL) is a proprietary shading language developed by Microsoft for the Direct3D 9 API to augment the shader assembly language, and went on to become the required shading language ...
transpiler. Version 10240+ supports WebGL 1.0 as prefixed. Latest Chromium-based Edge supports WebGL 2.0.
Mobile browsers
* Google Chrome
Google Chrome is a web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, iOS, iPadOS, an ...
– WebGL 1.0 is supported on Android as of Chrome 25. WebGL 2.0 is supported on Android as of Chrome 114. Chrome is used for the Android system webview as of Android 5.
* BlackBerry 10
BlackBerry 10 (BB10) is a proprietary mobile operating system for the BlackBerry line of smartphones, both developed by BlackBerry Limited (formerly known as Research In Motion). Released in January 2013, BlackBerry 10 is a complete rework from t ...
– WebGL 1.0 is available for BlackBerry devices since OS version 10.00
* BlackBerry PlayBook
The BlackBerry PlayBook is a mini tablet computer that was developed by BlackBerry. It was manufactured by Quanta Computer, an original design manufacturer (ODM). – WebGL 1.0 is available via WebWorks and browser in PlayBook OS 2.00
* Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated as IE or MSIE) is a deprecation, retired series of graphical user interface, graphical web browsers developed by Microsoft that were u ...
– Prefixed WebGL 1.0 is available on Windows Phone
Windows Phone (WP) is a discontinued mobile operating system developed by Microsoft Mobile for smartphones as the replacement successor to Windows Mobile and Zune. Windows Phone featured a new user interface derived from the Metro design languag ...
8.x (11+)
* Firefox for mobile – WebGL 1.0 is available for Android and MeeGo devices since Firefox 4.
* Firefox OS
Firefox OS (project name: ''Boot to Gecko'', also known as ''B2G'') is a discontinued Open-source software, open-source operating system made for smartphones, tablet computers, smart TVs, and Matchstick TV, dongles designed by Mozilla and exte ...
* Maemo
Maemo is a Linux-based software platform originally developed by Nokia, now developed by the Free software movement, community, for smartphones and Internet tablets. The platform comprises both the Maemo operating system and Software development ...
– In Nokia N900
The Nokia N900 is a smartphone made by Nokia, launched at Nokia World on 2 September 2009 and released in November. Superseding the Nokia N810, the N900's default operating system, Maemo 5, is a Linux-based OS originally developed for the Nokia ...
, WebGL 1.0 is available in the stock microB browser from the PR1.2 firmware update onwards.
* MeeGo
MeeGo is a discontinued Linux distribution hosted by the Linux Foundation, using source code from the operating systems Moblin (produced by Intel) and Maemo (produced by Nokia). MeeGo was primarily targeted at mobile devices and information app ...
– WebGL 1.0 is unsupported in the stock browser "Web." However, it is available through Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
.
* Microsoft Edge
Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
– Prefixed WebGL 1.0 is available on Windows 10 Mobile.
* Opera Mobile – Opera Mobile 12 supports WebGL 1.0 (on Android only).
* Safari
A safari (; originally ) is an overland journey to observe wildlife, wild animals, especially in East Africa. The so-called big five game, "Big Five" game animals of Africa – lion, African leopard, leopard, rhinoceros, African elephant, elep ...
on iOS
Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
– WebGL 1.0 is available for mobile Safari in iOS 8
iOS 8 is the eighth major release of the iOS mobile operating system developed by Apple Inc., being the successor to iOS 7. It was announced at the company's Worldwide Developers Conference on June 2, 2014, and was released on September 17 ...
. WebGL 2.0 is available for mobile Safari in iOS 15.
* Sailfish OS – WebGL 1.0 is supported in the default Sailfish browser.
* Tizen
Tizen () is a Linux-based operating system primarily developed by Samsung Electronics and supported by the Linux Foundation.
The project was originally conceived as an HTML5-based platform for mobile devices to succeed MeeGo. It was backed by o ...
– WebGL 1.0 is supported
Tools and ecosystem
Utilities
The low-level nature of the WebGL API, which provides little on its own to quickly create desirable 3D graphics, motivated the creation of higher-level libraries that abstract common operations (e.g. loading scene graphs and 3D objects in certain formats; applying linear transformations
In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that pr ...
to shader
In computer graphics, a shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene—a process known as '' shading''. Shaders have evolved to perform a variety of s ...
s or view frustums). Some such libraries were ported to JavaScript from other languages. Examples of libraries that provide high-level features include A-Frame (VR), BabylonJS, PlayCanvas, three.js, OSG.JS, Google
Google LLC (, ) is an American multinational corporation and technology company focusing on online advertising, search engine technology, cloud computing, computer software, quantum computing, e-commerce, consumer electronics, and artificial ...
’s model-viewer and CopperLicht. Web3D also made a project called X3DOM to make X3D and VRML content run on WebGL.
Games
There has been an emergence of 2D and 3D game engine
A game engine is a software framework primarily designed for the development of video games which generally includes relevant libraries and support programs such as a level editor. The "engine" terminology is akin to the term " software engine" u ...
s for WebGL, such as Unreal Engine
Unreal Engine (UE) is a 3D computer graphics game engine developed by Epic Games, first showcased in the 1998 first-person shooter video game '' Unreal''. Initially developed for PC first-person shooters, it has since been used in a variety of ...
4 and Unity. The Stage3D
Stage3D (codenamed ''Molehill'') is an Adobe Flash Player API for rendering interactive 3D graphics with GPU-acceleration, within Flash games and applications. Flash Player or AIR applications written in ActionScript 3 may use Stage3D to render ...
/Flash-based Away3D
Away3D is an open-source platform for developing interactive 3D graphics for video games and applications, in Adobe Flash or HTML5. The platform consists of a 3D world editor (Away Builder), high-level library also has a port to WebGL via TypeScript
TypeScript (abbreviated as TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications and transpiles to JavaScript. It is developed by Micr ...
. A more light-weight utility library that provides just the vector and matrix math utilities for shaders is sylvester.js. It is sometimes used in conjunction with a WebGL specific extension called glUtils.js.
There are also some 2D libraries built atop WebGL, like Cocos2d-x or Pixi.js, which were implemented this way for performance reasons in a move that parallels what happened with the Starling Framework
Starling is an open source game framework used to create 2D games that run both on mobile and desktop platforms. It recreates the traditional Flash display list architecture on top of accelerated graphics hardware. Several commercial games hav ...
over Stage3D in the Flash world. The WebGL-based 2D libraries fall back to HTML5 canvas when WebGL is not available. Removing the rendering bottleneck by giving almost direct access to the GPU has exposed performance limitations in the JavaScript implementations. Some were addressed by asm.js and WebAssembly
WebAssembly (Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating communication between such programs and their host environment.
The main goal of ...
(similarly, the introduction of Stage3D exposed performance problems within ActionScript
ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (later acquired by Adobe). It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript (mean ...
, which were addressed by projects like CrossBridge).
Content creation
As with any other graphics API, creating content for WebGL scenes requires using a 3D content creation tool and exporting the scene to a format that is readable by the viewer or helper library. Desktop 3D authoring software such as Blender, Autodesk Maya
Autodesk Maya, commonly shortened to just Maya (; ), is a 3D computer graphics application that runs on Windows, macOS, and Linux, originally developed by Alias and currently owned and developed by Autodesk. It is used to create assets for inter ...
or SimLab Composer can be used for this purpose. In particular, Blend4Web allows a WebGL scene to be authored entirely in Blender and exported to a browser with a single click, even as a standalone web page. There are also some WebGL-specific software such as CopperCube and the online WebGL-based editor Clara.io
Clara.io is web-based freemium 3D computer graphics software developed by Exocortex, a Canadian software company. The free or "Basic" component of their freemium offering, however, places severe restrictions, such as on saving models and importing ...
. Online platforms such as Sketchfab
Sketchfab is a 3D asset website used to publish, share, discover, buy and sell 3D model, 3D, Virtual reality, VR and Augmented reality, AR content. It provides a viewer based on the WebGL and WebXR technologies that allows users to display 3D m ...
and Clara.io allow users to directly upload their 3D models and display them using a hosted WebGL viewer.
Environment-based tools
Starting from Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
Version 27, Mozilla
Mozilla is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, publishes and supports Mozilla products, thereby promoting free software and open standards. The community is supported institution ...
has given Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
built-in WebGL tools that allow the editing of vertices and fragment shaders. A number of other debugging and profiling tools have also emerged.
See also
* List of WebGL frameworks
* Experience Curiosity – WebGL simulation of the Mars rover ''Curiosity''
* glTF
glTF (Graphics Library Transmission Format or GL Transmission Format and formerly known as WebGL Transmissions Format or WebGL TF) is a standard file format for three-dimensional scenes and models. A glTF file uses one of two possible file exte ...
– originally known as WebGL Transmissions Format or WebGL TF
* WebXR
* Java OpenGL
Java OpenGL (JOGL) is a wrapper library that allows OpenGL to be used in the Java programming language. It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Game Technology Group at Su ...
– OpenGL library for the Java programming language
* WebGPU
WebGPU API is a JavaScript, Rust, C++, and C API for cross-platform efficient graphics processing unit (GPU) access. Using a system's underlying Vulkan, Metal, or Direct3D 12 technologies, WebGPU allows for graphics processing, games, and mor ...
References
External links
*
WebGL
at the Mozilla Developer Network
{{Authority control
3D graphics APIs
Cross-platform software
Graphics libraries
Graphics standards
Web
Web most often refers to:
* Spider web, a silken structure created by the animal
* World Wide Web or the Web, an Internet-based hypertext system
Web, WEB, or the Web may also refer to:
Computing
* WEB, a literate programming system created by ...
Web development
Virtual reality
Augmented reality