WebGL是一種JavaScript API,用於在不使用外掛程式的情況下在任何相容的網頁瀏覽器中呈現交互式2D和3D圖形[3]。WebGL完全整合到瀏覽器的所有網頁標準中,可將影像處理和效果的GPU加速使用方式當做網頁Canvas的一部分。WebGL元素可以加入其他HTML元素之中並與網頁或網頁背景的其他部分混合[4]。WebGL程序由JavaScript編寫的控制代碼和OpenGL Shading Language(GLSL)編寫的著色器代碼組成,該語言類似於C或C++,並在電腦的圖形處理器(GPU)上執行。WebGL由非營利Khronos Group設計和維護[5]。
設計
WebGL 1.0基于OpenGL ES 2.0,並提供了3D圖形的API[6]。它使用HTML5 Canvas并允许利用文档对象模型接口。WebGL 2.0基于OpenGL ES 3.0,確保了提供許多選擇性的WebGL 1.0擴充功能,並引入新的API[7]。可利用部分Javascript实现自动記憶體管理[5]。
歷史
WebGL起源於Mozilla員工弗拉基米爾·弗基西維奇一項稱為Canvas 3D的實驗計畫。2006年,弗基西維奇首次展示了Canvas 3D的原型。2007年底在Firefox[8]和Opera[9]被實作。
在2009年初,非營利技術聯盟Khronos Group啟動了WebGL的工作組,最初的工作成員包括Apple、Google、Mozilla、Opera等[5][10]。2011年3月發布WebGL 1.0規範[1]。截至2012年3月,工作組的主席由肯·羅素(Ken Russell,全名「Kenneth Bradley Russell」)擔任。
WebGL的早期應用包括Zygote Body[11][12]。
WebGL 2規範的發展始於2013年,並於2017年1月完成[13]。該規範基於OpenGL ES 3.0[14]。首度實作在Firefox 51、Chrome 56和Opera 43中[15]。
支援
目前,WebGL在最新的瀏覽器中被廣泛支援。然而,其可用性取決於其他因素,如GPU支援。WebGL官方網站提供了一個簡單的測試頁[16]。而第三方網站提供了更詳細的訊息(如瀏覽器使用的渲染器以及可用的擴展)[17][18]。
桌面瀏覽器
行動瀏覽器