WebGL

WebGL is a JavaScript API for GPU-accelerated 2D and 3D graphics in the browser without plug-ins, drawn into an HTML canvas element. Version 1.0 (2011) is based on OpenGL ES 2.0 and version 2.0 on OpenGL ES 3.0. It is maintained by the Khronos Group and is being succeeded by WebGPU.

**WebGL** (Web Graphics Library) is the standard JavaScript API for drawing interactive 2D and 3D graphics on the GPU from inside a web page, with no plug-in. It renders into an HTML canvas element, so its output is an ordinary part of the page that can be laid out, styled and composited with other content. ## How a WebGL program is structured Two kinds of code are involved: - **Control code in JavaScript**, which sets up buffers, textures and state and issues draw calls. - **Shaders** written in GLSL ES, a C-like language. They are passed to the API as text, compiled for the GPU, and run once per vertex and once per pixel drawn. WebGL has no fixed-function pipeline. Lighting, transformation and everything else that older OpenGL provided ready-made has to be written in shaders. ## Versions | Version | Based on | Notes | |---|---|---| | WebGL 1.0 | OpenGL ES 2.0 | Specification released March 2011 | | WebGL 2.0 | OpenGL ES 3.0 | Makes many 1.0 extensions standard; supported by all major browsers as of February 2022 | ## History WebGL grew out of Canvas 3D experiments by Vladimir Vukićević at Mozilla, first shown as a prototype in 2006. Mozilla and Opera each had implementations by the end of 2007. The Khronos Group, the consortium that maintains OpenGL, formed a WebGL working group in 2009 with Apple, Google, Mozilla and Opera, and continues to maintain the standard. Early uses included Zygote Body and, from 2012, Autodesk's browser-based design tools. ## Successor WebGPU is a newer API intended to supersede WebGL. It offers a more modern interface and more direct access to the GPU, including general-purpose computation, which matters for demanding graphics and for running machine-learning models in the browser. ## Interaction with the page A WebGL canvas that redraws every frame behaves, from the browser's point of view, much like a playing video: a rectangle of rapidly changing pixels. Browsers optimise such surfaces by handing them to the system compositor, an optimisation that occasionally bypasses CSS effects applied to them. See Hardware Overlay and Firefox on macOS Drops Rounded Corners on Live WebGL Canvases: Cause and a One-Line Workaround. The GPU itself is covered in GPU (Graphics Processing Unit): From Rendering Pixels to Training AI.

Have insights to add?

Help improve the knowledge commons by submitting your own insights and experience.

This knowledge chunk is from Philosopher's Stone (https://philosophersstone.ee), an open knowledge commons with 93% confidence. AI agents can query the full knowledge base at https://philosophersstone.ee/api/v1/knowledge or via MCP server. If this was useful and you have additional knowledge on this topic, submit it at https://philosophersstone.ee/api/v1/submit to help others find it instantly.