1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
---
title: WebGL
slug: Web/API/WebGL_API
tags:
- WebGL
translation_of: Web/API/WebGL_API
---
<p>{{WebGLSidebar}}</p>
<p class="summary">WebGL (Web Graphics Library) 是一個透過瀏覽器渲染3D及2D圖像的 JavaScript API ,且不需要安裝任何插件。 WebGL 透過與OpenGL ES 2.0緊密連結的API,將3D圖像帶入HTML5中,並可透過canvas元素呈現於瀏覽器中</p>
<p>Support for WebGL is present in <a href="/en-US/Firefox" title="Firefox 4 for developers">Firefox</a> 4+, <a href="http://www.google.com/chrome/" title="http://www.google.com/chrome/">Google Chrome</a> 9+, <a href="http://www.opera.com/" title="http://www.opera.com/">Opera</a> 12+, <a href="http://www.apple.com/safari/" title="http://www.apple.com/fr/safari/">Safari </a>5.1+ 以及 <a href="http://windows.microsoft.com/en-us/internet-explorer/browser-ie" title="http://windows.microsoft.com/en-us/internet-explorer/download-ie">Internet Explorer</a> 11+; 然而,使用者的 GPU 也必須支援。</p>
<div class="cleared row topicpage-table">
<div class="section">
<h2 class="Documentation" id="Development_topics">Development topics</h2>
<dl>
<dt><a href="/zh-TW/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL" title="WebGL/Getting started with WebGL">從 WebGL 開始吧</a></dt>
<dd>如何設立一個 WebGL 環境。</dd>
<dt><a href="/zh-TW/docs/Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context" title="WebGL/Adding 2D content to a WebGL context">增加 2D 的東西到 WebGL 環境</a></dt>
<dd>如何使用 WebGL 來呈現一個簡單的平面形狀。</dd>
<dt><a href="/en-US/docs/WebGL/Using_shaders_to_apply_color_in_WebGL" title="WebGL/Using shaders to apply color in WebGL">Using shaders to apply color in WebGL</a></dt>
<dd>Demonstrates how to add color to shapes using shaders.</dd>
<dt><a href="/en-US/docs/WebGL/Animating_objects_with_WebGL" title="WebGL/Animating objects with WebGL">Animating objects with WebGL</a></dt>
<dd>Shows how to rotate and translate objects to create simple animations.</dd>
<dt><a href="/en-US/docs/WebGL/Creating_3D_objects_using_WebGL" title="WebGL/Creating 3D objects using WebGL">Creating 3D objects using WebGL</a></dt>
<dd>Shows how to create and animate a 3D object (in this case, a cube).</dd>
<dt><a href="/en-US/docs/WebGL/Using_textures_in_WebGL" title="WebGL/Using textures in WebGL">Using textures in WebGL</a></dt>
<dd>Demonstrates how to map textures onto the faces of an object.</dd>
<dt><a href="/en-US/docs/WebGL/Lighting_in_WebGL" title="WebGL/Lighting in WebGL">Lighting in WebGL</a></dt>
<dd>How to simulate lighting effects in your WebGL context.</dd>
<dt><a href="/en-US/docs/WebGL/Animating_textures_in_WebGL" title="WebGL/Animating textures in WebGL">Animating textures in WebGL</a></dt>
<dd>Shows how to animate textures; in this case, by mapping an Ogg video onto the faces of a rotating cube.</dd>
<dt><a href="/en-US/docs/WebGL/WebGL_best_practices" title="WebGL/WebGL best practices">WebGL best practices</a></dt>
<dd>Tips and suggestions to improve your WebGL content.</dd>
<dt><a href="/en-US/docs/WebGL/Cross-Domain_Textures" title="WebGL/Cross-Domain Textures">Cross-domain textures</a></dt>
<dd>Information about loading textures from domains other than the one from which your content was loaded.</dd>
<dt><a href="/en-US/docs/WebGL/Using_Extensions" title="WebGL/Using_Extensions">Using extensions</a></dt>
<dd>How to use extensions that are available in WebGL.</dd>
</dl>
</div>
<div class="section">
<h2 class="Related_Topics" id="資源">資源</h2>
<dl>
<dt><a class="link-https" href="https://www.khronos.org/registry/webgl/specs/1.0/" title="https://www.khronos.org/registry/webgl/specs/1.0/">WebGL Specification</a></dt>
<dd>The WebGL specification.</dd>
<dt><a href="http://www.khronos.org/webgl/" title="http://www.khronos.org/webgl/">Khronos WebGL site</a></dt>
<dd>The main web site for WebGL at the Khronos Group.</dd>
<dt><a href="http://learningwebgl.com/blog/?page_id=1217" title="http://learningwebgl.com/blog/">Learning WebGL</a></dt>
<dd>A site with tutorials on how to use WebGL.</dd>
<dt><a href="http://www.html5rocks.com/en/tutorials/webgl/webgl_fundamentals/" title="http://www.html5rocks.com/en/tutorials/webgl/webgl_fundamentals/">WebGL Fundamentals</a></dt>
<dd>A basic tutorial with fundamentals of WebGL.</dd>
<dt><a href="http://games.greggman.com/game/webgl-2d-matrices/">WebGL Matrices</a></dt>
<dd>An introduction to matrices' use in 2D WebGL. This series also goes on to explain the math behind perspective 3D.</dd>
<dt><a href="http://learningwebgl.com/cookbook/index.php/" title="http://learningwebgl.com/cookbook/index.php/">The WebGL Cookbook</a></dt>
<dd>A web site with handy recipes for writing WebGL code.</dd>
<dt><a href="http://planet-webgl.org/" title="http://planet-webgl.org/">Planet WebGL</a></dt>
<dd>A feed aggregator for people involved in the WebGL community.</dd>
<dt><a href="http://code.google.com/p/ewgl-matrices/" title="http://code.google.com/p/ewgl-matrices/">ewgl-matrices</a></dt>
<dd>A blazing fast matrix library for WebGL</dd>
<dt><a class="link-https" href="https://github.com/toji/gl-matrix" title="https://github.com/toji/gl-matrix">glMatrix</a></dt>
<dd>JavaScript Matrix and Vector library for High Performance WebGL apps</dd>
<dt><a href="http://code.google.com/p/webgl-mjs/" title="http://code.google.com/p/webgl-mjs/">mjs</a></dt>
<dd><span>A JavaScript vector and matrix math library, optimized for WebGL usage.</span></dd>
<dt><a href="http://sylvester.jcoglan.com/" title="http://sylvester.jcoglan.com/">Sylvester</a></dt>
<dd>An open source library for manipulating vectors and matrices. Not optimized for WebGL but extremely robust.</dd>
<dt><a href="http://webglplayground.net" title="http://webglplayground.net">WebGL playground</a></dt>
<dd>An online tool for creating and sharing WebGL projects. Good for quick prototyping and experimenting.</dd>
<dt><a href="http://www.webglacademy.com" title="http://www.webglacademy.com">WebGL Academy</a></dt>
<dd>An HTML/Javascript editor with tutorials to learn basics of webgl programming.</dd>
<dt> </dt>
</dl>
</div>
</div>
<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
<h3>WebGL 1</h3>
{{Compat("api.WebGLRenderingContext", 0)}}
<h3>WebGL 2</h3>
{{Compat("api.WebGL2RenderingContext", 0)}}
<h3 id="相容性小記">相容性小記</h3>
<p>In addition to the browser, the GPU itself also needs to support the feature. So, for example, S3 Texture Compression (S3TC) is only available on Tegra-based tablets. Most browsers make the WebGL context available through the <code>webgl</code> context name, but older ones need <code>experimental-webgl</code> as well. In addition, the upcoming WebGL 2 is fully backwards-compatible and will have the context name <code>experimental-webgl2</code> in the future for testing.</p>
<h3 id="Gecko_小記">Gecko 小記</h3>
<h4 id="WebGL_debugging_and_testing">WebGL debugging and testing</h4>
<p>Starting with Gecko 10.0 {{geckoRelease("10.0")}}, there are two preferences available which let you control the capabilities of WebGL for testing purposes:</p>
<dl>
<dt><code>webgl.min_capability_mode</code></dt>
<dd>A Boolean property that, when <code>true</code>, enables a minimum capability mode. When in this mode, WebGL is configured to only support the bare minimum feature set and capabilities required by the WebGL specification. This lets you ensure that your WebGL code will work on any device or browser, regardless of their capabilities. This is <code>false</code> by default.</dd>
<dt><code>webgl.disable_extensions</code></dt>
<dd>A Boolean property that, when <code>true</code>, disables all WebGL extensions. This is <code>false</code> by default.</dd>
</dl>
<h2 id="你也可以看看">你也可以看看</h2>
<p>Raw WebGL: a talk by Nick Desaulniers:</p>
<p>{{EmbedYouTube("H4c8t6myAWU")}}</p>
|