OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
2 "http://www.w3.org/TR/html4/strict.dtd"> | |
3 <html lang="en"> | |
4 <head> | |
5 <meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
6 <title>WebGL Specification</title> | |
7 <meta name="generator" content="BBEdit 9.1"> | |
8 <link rel="stylesheet" type="text/css" href="../../resources/Khronos-WD.css"
/> | |
9 <script src="../../resources/jquery-1.3.2.min.js" type="text/javascript"></s
cript> | |
10 <script src="../../resources/generateTOC.js" type="text/javascript"></script
> | |
11 </head> | |
12 <body onload="generateTOC(document.getElementById('toc'))"> | |
13 <!--begin-logo--> | |
14 <div class=head> | |
15 <p> | |
16 <a href="http://khronos.org/"> | |
17 <img alt=Khronos height=60 src="../../resources/KhronosGroup-3D.
png" width=220> | |
18 </a> | |
19 </p> | |
20 </div> | |
21 <div class=head> | |
22 <p> | |
23 <a href="http://webgl.org/"> | |
24 <img alt=WebGL height=72 src="../../resources/WebGL-Logo.png" wi
dth=156> | |
25 </a> | |
26 </p> | |
27 </div> | |
28 <!--end-logo--> | |
29 | |
30 <h1>WebGL Specification</h1> | |
31 <h2 class="no-toc">Editor's Draft 08 June 2011</h2> | |
32 <dl> | |
33 <dt>This version: | |
34 <dd> | |
35 <a href="https://www.khronos.org/registry/webgl/specs/latest/"> | |
36 https://www.khronos.org/registry/webgl/specs/latest/ | |
37 </a> | |
38 <br> | |
39 <a href="https://www.khronos.org/registry/webgl/specs/latest/web
gl.idl"> | |
40 <b>WebIDL:</b> https://www.khronos.org/registry/webgl/specs/
latest/webgl.idl | |
41 </a> | |
42 </dd> | |
43 <dt>Latest version: | |
44 <dd> | |
45 <a href="https://www.khronos.org/registry/webgl/specs/latest/"> | |
46 https://www.khronos.org/registry/webgl/specs/latest/ | |
47 </a> | |
48 <br> | |
49 <a href="https://www.khronos.org/registry/webgl/specs/latest/web
gl.idl"> | |
50 <b>WebIDL:</b> https://www.khronos.org/registry/webgl/specs/
latest/webgl.idl | |
51 </a> | |
52 </dd> | |
53 <dt>Previous version: | |
54 <dd> | |
55 <a href="https://www.khronos.org/registry/webgl/specs/1.0/"> | |
56 https://www.khronos.org/registry/webgl/specs/1.0/ | |
57 </a> | |
58 <br> | |
59 <a href="https://www.khronos.org/registry/webgl/specs/1.0/webgl.
idl"> | |
60 <b>WebIDL:</b> https://www.khronos.org/registry/webgl/specs/
1.0/webgl.idl | |
61 </a> | |
62 </dd> | |
63 <dt>Editor: | |
64 <dd> | |
65 <a href="mailto:cmarrin@apple.com">Chris Marrin</a> | |
66 <a href="http://www.apple.com/">(Apple Inc.)</a> | |
67 </dd> | |
68 </dl> | |
69 | |
70 <span style="font-size: x-small; font-style: oblique">Copyright © 2011
Khronos Group</span> | |
71 | |
72 <hr /> | |
73 | |
74 <h2 class="no-toc">Abstract</h2> | |
75 <p> | |
76 This specification describes an additional rendering context and support | |
77 objects for the | |
78 <a href="http://www.w3.org/TR/html5/the-canvas-element.html" | |
79 title="HTML 5 Canvas Element"> | |
80 HTML 5 <span class="prop-name">canvas</span> element <a href="#refsC
ANVAS">[CANVAS]</a>. | |
81 </a> | |
82 This context allows rendering using an API that conforms closely to the
OpenGL ES 2.0 API. | |
83 </p> | |
84 | |
85 <h2 class="no-toc">Status of this document</h2> | |
86 | |
87 <!--begin-status--> | |
88 <p> | |
89 This document is an editor's draft. Do not cite this document as other t
han work in | |
90 progress. Public discussion of this specification is welcome on the | |
91 (<a href="https://www.khronos.org/webgl/public-mailing-list/archives/">a
rchived</a>) WebGL | |
92 mailing list <a href="mailto:public_webgl@khronos.org">public_webgl@khro
nos.org</a> (see | |
93 <a href="http://www.khronos.org/webgl/public-mailing-list/">instructions
</a>). | |
94 </p> | |
95 <!--end-status--> | |
96 | |
97 <h2 class="no-toc">Table of contents</h2> | |
98 <div id="toc"></div> | |
99 | |
100 <h2>Introduction</h2> | |
101 <div class="note"> | |
102 <p> | |
103 WebGLâ„¢ is an immediate mode 3D rendering API designed for the | |
104 web. It is derived from OpenGL® ES 2.0, and provides similar | |
105 rendering functionality, but in an HTML context. WebGL is | |
106 designed as a rendering context for the HTML Canvas element. | |
107 The HTML Canvas provides a destination for programmatic | |
108 rendering in web pages, and allows for performing that rendering | |
109 using different rendering APIs. The only such interface | |
110 described as part of the Canvas specification is the 2D canvas | |
111 rendering context, CanvasRenderingContext2D. This document | |
112 describes another such interface, WebGLRenderingContext, which | |
113 presents the WebGL API. | |
114 </p> | |
115 | |
116 <p> | |
117 The immediate mode nature of the API is a divergence from most | |
118 web APIs. Given the many use cases of 3D graphics, WebGL | |
119 chooses the approach of providing flexible primitives that can | |
120 be applied to any use case. Libraries can provide an API on top | |
121 of WebGL that is more tailored to specific areas, thus adding a | |
122 convenience layer to WebGL that can accelerate and simplify development. | |
123 However, because of its OpenGL ES 2.0 heritage, it should be | |
124 straightforward for developers familiar with modern desktop | |
125 OpenGL or OpenGL ES 2.0 development to transition to WebGL | |
126 development. | |
127 </p> | |
128 | |
129 <p> | |
130 Many functions described in this document contain links to OpenGL ES | |
131 man pages. While every effort is made to make these pages match the | |
132 OpenGL ES 2.0 specification <a href="#refsGLES20">[GLES20]</a>, | |
133 they may contain errors. In the case of a contradiction, the OpenGL | |
134 ES 2.0 specification is the final authority. | |
135 </p> | |
136 | |
137 <p> | |
138 The remaining sections of this document are intended to be read in conjunc
tion | |
139 with the OpenGL ES 2.0 specification (2.0.24 at the time of this writing,
available | |
140 from the <a href="http://www.khronos.org/registry/gles/">Khronos OpenGL ES
API Registry</a>). | |
141 Unless otherwise specified, the behavior of each method is defined by the | |
142 OpenGL ES 2.0 specification. This specification may diverge from OpenGL E
S 2.0 | |
143 in order to ensure interoperability or security, often defining areas that | |
144 OpenGL ES 2.0 leaves implementation-defined. These differences are summar
ized in the | |
145 <a href="#webgl_gl_differences">Differences Between WebGL and OpenGL ES 2.
0</a> section. | |
146 </p> | |
147 </div> | |
148 | |
149 <!-- ===========================================================================
============================ --> | |
150 | |
151 <h2>Context Creation and Drawing Buffer Presentation</h2> | |
152 | |
153 <p> | |
154 Before using the WebGL API, the author must obtain a WebGLRenderingConte
xt object | |
155 for a given HTMLCanvasElement as described below. This object is used to
manage | |
156 OpenGL state and render to the drawing buffer, which must also be create
d at the time of | |
157 context creation. The author may supply configuration options for this d
rawing buffer, otherwise | |
158 default values shall be used as specified elsewhere in this document. Th
is drawing buffer | |
159 is presented to the HTML page compositor immediately before an HTML page
compositing operation, | |
160 but only if the drawing buffer has been modified since the last composit
ing operation. | |
161 </p> | |
162 | |
163 <!-- ===========================================================================
============================ --> | |
164 | |
165 <h3>The <span class=prop-name><code>canvas</code></span> Element</h3> | |
166 | |
167 <p> | |
168 A WebGLRenderingContext object shall be created by calling the <code>get
Context()</code> | |
169 method of a given HTMLCanvasElement <a href="#refsCANVAS">[CANVAS]</a> o
bject with the exact string | |
170 ‘<code class=property>webgl</code>’. This string is case se
nsitive. When called | |
171 for the first time, a WebGLRenderingContext object is created and return
ed. Also at this | |
172 time a drawing buffer shall be created. Subsequent calls to <code>getCon
text()</code> with | |
173 the same string shall return the same object. | |
174 </p> | |
175 <p> | |
176 The HTML Canvas specification <a href="#refsCANVAS">[CANVAS]</a> | |
177 defines the behavior when attempting to fetch two or more | |
178 incompatible contexts against the same canvas element. | |
179 </p> | |
180 <p> | |
181 A second parameter may be passed to the <code>getContext()</code> method
. If passed, this | |
182 parameter shall be a WebGLContextAttributes object containing configurat
ion parameters to be | |
183 used in creating the drawing buffer. | |
184 See <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> for mor
e details. | |
185 </p> | |
186 <p> | |
187 The <code>depth</code>, <code>stencil</code> and <code>antialias</code>
attributes are | |
188 requests, not requirements. The WebGL implementation does not guarantee
that they will be | |
189 obeyed, but should make a best effort to honor them. Combinations of att
ributes not | |
190 supported by the WebGL implementation or graphics hardware shall not cau
se a failure to | |
191 create a WebGLRenderingContext. The attributes actually used to create t
he context may be | |
192 queried by the <code>getContextAttributes()</code> method on the | |
193 WebGLRenderingContext. The <code>alpha</code>, <code>premultipliedAlpha<
/code> | |
194 and <code>preserveDrawingBuffer</code> attributes must be obeyed by the
WebGL | |
195 implementation. | |
196 </p> | |
197 <p> | |
198 On subsequent calls to getContext() with the ‘<code class=property
>webgl</code>’ | |
199 string, the passed WebGLContextAttributes object, if any, shall be ignor
ed. | |
200 <p> | |
201 </p> | |
202 | |
203 <!-- ===========================================================================
============================ --> | |
204 | |
205 <h3><a name="THE_DRAWING_BUFFER">The Drawing Buffer</a></h3> | |
206 | |
207 <p> | |
208 The drawing buffer into which the API calls are rendered shall be define
d upon creation of | |
209 the WebGLRenderingContext object. The table below shows all the buffers
which make up the | |
210 drawing buffer, along with their minimum sizes and whether they are defi
ned or not by | |
211 default. The size of this drawing buffer shall be determined by the <cod
e>width</code> | |
212 and <code>height</code> attributes of the HTMLCanvasElement. The table b
elow also shows the | |
213 value to which these buffers shall be cleared when first created, when t
he size is changed, | |
214 or after presentation when the <code>preserveDrawingBuffer</code> contex
t creation attribute | |
215 is <code>false</code>. | |
216 </p> | |
217 <table class="foo"> | |
218 <tr><th>Buffer</th><th>Clear value</th><th>Minimum size</th><th>Defined
by default?</th></tr> | |
219 <tr><td>Color</td><td>(0, 0, 0, 0)</td><td>8 bits per component</td><td>
yes</td></tr> | |
220 <tr><td>Depth</td><td>1.0</td><td>16 bit integer</td><td>yes</td></tr> | |
221 <tr><td>Stencil</td><td>0</td><td>8 bits</td><td>no</td></tr> | |
222 </table> | |
223 <br> | |
224 <p> | |
225 If the requested width or height cannot be satisfied, either when the dr
awing buffer is first | |
226 created or when the <code>width</code> and <code>height</code> attribute
s of the | |
227 <code>HTMLCanvasElement</code> are changed, a drawing buffer with smalle
r dimensions shall | |
228 be created. The dimensions actually used are implementation dependent an
d there is no | |
229 guarantee that a buffer with the same aspect ratio will be created. The
actual drawing | |
230 buffer size can be obtained from the <code>drawingBufferWidth</code> and
| |
231 <code>drawingBufferHeight</code> attributes. | |
232 </p> | |
233 <p> | |
234 By default, the buffers shall be the size shown below. The optional <a h
ref="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> | |
235 object may be used to change whether or not the buffers are defined. It
can also be used | |
236 to define whether the color buffer will include an alpha channel. If def
ined, the | |
237 alpha channel is used by the HTML compositor to combine the color buffer
with the rest | |
238 of the page. The WebGLContextAttributes object is only used on the first
call to | |
239 <code>getContext</code>. No facility is provided to change the attribute
s of the drawing | |
240 buffer after its creation. | |
241 </p> | |
242 <p> | |
243 WebGL presents its drawing buffer to the HTML page compositor immediatel
y before a compositing | |
244 operation, but only if the drawing buffer has been modified since the la
st compositing operation. | |
245 Before the drawing buffer is presented for compositing the implementatio
n shall ensure that all | |
246 rendering operations have been flushed to the drawing buffer. By default
, after compositing the | |
247 contents of the drawing buffer shall be cleared to their default values,
as shown in the table | |
248 above. | |
249 </p> | |
250 <p> | |
251 This default behavior can be changed by setting the <code>preserveDrawin
gBuffer</code> | |
252 attribute of the <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttribute
s</a> object. If | |
253 this flag is true, the contents of the drawing buffer shall be preserved
until the author | |
254 either clears or overwrites them. If this flag is false, attempting to p
erform operations | |
255 using this context as a source image after the rendering function has re
turned can lead to | |
256 undefined behavior. This includes <code>readPixels</code> or <code>toDat
aURL</code> calls, | |
257 or using this context as the source image of another context's <code>tex
Image2D</code> or | |
258 <code>drawImage</code> call. | |
259 </p> | |
260 <div class="note"> | |
261 <p> | |
262 While it is sometimes desirable to preserve the drawing buffer, it c
an cause significant | |
263 performance loss on some platforms. Whenever possible this flag shou
ld remain false | |
264 and other techniques used. Techniques like synchronous drawing buffe
r access (e.g., | |
265 calling <code>readPixels</code> or <code>toDataURL</code> in the sam
e function that | |
266 renders to the drawing buffer) can be used to get the contents of th
e drawing buffer. | |
267 If the author needs to render to the same drawing buffer over a seri
es of calls, a | |
268 <a href="#WEBGL_FRAMEBUFFER">Framebuffer Object</a> can be used. | |
269 </p> | |
270 <p> | |
271 Implementations may optimize away the required implicit clear operat
ion of the Drawing | |
272 Buffer as long as a guarantee can be made that the author cannot gai
n access to buffer | |
273 contents from another process. For instance, if the author performs
an explicit | |
274 clear then the implicit clear is not needed. | |
275 </p> | |
276 </div> | |
277 | |
278 <!-- ===========================================================================
============================ --> | |
279 | |
280 <h3>The WebGL Viewport</h3> | |
281 | |
282 <p> | |
283 OpenGL manages a rectangular viewport as part of its state which defines
the placement of the | |
284 rendering results in the drawing buffer. Upon creation of the WebGL cont
ext, the viewport is | |
285 initialized to a rectangle with origin at (0, 0) and width and height eq
ual to (canvas.width, | |
286 canvas.height). | |
287 </p> | |
288 <p> | |
289 A WebGL implementation <em>shall not</em> affect the state of the OpenGL
viewport in response to | |
290 resizing of the canvas element. | |
291 </p> | |
292 <div class="example"> | |
293 Note that if a WebGL program does not contain logic to set the viewport,
it will not properly | |
294 handle the case where the canvas is resized. The following ECMAScript ex
ample illustrates how | |
295 a WebGL program might resize the canvas programmatically. | |
296 | |
297 <pre> | |
298 var canvas = document.getElementById('canvas1'); | |
299 var gl = canvas.getContext('webgl'); | |
300 canvas.width = newWidth; | |
301 canvas.height = newHeight; | |
302 gl.viewport(0, 0, canvas.width, canvas.height); | |
303 </pre> | |
304 </div> | |
305 <p> | |
306 <em>Rationale</em>: automatically setting the viewport will interfere wi
th applications that set | |
307 it manually. Applications are expected to use <code>onresize</code> hand
lers to respond to | |
308 changes in size of the canvas and set the OpenGL viewport in turn. | |
309 </p> | |
310 | |
311 <!-- ===========================================================================
============================ --> | |
312 | |
313 <h3><a name="PREMULTIPLIED_ALPHA">Premultiplied Alpha, Canvas APIs and texIm
age2D</a></h3> | |
314 | |
315 <p> | |
316 The OpenGL API allows the application to modify the blending modes used
during rendering, | |
317 and for this reason allows control over how alpha values in the drawing
buffer are | |
318 interpreted; see the <code>premultipliedAlpha</code> parameter in | |
319 the <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> section
. | |
320 </p> | |
321 <p> | |
322 The HTML Canvas APIs <code>toDataURL</code> and <code>drawImage</code> m
ust respect | |
323 the <code>premultipliedAlpha</code> context creation parameter. When <co
de>toDataURL</code> | |
324 is called against a Canvas into which WebGL content is being rendered, t
hen if the requested | |
325 image format does not specify premultiplied alpha and the WebGL context
has | |
326 the <code>premultipliedAlpha</code> parameter set to true, then the pixe
l values must be | |
327 de-multiplied; i.e., the color channels are divided by the alpha channel
. <b>Note</b> that | |
328 this operation is lossy. | |
329 </p> | |
330 <p> | |
331 Passing a WebGL-rendered Canvas to the <code>drawImage</code> method | |
332 of <code>CanvasRenderingContext2D</code> may or may not need to modify t
he the rendered | |
333 WebGL content during the drawing operation, depending on the premultipli
cation needs of the | |
334 <code>CanvasRenderingContext2D</code> implementation. | |
335 </p> | |
336 <p> | |
337 When passing a WebGL-rendered Canvas to the <code>texImage2D</code> API,
then depending on | |
338 the setting of the <code>premultipliedAlpha</code> context creation para
meter of the passed | |
339 canvas and the <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel store p
arameter of the | |
340 destination WebGL context, the pixel data may need to be changed to or f
rom premultiplied | |
341 form. | |
342 </p> | |
343 | |
344 <!-- ===========================================================================
============================ --> | |
345 | |
346 <h2>WebGL Resources</h2> | |
347 | |
348 <p> | |
349 OpenGL manages several types of resources as part of its state. These ar
e identified | |
350 by integer object names and are obtained from OpenGL by various creation
calls. | |
351 In contrast WebGL represents these resources as DOM objects. Each object
is derived | |
352 from the WebGLObject interface. Currently supported resources are: | |
353 textures, buffers (i.e., VBOs), framebuffers, renderbuffers, shaders and | |
354 programs. The WebGLRenderingContext interface has a method to create a | |
355 WebGLObject subclass for each type. Data from the underlying graphics li
brary are | |
356 stored in these objects and are fully managed by them. The resources rep
resented | |
357 by these objects are guaranteed to exist as long as the object exists. | |
358 Furthermore, the DOM object is guaranteed to exist as long as the author
has an explicit | |
359 valid reference to it <b>or</b> as long as it is bound by the underlying
graphics library. | |
360 When none of these conditions exist the user agent can, at any point, de
lete the object | |
361 using the equivalent of a delete call (e.g., deleteTexture). If authors
wish to control | |
362 when the underlying resource is released then the delete call can be mad
e explicitly. | |
363 </p> | |
364 | |
365 <!-- ===========================================================================
============================ --> | |
366 | |
367 <h2>Security</h2> | |
368 | |
369 <p> | |
370 </p> | |
371 | |
372 <!-- ===========================================================================
============================ --> | |
373 | |
374 <h3>Resource Restrictions</h3> | |
375 | |
376 <p> | |
377 WebGL resources such as textures and vertex buffer objects (VBOs) must a
lways | |
378 contain initialized data, even if they were created without initial user
| |
379 data values. Creating a resource without initial values is commonly use
d to | |
380 reserve space for a texture or VBO, which is then modified using <code>t
exSubImage</code> or | |
381 <code>bufferSubData</code> calls. If initial data is not provided to th
ese calls, the WebGL | |
382 implementation must initialize their contents to 0; depth renderbuffers
must be cleared to | |
383 the default 1.0 clear depth. For example, this may require creating a t
emporary buffer of 0 | |
384 values the size of a requested VBO, so that it can be initialized correc
tly. All other | |
385 forms of loading data into a texture or VBO involve either ArrayBuffers
or DOM objects such | |
386 as images, and are therefore already required to be initialized. | |
387 </p> | |
388 | |
389 <p> | |
390 When WebGL resources are accessed by shaders through a call such as | |
391 <code>drawElements</code> or <code>drawArrays</code>, the WebGL implemen
tation must ensure | |
392 that the shader cannot access either out of bounds or uninitialized data
. | |
393 See <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes and
Range Checking</a> | |
394 for restrictions which must be enforced by the WebGL implementation. | |
395 </p> | |
396 | |
397 <!-- ===========================================================================
============================ --> | |
398 | |
399 <h3><a name="ORIGIN_RESTRICTIONS">Origin Restrictions</a></h3> | |
400 | |
401 <p> | |
402 In order to prevent information leakage, WebGL disallows uploading as te
xtures: | |
403 <ul> | |
404 <li> Image or video elements whose origin is not the same as the origin
of the Document that | |
405 contains the WebGLRenderingContext's canvas element | |
406 <li> Canvas elements whose <i>origin-clean</i> flag is set to false | |
407 </ul> | |
408 </p> | |
409 <p> | |
410 If the <code>texImage2D</code> or <code>texSubImage2D</code> method is c
alled with otherwise | |
411 correct arguments and an <code>HTMLImageElement</code>, <code>HTMLVideoE
lement</code>, | |
412 or <code>HTMLCanvasElement</code> violating these restrictions, a <code>
SECURITY_ERR</code> | |
413 exception must be raised. | |
414 </p> | |
415 <div class="note"> | |
416 <p> | |
417 WebGL necessarily imposes stronger restrictions on the use of cross-
domain media than other | |
418 APIs such as the 2D canvas rendering context, because shaders can be
used to indirectly | |
419 deduce the contents of textures which have been uploaded to the GPU. | |
420 </p> | |
421 <p> | |
422 WebGL applications may utilize images and videos that come from othe
r domains, with the | |
423 cooperation of the server hosting the media, | |
424 using <a href="http://www.w3.org/TR/cors/">Cross-Origin Resource | |
425 Sharing</a> <a href="#refsCORS">[CORS]</a>. In order to use such med
ia, the application | |
426 must explicitly request permission to do so, and the server must exp
licitly grant | |
427 permission. Successful CORS-enabled fetches of image and video eleme
nts from other | |
428 domains <a href="http://www.whatwg.org/specs/web-apps/current-work/m
ultipage/origin-0.html#origin-0">cause | |
429 the origin of these elements</a> to be set to that of the containing | |
430 Document <a href="#refsHTML">[HTML]</a>. | |
431 </p> | |
432 <div class="example"> | |
433 <p> | |
434 The following ECMAScript example demonstrates how to issue a COR
S request for an | |
435 image coming from another domain. The image is fetched from the
server without any | |
436 credentials, i.e., cookies. | |
437 </p> | |
438 <pre> | |
439 var gl = ...; | |
440 var image = new Image(); | |
441 | |
442 // The onload handler should be set to a function which uploads the HTMLImageEle
ment | |
443 // using texImage2D or texSubImage2D. | |
444 image.onload = ...; | |
445 | |
446 image.crossOrigin = "anonymous"; | |
447 | |
448 image.src = "http://other-domain.com/image.jpg"; | |
449 </pre> | |
450 </div> | |
451 <p> | |
452 Note that these rules imply that the <i>origin-clean</i> flag for a
canvas rendered | |
453 using WebGL will never be set to false. | |
454 </p> | |
455 <p> | |
456 For more information on issuing CORS requests for image and video el
ements, consult: | |
457 <ul> | |
458 <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/mult
ipage/urls.html#cors-settings-attribute">CORS settings attributes</a> <a href="#
refsHTML">[HTML]</a> | |
459 <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/mult
ipage/embedded-content-1.html#the-img-element">The <code>img</code> element</a>
<a href="#refsHTML">[HTML]</a> | |
460 <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/mult
ipage/the-iframe-element.html#media-elements">Media elements</a> <a href="#refsH
TML">[HTML]</a> | |
461 </ul> | |
462 </p> | |
463 </div> | |
464 | |
465 <!-- ===========================================================================
============================ --> | |
466 | |
467 <h3><a name="SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</a></h3> | |
468 | |
469 <p> | |
470 A WebGL implementation must only accept shaders which conform to The Ope
nGL ES Shading | |
471 Language, Version 1.00 <a href="#refsGLES20GLSL">[GLES20GLSL]</a>, and w
hich do not exceed | |
472 the minimum functionality mandated in Sections 4 and 5 of Appendix A. I
n particular: | |
473 | |
474 <ul> | |
475 <li> A shader referencing state variables or functions that are availabl
e in other versions | |
476 of GLSL, such as that found in versions of OpenGL for the desktop,
must not be allowed | |
477 to load. </li> | |
478 <li> <code>for</code> loops must conform to the structural constraints i
n Appendix A. </li> | |
479 <li> Appendix A mandates certain forms of indexing of arrays; for exampl
e, within fragment | |
480 shaders, indexing is only mandated with a <i>constant-index-express
ion</i> | |
481 (see <a href="#refsGLES20GLSL">[GLES20GLSL]</a> for the definition
of this term). In | |
482 the WebGL API, only the forms of indexing mandated in Appendix A ar
e supported. </li> | |
483 </ul> | |
484 </p> | |
485 <p> | |
486 In addition to the reserved identifiers in the aforementioned specificat
ion, identifiers | |
487 starting with "webgl_" and "_webgl_" are reserved for use by WebGL. A sh
ader which declares | |
488 a function, variable, structure name, or structure field starting with t
hese prefixes must | |
489 not be allowed to load. | |
490 </p> | |
491 | |
492 <!-- ===========================================================================
============================ --> | |
493 | |
494 <h3>Defense Against Denial of Service</h3> | |
495 <div class="note"> | |
496 <p> | |
497 It is possible to create, either intentionally or unintentionally, combinati
ons of shaders and | |
498 geometry that take an undesirably long time to render. This issue is analogo
us to that of | |
499 long-running scripts, for which user agents already have safeguards. However
, long-running draw | |
500 calls can cause loss of interactivity for the entire window system, not just
the user agent. | |
501 </p> | |
502 | |
503 <p> | |
504 In the general case it is not possible to impose limits on the structure of
incoming shaders to | |
505 guard against this problem. Experimentation has shown that even very strict
structural limits | |
506 are insufficient to prevent long rendering times, and such limits would prev
ent shader authors | |
507 from implementing common algorithms. | |
508 </p> | |
509 | |
510 <p> | |
511 User agents should implement safeguards to prevent excessively long renderin
g times and | |
512 associated loss of interactivity. Suggested safeguards include: | |
513 </p> | |
514 | |
515 <ul> | |
516 | |
517 <li> Splitting up draw calls with large numbers of elements into smaller dra
w calls. | |
518 | |
519 <li> Timing individual draw calls and forbidding further rendering from a pa
ge if a certain | |
520 timeout is exceeded. | |
521 | |
522 <li> Using any watchdog facilities available at the user level, graphics API
level, or operating | |
523 system level to limit the duration of draw calls. | |
524 | |
525 <li> Separating the graphics rendering of the user agent into a distinct ope
rating system | |
526 process which can be terminated and restarted without losing applicatio
n state. | |
527 | |
528 </ul> | |
529 | |
530 <p> | |
531 The supporting infrastructure at the OS and graphics API layer is expected t
o improve over time, | |
532 which is why the exact nature of these safeguards is not specified. | |
533 </p> | |
534 </div> | |
535 <!-- ===========================================================================
============================ --> | |
536 | |
537 <h3><a name="OUT_OF_RANGE_ARRAY_ACCESSES">Out-of-Range Array Accesses</a></h
3> | |
538 | |
539 <p> | |
540 Shaders must not be allowed to read or write array elements that lie out
side the bounds of | |
541 the array. This includes any variable of array type, as well as vector o
r matrix types such | |
542 as <code>vec3</code> or <code>mat4</code> when accessed using array subs
cripting syntax. If | |
543 detected during compilation, such accesses must generate an error and pr
event the shader | |
544 from compiling. Otherwise, at runtime they may return a constant value (
such as 0), or the | |
545 value at any valid index of the same array. | |
546 </p> | |
547 <div class="note"> | |
548 <p> | |
549 See <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</
a> for more information | |
550 on restrictions which simplify static analysis of the array indexing
operations in shaders. | |
551 </p> | |
552 </div> | |
553 <!-- ===========================================================================
============================ --> | |
554 | |
555 <h2>DOM Interfaces</h2> | |
556 | |
557 <p> | |
558 This section describes the interfaces and functionality added to the | |
559 DOM to support runtime access to the functionality described above. | |
560 </p> | |
561 | |
562 <!-- ===========================================================================
============================ --> | |
563 | |
564 <h3>Types</h3> | |
565 | |
566 <p> | |
567 The following types are used in all interfaces in the following section. | |
568 </p> | |
569 <pre class="idl"> | |
570 typedef events::Event Event; | |
571 typedef html::HTMLCanvasElement HTMLCanvasElement; | |
572 typedef html::HTMLImageElement HTMLImageElement; | |
573 typedef html::HTMLVideoElement HTMLVideoElement; | |
574 typedef html::ImageData ImageData; | |
575 | |
576 typedef unsigned long GLenum; | |
577 typedef boolean GLboolean; | |
578 typedef unsigned long GLbitfield; | |
579 typedef byte GLbyte; /* 'byte' should be a signed 8 bit type.
*/ | |
580 typedef short GLshort; | |
581 typedef long GLint; | |
582 typedef long GLsizei; | |
583 typedef long long GLintptr; | |
584 typedef long long GLsizeiptr; | |
585 typedef unsigned byte GLubyte; /* 'unsigned byte' should be an unsigned
8 bit type. */ | |
586 typedef unsigned short GLushort; | |
587 typedef unsigned long GLuint; | |
588 typedef float GLfloat; | |
589 typedef float GLclampf; | |
590 </pre> | |
591 | |
592 <!-- ===========================================================================
============================ --> | |
593 | |
594 <h3><a name="WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a></h3> | |
595 | |
596 <p> | |
597 The <code>WebGLContextAttributes</code> interface contains drawing surfa
ce attributes and is | |
598 passed as the second parameter to <code>getContext</code>. A native obje
ct may be supplied | |
599 as this parameter; the specified attributes will be queried from this ob
ject. | |
600 </p> | |
601 <pre class="idl">[Callback] interface <dfn id="WebGLContextAttributes">WebGL
ContextAttributes</dfn> { | |
602 attribute boolean alpha; | |
603 attribute boolean depth; | |
604 attribute boolean stencil; | |
605 attribute boolean antialias; | |
606 attribute boolean premultipliedAlpha; | |
607 attribute boolean preserveDrawingBuffer; | |
608 };</pre> | |
609 | |
610 <h4>Context creation parameters</h4> | |
611 | |
612 <p> | |
613 The following list describes each attribute in the WebGLContextAttribute
s object and its | |
614 use. For each attribute the default value is shown. The default value is
used either if no | |
615 second parameter is passed to <code>getContext</code>, or if a native ob
ject is passed which | |
616 has no attribute of the given name. | |
617 </p> | |
618 <dl> | |
619 <dt><span class=prop-value>alpha</span></dt> | |
620 <dd> | |
621 <em>Default: true</em>. If the value is true, the drawing buffer
has an alpha | |
622 channel for the purposes of performing OpenGL destination alpha
operations and | |
623 compositing with the page. If the value is false, no alpha buffe
r is available. | |
624 </dd> | |
625 <dt> <span class=prop-value>depth</span> | |
626 <dd> | |
627 <em>Default: true</em>. If the value is true, the drawing buffer
has a depth | |
628 buffer of at least 16 bits. If the value is false, no depth buff
er is | |
629 available. | |
630 </dd> | |
631 <dt> <span class=prop-value>stencil</span> | |
632 <dd> | |
633 <em>Default: false</em>. If the value is true, the drawing buffe
r has a stencil | |
634 buffer of at least 8 bits. If the value is false, no stencil buf
fer is | |
635 available. | |
636 </dd> | |
637 <dt> <span class=prop-value>antialias</span> | |
638 <dd> | |
639 <em>Default: true</em>. If the value is true and the implementat
ion supports | |
640 antialiasing the drawing buffer will perform antialiasing using
its choice of | |
641 technique (multisample/supersample) and quality. If the value is
false or the | |
642 implementation does not support antialiasing, no antialiasing is
performed. | |
643 </dd> | |
644 <dt> <span class=prop-value>premultipliedAlpha</span> | |
645 <dd> | |
646 <em>Default: true</em>. If the value is true the page compositor
will assume the | |
647 drawing buffer contains colors with premultiplied alpha. If the
value is false the | |
648 page compositor will assume that colors in the drawing buffer ar
e not | |
649 premultiplied. This flag is ignored if the <strong>alpha</strong
> flag is | |
650 false. See <a href="#PREMULTIPLIED_ALPHA">Premultiplied Alpha</a
> for more | |
651 information on the effects of the <code>premultipliedAlpha</code
> flag. | |
652 </dd> | |
653 <dt> <span class=prop-value>preserveDrawingBuffer</span> | |
654 <dd> | |
655 <em>Default: false</em>. If false, once the drawing buffer is pr
esented | |
656 as described in the<a href="#THE_DRAWING_BUFFER">Drawing Buffer<
/a> section, | |
657 the contents of the drawing buffer are cleared to their default
values. | |
658 All elements of the drawing buffer (color, depth and stencil) ar
e cleared. | |
659 If the value is true the buffers will not be cleared and will pr
eserve | |
660 their values until cleared or overwritten by the author. | |
661 <blockquote> | |
662 <em> | |
663 On some hardware setting the <code>preserveDrawingBuffer</co
de> flag | |
664 to true can have significant performance implications. | |
665 </em> | |
666 </blockquote> | |
667 </dd> | |
668 </dl> | |
669 <div class="example"> | |
670 Here is an ECMAScript example which passes a WebGLContextAttributes argument | |
671 to <code>getContext</code>. It assumes the presence of a canvas element nam
ed "canvas1" on the | |
672 page. | |
673 | |
674 <pre> | |
675 var canvas = document.getElementById('canvas1'); | |
676 var context = canvas.getContext('webgl', | |
677 { antialias: false, | |
678 stencil: true }); | |
679 </pre> | |
680 </div> | |
681 | |
682 <!-- ===========================================================================
============================ --> | |
683 | |
684 <h3>WebGLObject</h3> | |
685 | |
686 <p> | |
687 The <code>WebGLObject</code> interface is the parent interface for all G
L objects. | |
688 </p> | |
689 <pre class="idl">interface <dfn id="WebGLObject">WebGLObject</dfn> { | |
690 };</pre> | |
691 | |
692 <!-- ===========================================================================
============================ --> | |
693 | |
694 <h3>WebGLBuffer</h3> | |
695 | |
696 <p> | |
697 The <code>WebGLBuffer</code> interface represents an OpenGL Buffer Objec
t. The | |
698 underlying object is created as if by calling glGenBuffers | |
699 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.9</a
>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/ma
n/xhtml/glGenBuffers.xml">man page</a>)</span> | |
700 , bound as if by calling glBindBuffer | |
701 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.9</a
>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/ma
n/xhtml/glBindBuffer.xml">man page</a>)</span> | |
702 and destroyed as if by calling glDeleteBuffers | |
703 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.9</a
>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/ma
n/xhtml/glDeleteBuffers.xml">man page</a>)</span> | |
704 . | |
705 </p> | |
706 <pre class="idl">interface <dfn id="WebGLBuffer">WebGLBuffer</dfn> : WebGLOb
ject { | |
707 };</pre> | |
708 | |
709 <!-- ===========================================================================
============================ --> | |
710 | |
711 <h3><a name="WEBGL_FRAMEBUFFER">WebGLFramebuffer</a></h3> | |
712 | |
713 <p> | |
714 The <code>WebGLFramebuffer</code> interface represents an OpenGL Framebu
ffer Object. The | |
715 underlying object is created as if by calling glGenFramebuffers | |
716 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §4.4.
1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glGenFramebuffers.xml">man page</a>)</span> | |
717 , bound as if by calling glBindFramebuffer | |
718 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §4.4.
1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBindFramebuffer.xml">man page</a>)</span> | |
719 and destroyed as if by calling glDeleteFramebuffers | |
720 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §4.4.
1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glDeleteFramebuffers.xml">man page</a>)</span> | |
721 . | |
722 </p> | |
723 <pre class="idl">interface <dfn id="WebGLFramebuffer">WebGLFramebuffer</dfn>
: WebGLObject { | |
724 };</pre> | |
725 | |
726 <!-- ===========================================================================
============================ --> | |
727 | |
728 <h3>WebGLProgram</h3> | |
729 | |
730 <p> | |
731 The <code>WebGLProgram</code> interface represents an OpenGL Program Obj
ect. The | |
732 underlying object is created as if by calling glCreateProgram | |
733 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §2.1
0.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glCreateProgram.xml">man page</a>)</span> | |
734 , used as if by calling glUseProgram | |
735 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §2.1
0.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glUseProgram.xml">man page</a>)</span> | |
736 and destroyed as if by calling glDeleteProgram | |
737 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §2.1
0.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glDeleteProgram.xml">man page</a>)</span> | |
738 . | |
739 </p> | |
740 <pre class="idl">interface <dfn id="WebGLProgram">WebGLProgram</dfn> : WebGL
Object { | |
741 };</pre> | |
742 | |
743 <!-- ===========================================================================
============================ --> | |
744 | |
745 <h3>WebGLRenderbuffer</h3> | |
746 | |
747 <p> | |
748 The <code>WebGLRenderbuffer</code> interface represents an OpenGL Render
buffer Object. The | |
749 underlying object is created as if by calling glGenRenderbuffers | |
750 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §4.4.
3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glGenRenderbuffers.xml">man page</a>)</span> | |
751 , bound as if by calling glBindRenderbuffer | |
752 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §4.4.
3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBindRenderbuffer.xml">man page</a>)</span> | |
753 and destroyed as if by calling glDeleteRenderbuffers | |
754 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §4.4.
3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glDeleteRenderbuffers.xml">man page</a>)</span> | |
755 . | |
756 </p> | |
757 <pre class="idl">interface <dfn id="WebGLRenderbuffer">WebGLRenderbuffer</df
n> : WebGLObject { | |
758 };</pre> | |
759 | |
760 <!-- ===========================================================================
============================ --> | |
761 | |
762 <h3>WebGLShader</h3> | |
763 | |
764 <p> | |
765 The <code>WebGLShader</code> interface represents an OpenGL Shader Objec
t. The | |
766 underlying object is created as if by calling glCreateShader | |
767 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §2.1
0.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glCreateShader.xml">man page</a>)</span> | |
768 , attached to a Program as if by calling glAttachShader | |
769 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §2.1
0.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glAttachShader.xml">man page</a>)</span> | |
770 and destroyed as if by calling glDeleteShader | |
771 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §2.1
0.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glDeleteShader.xml">man page</a>)</span> | |
772 . | |
773 </p> | |
774 <pre class="idl">interface <dfn id="WebGLShader">WebGLShader</dfn> : WebGLOb
ject { | |
775 };</pre> | |
776 | |
777 <!-- ===========================================================================
============================ --> | |
778 | |
779 <h3>WebGLTexture</h3> | |
780 | |
781 <p> | |
782 The <code>WebGLTexture</code> interface represents an OpenGL Texture Obj
ect. The | |
783 underlying object is created as if by calling glGenTextures | |
784 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §3.7
.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glGenTextures.xml">man page</a>)</span> | |
785 , bound as if by calling glBindTexture | |
786 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §3.7
.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glBindTexture.xml">man page</a>)</span> | |
787 and destroyed as if by calling glDeleteTextures | |
788 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/spe
cs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §3.7
.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/d
ocs/man/xhtml/glDeleteTextures.xml">man page</a>)</span> | |
789 . | |
790 </p> | |
791 <pre class="idl">interface <dfn id="WebGLTexture">WebGLTexture</dfn> : WebGL
Object { | |
792 };</pre> | |
793 | |
794 <!-- ===========================================================================
============================ --> | |
795 | |
796 <h3>WebGLUniformLocation</h3> | |
797 | |
798 <p> | |
799 The <code>WebGLUniformLocation</code> interface represents the location
of a uniform variable | |
800 in a shader program. | |
801 </p> | |
802 <pre class="idl">interface <dfn id="WebGLUniformLocation">WebGLUniformLocati
on</dfn> { | |
803 };</pre> | |
804 | |
805 <!-- ===========================================================================
============================ --> | |
806 | |
807 <h3>WebGLActiveInfo</h3> | |
808 | |
809 <p> | |
810 The <code>WebGLActiveInfo</code> interface represents the information re
turned | |
811 from the getActiveAttrib and getActiveUniform calls. | |
812 </p> | |
813 <pre class="idl">interface <dfn id="WebGLActiveInfo">WebGLActiveInfo</dfn> { | |
814 readonly attribute GLint size; | |
815 readonly attribute GLenum type; | |
816 readonly attribute DOMString name; | |
817 };</pre> | |
818 | |
819 <h4>Attributes</h4> | |
820 | |
821 <p> | |
822 The following attributes are available: | |
823 </p> | |
824 | |
825 <dl class="methods"> | |
826 <dt> | |
827 <code class=attribute-name> | |
828 <a id="DOM-WebGLActiveInfo-size"> | |
829 size | |
830 </a> | |
831 </code> | |
832 of type <code>GLint</code> | |
833 <dd> | |
834 The size of the requested variable. | |
835 <dt> | |
836 <code class=attribute-name> | |
837 <a id="DOM-WebGLActiveInfo-type"> | |
838 type | |
839 </a> | |
840 </code> | |
841 of type <code>GLenum</code> | |
842 <dd> | |
843 The data type of the requested variable. | |
844 <dt> | |
845 <code class=attribute-name> | |
846 <a id="DOM-WebGLActiveInfo-name"> | |
847 name | |
848 </a> | |
849 </code> | |
850 of type <code>DOMString</code> | |
851 <dd> | |
852 The name of the requested variable. | |
853 </dl> | |
854 | |
855 <!-- ===========================================================================
============================ --> | |
856 | |
857 <h3><a name="ARRAYBUFFER">ArrayBuffer</a> and <a name="TYPEDARRAY">Typed Arr
ays</a></h3> | |
858 | |
859 <p> | |
860 Vertex, index, texture, and other data is transferred to the WebGL imple
mentation using | |
861 the <a href="../../../typedarray/specs/latest/#ARRAYBUFFER">ArrayBuffer<
/a> | |
862 and <a href="../../../typedarray/specs/latest/#TYPEDARRAYS">views</a> de
fined in | |
863 the <a href="../../../typedarray/specs/latest/">Typed Array</a> | |
864 specification <a href="#refsTYPEDARRAYS">[TYPEDARRAYS]</a>. | |
865 </p> | |
866 <p> | |
867 Typed Arrays support the creation of interleaved, heterogeneous vertex d
ata; uploading of | |
868 distinct blocks of data into a large vertex buffer object; and most othe
r use cases required | |
869 by OpenGL programs. | |
870 </p> | |
871 | |
872 <div class="example"> | |
873 Here is an ECMAScript example showing access to the same ArrayBuffer using d
ifferent types of | |
874 typed arrays. In this case the buffer contains a floating point vertex posit
ion (x, y, z) | |
875 followed by a color as 4 unsigned bytes (r, g, b, a). | |
876 | |
877 <pre> | |
878 var numVertices = 100; // for example | |
879 | |
880 // Compute the size needed for the buffer, in bytes and floats | |
881 var vertexSize = 3 * Float32Array.BYTES_PER_ELEMENT + | |
882 4 * Uint8Array.BYTES_PER_ELEMENT; | |
883 var vertexSizeInFloats = vertexSize / Float32Array.BYTES_PER_ELEMENT; | |
884 | |
885 // Allocate the buffer | |
886 var buf = new ArrayBuffer(numVertices * vertexSize); | |
887 | |
888 // Map this buffer to a Float32Array to access the positions | |
889 var positionArray = new Float32Array(buf); | |
890 | |
891 // Map the same buffer to a Uint8Array to access the color | |
892 var colorArray = new Uint8Array(buf); | |
893 | |
894 // Set up the initial offset of the vertices and colors within the buffer | |
895 var positionIdx = 0; | |
896 var colorIdx = 3 * Float32Array.BYTES_PER_ELEMENT; | |
897 | |
898 // Initialize the buffer | |
899 for (var i = 0; i < numVertices; i++) { | |
900 positionArray[positionIdx] = ...; | |
901 positionArray[positionIdx + 1] = ...; | |
902 positionArray[positionIdx + 2] = ...; | |
903 colorArray[colorIdx] = ...; | |
904 colorArray[colorIdx + 1] = ...; | |
905 colorArray[colorIdx + 2] = ...; | |
906 colorArray[colorIdx + 3] = ...; | |
907 positionIdx += vertexSizeInFloats; | |
908 colorIdx += vertexSize; | |
909 } | |
910 </pre> | |
911 </div> | |
912 | |
913 <!-- ===========================================================================
============================ --> | |
914 | |
915 <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3> | |
916 | |
917 <p> | |
918 The <code>WebGLRenderingContext</code> represents the API allowing | |
919 OpenGL ES 2.0 style rendering into the canvas element. | |
920 </p> | |
921 <pre class="idl">interface <dfn id="WebGLRenderingContext">WebGLRenderingCon
text</dfn> { | |
922 | |
923 /* ClearBufferMask */ | |
924 const GLenum DEPTH_BUFFER_BIT = 0x00000100; | |
925 const GLenum STENCIL_BUFFER_BIT = 0x00000400; | |
926 const GLenum COLOR_BUFFER_BIT = 0x00004000; | |
927 | |
928 /* BeginMode */ | |
929 const GLenum POINTS = 0x0000; | |
930 const GLenum LINES = 0x0001; | |
931 const GLenum LINE_LOOP = 0x0002; | |
932 const GLenum LINE_STRIP = 0x0003; | |
933 const GLenum TRIANGLES = 0x0004; | |
934 const GLenum TRIANGLE_STRIP = 0x0005; | |
935 const GLenum TRIANGLE_FAN = 0x0006; | |
936 | |
937 /* AlphaFunction (not supported in ES20) */ | |
938 /* NEVER */ | |
939 /* LESS */ | |
940 /* EQUAL */ | |
941 /* LEQUAL */ | |
942 /* GREATER */ | |
943 /* NOTEQUAL */ | |
944 /* GEQUAL */ | |
945 /* ALWAYS */ | |
946 | |
947 /* BlendingFactorDest */ | |
948 const GLenum ZERO = 0; | |
949 const GLenum ONE = 1; | |
950 const GLenum SRC_COLOR = 0x0300; | |
951 const GLenum ONE_MINUS_SRC_COLOR = 0x0301; | |
952 const GLenum SRC_ALPHA = 0x0302; | |
953 const GLenum ONE_MINUS_SRC_ALPHA = 0x0303; | |
954 const GLenum DST_ALPHA = 0x0304; | |
955 const GLenum ONE_MINUS_DST_ALPHA = 0x0305; | |
956 | |
957 /* BlendingFactorSrc */ | |
958 /* ZERO */ | |
959 /* ONE */ | |
960 const GLenum DST_COLOR = 0x0306; | |
961 const GLenum ONE_MINUS_DST_COLOR = 0x0307; | |
962 const GLenum SRC_ALPHA_SATURATE = 0x0308; | |
963 /* SRC_ALPHA */ | |
964 /* ONE_MINUS_SRC_ALPHA */ | |
965 /* DST_ALPHA */ | |
966 /* ONE_MINUS_DST_ALPHA */ | |
967 | |
968 /* BlendEquationSeparate */ | |
969 const GLenum FUNC_ADD = 0x8006; | |
970 const GLenum BLEND_EQUATION = 0x8009; | |
971 const GLenum BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQU
ATION */ | |
972 const GLenum BLEND_EQUATION_ALPHA = 0x883D; | |
973 | |
974 /* BlendSubtract */ | |
975 const GLenum FUNC_SUBTRACT = 0x800A; | |
976 const GLenum FUNC_REVERSE_SUBTRACT = 0x800B; | |
977 | |
978 /* Separate Blend Functions */ | |
979 const GLenum BLEND_DST_RGB = 0x80C8; | |
980 const GLenum BLEND_SRC_RGB = 0x80C9; | |
981 const GLenum BLEND_DST_ALPHA = 0x80CA; | |
982 const GLenum BLEND_SRC_ALPHA = 0x80CB; | |
983 const GLenum CONSTANT_COLOR = 0x8001; | |
984 const GLenum ONE_MINUS_CONSTANT_COLOR = 0x8002; | |
985 const GLenum CONSTANT_ALPHA = 0x8003; | |
986 const GLenum ONE_MINUS_CONSTANT_ALPHA = 0x8004; | |
987 const GLenum BLEND_COLOR = 0x8005; | |
988 | |
989 /* Buffer Objects */ | |
990 const GLenum ARRAY_BUFFER = 0x8892; | |
991 const GLenum ELEMENT_ARRAY_BUFFER = 0x8893; | |
992 const GLenum ARRAY_BUFFER_BINDING = 0x8894; | |
993 const GLenum ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; | |
994 | |
995 const GLenum STREAM_DRAW = 0x88E0; | |
996 const GLenum STATIC_DRAW = 0x88E4; | |
997 const GLenum DYNAMIC_DRAW = 0x88E8; | |
998 | |
999 const GLenum BUFFER_SIZE = 0x8764; | |
1000 const GLenum BUFFER_USAGE = 0x8765; | |
1001 | |
1002 const GLenum CURRENT_VERTEX_ATTRIB = 0x8626; | |
1003 | |
1004 /* CullFaceMode */ | |
1005 const GLenum FRONT = 0x0404; | |
1006 const GLenum BACK = 0x0405; | |
1007 const GLenum FRONT_AND_BACK = 0x0408; | |
1008 | |
1009 /* DepthFunction */ | |
1010 /* NEVER */ | |
1011 /* LESS */ | |
1012 /* EQUAL */ | |
1013 /* LEQUAL */ | |
1014 /* GREATER */ | |
1015 /* NOTEQUAL */ | |
1016 /* GEQUAL */ | |
1017 /* ALWAYS */ | |
1018 | |
1019 /* EnableCap */ | |
1020 /* TEXTURE_2D */ | |
1021 const GLenum CULL_FACE = 0x0B44; | |
1022 const GLenum BLEND = 0x0BE2; | |
1023 const GLenum DITHER = 0x0BD0; | |
1024 const GLenum STENCIL_TEST = 0x0B90; | |
1025 const GLenum DEPTH_TEST = 0x0B71; | |
1026 const GLenum SCISSOR_TEST = 0x0C11; | |
1027 const GLenum POLYGON_OFFSET_FILL = 0x8037; | |
1028 const GLenum SAMPLE_ALPHA_TO_COVERAGE = 0x809E; | |
1029 const GLenum SAMPLE_COVERAGE = 0x80A0; | |
1030 | |
1031 /* ErrorCode */ | |
1032 const GLenum NO_ERROR = 0; | |
1033 const GLenum INVALID_ENUM = 0x0500; | |
1034 const GLenum INVALID_VALUE = 0x0501; | |
1035 const GLenum INVALID_OPERATION = 0x0502; | |
1036 const GLenum OUT_OF_MEMORY = 0x0505; | |
1037 | |
1038 /* FrontFaceDirection */ | |
1039 const GLenum CW = 0x0900; | |
1040 const GLenum CCW = 0x0901; | |
1041 | |
1042 /* GetPName */ | |
1043 const GLenum LINE_WIDTH = 0x0B21; | |
1044 const GLenum ALIASED_POINT_SIZE_RANGE = 0x846D; | |
1045 const GLenum ALIASED_LINE_WIDTH_RANGE = 0x846E; | |
1046 const GLenum CULL_FACE_MODE = 0x0B45; | |
1047 const GLenum FRONT_FACE = 0x0B46; | |
1048 const GLenum DEPTH_RANGE = 0x0B70; | |
1049 const GLenum DEPTH_WRITEMASK = 0x0B72; | |
1050 const GLenum DEPTH_CLEAR_VALUE = 0x0B73; | |
1051 const GLenum DEPTH_FUNC = 0x0B74; | |
1052 const GLenum STENCIL_CLEAR_VALUE = 0x0B91; | |
1053 const GLenum STENCIL_FUNC = 0x0B92; | |
1054 const GLenum STENCIL_FAIL = 0x0B94; | |
1055 const GLenum STENCIL_PASS_DEPTH_FAIL = 0x0B95; | |
1056 const GLenum STENCIL_PASS_DEPTH_PASS = 0x0B96; | |
1057 const GLenum STENCIL_REF = 0x0B97; | |
1058 const GLenum STENCIL_VALUE_MASK = 0x0B93; | |
1059 const GLenum STENCIL_WRITEMASK = 0x0B98; | |
1060 const GLenum STENCIL_BACK_FUNC = 0x8800; | |
1061 const GLenum STENCIL_BACK_FAIL = 0x8801; | |
1062 const GLenum STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; | |
1063 const GLenum STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; | |
1064 const GLenum STENCIL_BACK_REF = 0x8CA3; | |
1065 const GLenum STENCIL_BACK_VALUE_MASK = 0x8CA4; | |
1066 const GLenum STENCIL_BACK_WRITEMASK = 0x8CA5; | |
1067 const GLenum VIEWPORT = 0x0BA2; | |
1068 const GLenum SCISSOR_BOX = 0x0C10; | |
1069 /* SCISSOR_TEST */ | |
1070 const GLenum COLOR_CLEAR_VALUE = 0x0C22; | |
1071 const GLenum COLOR_WRITEMASK = 0x0C23; | |
1072 const GLenum UNPACK_ALIGNMENT = 0x0CF5; | |
1073 const GLenum PACK_ALIGNMENT = 0x0D05; | |
1074 const GLenum MAX_TEXTURE_SIZE = 0x0D33; | |
1075 const GLenum MAX_VIEWPORT_DIMS = 0x0D3A; | |
1076 const GLenum SUBPIXEL_BITS = 0x0D50; | |
1077 const GLenum RED_BITS = 0x0D52; | |
1078 const GLenum GREEN_BITS = 0x0D53; | |
1079 const GLenum BLUE_BITS = 0x0D54; | |
1080 const GLenum ALPHA_BITS = 0x0D55; | |
1081 const GLenum DEPTH_BITS = 0x0D56; | |
1082 const GLenum STENCIL_BITS = 0x0D57; | |
1083 const GLenum POLYGON_OFFSET_UNITS = 0x2A00; | |
1084 /* POLYGON_OFFSET_FILL */ | |
1085 const GLenum POLYGON_OFFSET_FACTOR = 0x8038; | |
1086 const GLenum TEXTURE_BINDING_2D = 0x8069; | |
1087 const GLenum SAMPLE_BUFFERS = 0x80A8; | |
1088 const GLenum SAMPLES = 0x80A9; | |
1089 const GLenum SAMPLE_COVERAGE_VALUE = 0x80AA; | |
1090 const GLenum SAMPLE_COVERAGE_INVERT = 0x80AB; | |
1091 | |
1092 /* GetTextureParameter */ | |
1093 /* TEXTURE_MAG_FILTER */ | |
1094 /* TEXTURE_MIN_FILTER */ | |
1095 /* TEXTURE_WRAP_S */ | |
1096 /* TEXTURE_WRAP_T */ | |
1097 | |
1098 const GLenum NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2; | |
1099 const GLenum COMPRESSED_TEXTURE_FORMATS = 0x86A3; | |
1100 | |
1101 /* HintMode */ | |
1102 const GLenum DONT_CARE = 0x1100; | |
1103 const GLenum FASTEST = 0x1101; | |
1104 const GLenum NICEST = 0x1102; | |
1105 | |
1106 /* HintTarget */ | |
1107 const GLenum GENERATE_MIPMAP_HINT = 0x8192; | |
1108 | |
1109 /* DataType */ | |
1110 const GLenum BYTE = 0x1400; | |
1111 const GLenum UNSIGNED_BYTE = 0x1401; | |
1112 const GLenum SHORT = 0x1402; | |
1113 const GLenum UNSIGNED_SHORT = 0x1403; | |
1114 const GLenum INT = 0x1404; | |
1115 const GLenum UNSIGNED_INT = 0x1405; | |
1116 const GLenum FLOAT = 0x1406; | |
1117 | |
1118 /* PixelFormat */ | |
1119 const GLenum DEPTH_COMPONENT = 0x1902; | |
1120 const GLenum ALPHA = 0x1906; | |
1121 const GLenum RGB = 0x1907; | |
1122 const GLenum RGBA = 0x1908; | |
1123 const GLenum LUMINANCE = 0x1909; | |
1124 const GLenum LUMINANCE_ALPHA = 0x190A; | |
1125 | |
1126 /* PixelType */ | |
1127 /* UNSIGNED_BYTE */ | |
1128 const GLenum UNSIGNED_SHORT_4_4_4_4 = 0x8033; | |
1129 const GLenum UNSIGNED_SHORT_5_5_5_1 = 0x8034; | |
1130 const GLenum UNSIGNED_SHORT_5_6_5 = 0x8363; | |
1131 | |
1132 /* Shaders */ | |
1133 const GLenum FRAGMENT_SHADER = 0x8B30; | |
1134 const GLenum VERTEX_SHADER = 0x8B31; | |
1135 const GLenum MAX_VERTEX_ATTRIBS = 0x8869; | |
1136 const GLenum MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; | |
1137 const GLenum MAX_VARYING_VECTORS = 0x8DFC; | |
1138 const GLenum MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; | |
1139 const GLenum MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; | |
1140 const GLenum MAX_TEXTURE_IMAGE_UNITS = 0x8872; | |
1141 const GLenum MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; | |
1142 const GLenum SHADER_TYPE = 0x8B4F; | |
1143 const GLenum DELETE_STATUS = 0x8B80; | |
1144 const GLenum LINK_STATUS = 0x8B82; | |
1145 const GLenum VALIDATE_STATUS = 0x8B83; | |
1146 const GLenum ATTACHED_SHADERS = 0x8B85; | |
1147 const GLenum ACTIVE_UNIFORMS = 0x8B86; | |
1148 const GLenum ACTIVE_ATTRIBUTES = 0x8B89; | |
1149 const GLenum SHADING_LANGUAGE_VERSION = 0x8B8C; | |
1150 const GLenum CURRENT_PROGRAM = 0x8B8D; | |
1151 | |
1152 /* StencilFunction */ | |
1153 const GLenum NEVER = 0x0200; | |
1154 const GLenum LESS = 0x0201; | |
1155 const GLenum EQUAL = 0x0202; | |
1156 const GLenum LEQUAL = 0x0203; | |
1157 const GLenum GREATER = 0x0204; | |
1158 const GLenum NOTEQUAL = 0x0205; | |
1159 const GLenum GEQUAL = 0x0206; | |
1160 const GLenum ALWAYS = 0x0207; | |
1161 | |
1162 /* StencilOp */ | |
1163 /* ZERO */ | |
1164 const GLenum KEEP = 0x1E00; | |
1165 const GLenum REPLACE = 0x1E01; | |
1166 const GLenum INCR = 0x1E02; | |
1167 const GLenum DECR = 0x1E03; | |
1168 const GLenum INVERT = 0x150A; | |
1169 const GLenum INCR_WRAP = 0x8507; | |
1170 const GLenum DECR_WRAP = 0x8508; | |
1171 | |
1172 /* StringName */ | |
1173 const GLenum VENDOR = 0x1F00; | |
1174 const GLenum RENDERER = 0x1F01; | |
1175 const GLenum VERSION = 0x1F02; | |
1176 | |
1177 /* TextureMagFilter */ | |
1178 const GLenum NEAREST = 0x2600; | |
1179 const GLenum LINEAR = 0x2601; | |
1180 | |
1181 /* TextureMinFilter */ | |
1182 /* NEAREST */ | |
1183 /* LINEAR */ | |
1184 const GLenum NEAREST_MIPMAP_NEAREST = 0x2700; | |
1185 const GLenum LINEAR_MIPMAP_NEAREST = 0x2701; | |
1186 const GLenum NEAREST_MIPMAP_LINEAR = 0x2702; | |
1187 const GLenum LINEAR_MIPMAP_LINEAR = 0x2703; | |
1188 | |
1189 /* TextureParameterName */ | |
1190 const GLenum TEXTURE_MAG_FILTER = 0x2800; | |
1191 const GLenum TEXTURE_MIN_FILTER = 0x2801; | |
1192 const GLenum TEXTURE_WRAP_S = 0x2802; | |
1193 const GLenum TEXTURE_WRAP_T = 0x2803; | |
1194 | |
1195 /* TextureTarget */ | |
1196 const GLenum TEXTURE_2D = 0x0DE1; | |
1197 const GLenum TEXTURE = 0x1702; | |
1198 | |
1199 const GLenum TEXTURE_CUBE_MAP = 0x8513; | |
1200 const GLenum TEXTURE_BINDING_CUBE_MAP = 0x8514; | |
1201 const GLenum TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; | |
1202 const GLenum TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; | |
1203 const GLenum TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; | |
1204 const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; | |
1205 const GLenum TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; | |
1206 const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; | |
1207 const GLenum MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; | |
1208 | |
1209 /* TextureUnit */ | |
1210 const GLenum TEXTURE0 = 0x84C0; | |
1211 const GLenum TEXTURE1 = 0x84C1; | |
1212 const GLenum TEXTURE2 = 0x84C2; | |
1213 const GLenum TEXTURE3 = 0x84C3; | |
1214 const GLenum TEXTURE4 = 0x84C4; | |
1215 const GLenum TEXTURE5 = 0x84C5; | |
1216 const GLenum TEXTURE6 = 0x84C6; | |
1217 const GLenum TEXTURE7 = 0x84C7; | |
1218 const GLenum TEXTURE8 = 0x84C8; | |
1219 const GLenum TEXTURE9 = 0x84C9; | |
1220 const GLenum TEXTURE10 = 0x84CA; | |
1221 const GLenum TEXTURE11 = 0x84CB; | |
1222 const GLenum TEXTURE12 = 0x84CC; | |
1223 const GLenum TEXTURE13 = 0x84CD; | |
1224 const GLenum TEXTURE14 = 0x84CE; | |
1225 const GLenum TEXTURE15 = 0x84CF; | |
1226 const GLenum TEXTURE16 = 0x84D0; | |
1227 const GLenum TEXTURE17 = 0x84D1; | |
1228 const GLenum TEXTURE18 = 0x84D2; | |
1229 const GLenum TEXTURE19 = 0x84D3; | |
1230 const GLenum TEXTURE20 = 0x84D4; | |
1231 const GLenum TEXTURE21 = 0x84D5; | |
1232 const GLenum TEXTURE22 = 0x84D6; | |
1233 const GLenum TEXTURE23 = 0x84D7; | |
1234 const GLenum TEXTURE24 = 0x84D8; | |
1235 const GLenum TEXTURE25 = 0x84D9; | |
1236 const GLenum TEXTURE26 = 0x84DA; | |
1237 const GLenum TEXTURE27 = 0x84DB; | |
1238 const GLenum TEXTURE28 = 0x84DC; | |
1239 const GLenum TEXTURE29 = 0x84DD; | |
1240 const GLenum TEXTURE30 = 0x84DE; | |
1241 const GLenum TEXTURE31 = 0x84DF; | |
1242 const GLenum ACTIVE_TEXTURE = 0x84E0; | |
1243 | |
1244 /* TextureWrapMode */ | |
1245 const GLenum REPEAT = 0x2901; | |
1246 const GLenum CLAMP_TO_EDGE = 0x812F; | |
1247 const GLenum MIRRORED_REPEAT = 0x8370; | |
1248 | |
1249 /* Uniform Types */ | |
1250 const GLenum FLOAT_VEC2 = 0x8B50; | |
1251 const GLenum FLOAT_VEC3 = 0x8B51; | |
1252 const GLenum FLOAT_VEC4 = 0x8B52; | |
1253 const GLenum INT_VEC2 = 0x8B53; | |
1254 const GLenum INT_VEC3 = 0x8B54; | |
1255 const GLenum INT_VEC4 = 0x8B55; | |
1256 const GLenum BOOL = 0x8B56; | |
1257 const GLenum BOOL_VEC2 = 0x8B57; | |
1258 const GLenum BOOL_VEC3 = 0x8B58; | |
1259 const GLenum BOOL_VEC4 = 0x8B59; | |
1260 const GLenum FLOAT_MAT2 = 0x8B5A; | |
1261 const GLenum FLOAT_MAT3 = 0x8B5B; | |
1262 const GLenum FLOAT_MAT4 = 0x8B5C; | |
1263 const GLenum SAMPLER_2D = 0x8B5E; | |
1264 const GLenum SAMPLER_CUBE = 0x8B60; | |
1265 | |
1266 /* Vertex Arrays */ | |
1267 const GLenum VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; | |
1268 const GLenum VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; | |
1269 const GLenum VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; | |
1270 const GLenum VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; | |
1271 const GLenum VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; | |
1272 const GLenum VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; | |
1273 const GLenum VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; | |
1274 | |
1275 /* Shader Source */ | |
1276 const GLenum COMPILE_STATUS = 0x8B81; | |
1277 | |
1278 /* Shader Precision-Specified Types */ | |
1279 const GLenum LOW_FLOAT = 0x8DF0; | |
1280 const GLenum MEDIUM_FLOAT = 0x8DF1; | |
1281 const GLenum HIGH_FLOAT = 0x8DF2; | |
1282 const GLenum LOW_INT = 0x8DF3; | |
1283 const GLenum MEDIUM_INT = 0x8DF4; | |
1284 const GLenum HIGH_INT = 0x8DF5; | |
1285 | |
1286 /* Framebuffer Object. */ | |
1287 const GLenum FRAMEBUFFER = 0x8D40; | |
1288 const GLenum RENDERBUFFER = 0x8D41; | |
1289 | |
1290 const GLenum RGBA4 = 0x8056; | |
1291 const GLenum RGB5_A1 = 0x8057; | |
1292 const GLenum RGB565 = 0x8D62; | |
1293 const GLenum DEPTH_COMPONENT16 = 0x81A5; | |
1294 const GLenum STENCIL_INDEX = 0x1901; | |
1295 const GLenum STENCIL_INDEX8 = 0x8D48; | |
1296 const GLenum DEPTH_STENCIL = 0x84F9; | |
1297 | |
1298 const GLenum RENDERBUFFER_WIDTH = 0x8D42; | |
1299 const GLenum RENDERBUFFER_HEIGHT = 0x8D43; | |
1300 const GLenum RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; | |
1301 const GLenum RENDERBUFFER_RED_SIZE = 0x8D50; | |
1302 const GLenum RENDERBUFFER_GREEN_SIZE = 0x8D51; | |
1303 const GLenum RENDERBUFFER_BLUE_SIZE = 0x8D52; | |
1304 const GLenum RENDERBUFFER_ALPHA_SIZE = 0x8D53; | |
1305 const GLenum RENDERBUFFER_DEPTH_SIZE = 0x8D54; | |
1306 const GLenum RENDERBUFFER_STENCIL_SIZE = 0x8D55; | |
1307 | |
1308 const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; | |
1309 const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; | |
1310 const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; | |
1311 const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; | |
1312 | |
1313 const GLenum COLOR_ATTACHMENT0 = 0x8CE0; | |
1314 const GLenum DEPTH_ATTACHMENT = 0x8D00; | |
1315 const GLenum STENCIL_ATTACHMENT = 0x8D20; | |
1316 const GLenum DEPTH_STENCIL_ATTACHMENT = 0x821A; | |
1317 | |
1318 const GLenum NONE = 0; | |
1319 | |
1320 const GLenum FRAMEBUFFER_COMPLETE = 0x8CD5; | |
1321 const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; | |
1322 const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; | |
1323 const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; | |
1324 const GLenum FRAMEBUFFER_UNSUPPORTED = 0x8CDD; | |
1325 | |
1326 const GLenum FRAMEBUFFER_BINDING = 0x8CA6; | |
1327 const GLenum RENDERBUFFER_BINDING = 0x8CA7; | |
1328 const GLenum MAX_RENDERBUFFER_SIZE = 0x84E8; | |
1329 | |
1330 const GLenum INVALID_FRAMEBUFFER_OPERATION = 0x0506; | |
1331 | |
1332 /* WebGL-specific enums */ | |
1333 const GLenum UNPACK_FLIP_Y_WEBGL = 0x9240; | |
1334 const GLenum UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; | |
1335 const GLenum CONTEXT_LOST_WEBGL = 0x9242; | |
1336 const GLenum UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243; | |
1337 const GLenum BROWSER_DEFAULT_WEBGL = 0x9244; | |
1338 | |
1339 readonly attribute HTMLCanvasElement canvas; | |
1340 readonly attribute GLsizei drawingBufferWidth; | |
1341 readonly attribute GLsizei drawingBufferHeight; | |
1342 | |
1343 WebGLContextAttributes getContextAttributes(); | |
1344 boolean isContextLost(); | |
1345 | |
1346 DOMString[ ] getSupportedExtensions(); | |
1347 object getExtension(DOMString name); | |
1348 | |
1349 void activeTexture(GLenum texture); | |
1350 void attachShader(WebGLProgram program, WebGLShader shader); | |
1351 void bindAttribLocation(WebGLProgram program, GLuint index, DOMString name); | |
1352 void bindBuffer(GLenum target, WebGLBuffer buffer); | |
1353 void bindFramebuffer(GLenum target, WebGLFramebuffer framebuffer); | |
1354 void bindRenderbuffer(GLenum target, WebGLRenderbuffer renderbuffer); | |
1355 void bindTexture(GLenum target, WebGLTexture texture); | |
1356 void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
; | |
1357 void blendEquation(GLenum mode); | |
1358 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); | |
1359 void blendFunc(GLenum sfactor, GLenum dfactor); | |
1360 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, | |
1361 GLenum srcAlpha, GLenum dstAlpha); | |
1362 | |
1363 void bufferData(GLenum target, GLsizeiptr size, GLenum usage); | |
1364 void bufferData(GLenum target, ArrayBufferView data, GLenum usage); | |
1365 void bufferData(GLenum target, ArrayBuffer data, GLenum usage); | |
1366 void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data); | |
1367 void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer data); | |
1368 | |
1369 GLenum checkFramebufferStatus(GLenum target); | |
1370 void clear(GLbitfield mask); | |
1371 void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
; | |
1372 void clearDepth(GLclampf depth); | |
1373 void clearStencil(GLint s); | |
1374 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp
ha); | |
1375 void compileShader(WebGLShader shader); | |
1376 | |
1377 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, | |
1378 GLint x, GLint y, GLsizei width, GLsizei height, | |
1379 GLint border); | |
1380 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
set, | |
1381 GLint x, GLint y, GLsizei width, GLsizei height); | |
1382 | |
1383 WebGLBuffer createBuffer(); | |
1384 WebGLFramebuffer createFramebuffer(); | |
1385 WebGLProgram createProgram(); | |
1386 WebGLRenderbuffer createRenderbuffer(); | |
1387 WebGLShader createShader(GLenum type); | |
1388 WebGLTexture createTexture(); | |
1389 | |
1390 void cullFace(GLenum mode); | |
1391 | |
1392 void deleteBuffer(WebGLBuffer buffer); | |
1393 void deleteFramebuffer(WebGLFramebuffer framebuffer); | |
1394 void deleteProgram(WebGLProgram program); | |
1395 void deleteRenderbuffer(WebGLRenderbuffer renderbuffer); | |
1396 void deleteShader(WebGLShader shader); | |
1397 void deleteTexture(WebGLTexture texture); | |
1398 | |
1399 void depthFunc(GLenum func); | |
1400 void depthMask(GLboolean flag); | |
1401 void depthRange(GLclampf zNear, GLclampf zFar); | |
1402 void detachShader(WebGLProgram program, WebGLShader shader); | |
1403 void disable(GLenum cap); | |
1404 void disableVertexAttribArray(GLuint index); | |
1405 void drawArrays(GLenum mode, GLint first, GLsizei count); | |
1406 void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset); | |
1407 | |
1408 void enable(GLenum cap); | |
1409 void enableVertexAttribArray(GLuint index); | |
1410 void finish(); | |
1411 void flush(); | |
1412 void framebufferRenderbuffer(GLenum target, GLenum attachment, | |
1413 GLenum renderbuffertarget, | |
1414 WebGLRenderbuffer renderbuffer); | |
1415 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget
, | |
1416 WebGLTexture texture, GLint level); | |
1417 void frontFace(GLenum mode); | |
1418 | |
1419 void generateMipmap(GLenum target); | |
1420 | |
1421 WebGLActiveInfo getActiveAttrib(WebGLProgram program, GLuint index); | |
1422 WebGLActiveInfo getActiveUniform(WebGLProgram program, GLuint index); | |
1423 WebGLShader[ ] getAttachedShaders(WebGLProgram program); | |
1424 | |
1425 GLint getAttribLocation(WebGLProgram program, DOMString name); | |
1426 | |
1427 any getParameter(GLenum pname); | |
1428 any getBufferParameter(GLenum target, GLenum pname); | |
1429 | |
1430 GLenum getError(); | |
1431 | |
1432 any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, | |
1433 GLenum pname); | |
1434 any getProgramParameter(WebGLProgram program, GLenum pname); | |
1435 DOMString getProgramInfoLog(WebGLProgram program); | |
1436 any getRenderbufferParameter(GLenum target, GLenum pname); | |
1437 any getShaderParameter(WebGLShader shader, GLenum pname); | |
1438 DOMString getShaderInfoLog(WebGLShader shader); | |
1439 | |
1440 DOMString getShaderSource(WebGLShader shader); | |
1441 | |
1442 any getTexParameter(GLenum target, GLenum pname); | |
1443 | |
1444 any getUniform(WebGLProgram program, WebGLUniformLocation location); | |
1445 | |
1446 WebGLUniformLocation getUniformLocation(WebGLProgram program, DOMString name
); | |
1447 | |
1448 any getVertexAttrib(GLuint index, GLenum pname); | |
1449 | |
1450 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname); | |
1451 | |
1452 void hint(GLenum target, GLenum mode); | |
1453 GLboolean isBuffer(WebGLBuffer buffer); | |
1454 GLboolean isEnabled(GLenum cap); | |
1455 GLboolean isFramebuffer(WebGLFramebuffer framebuffer); | |
1456 GLboolean isProgram(WebGLProgram program); | |
1457 GLboolean isRenderbuffer(WebGLRenderbuffer renderbuffer); | |
1458 GLboolean isShader(WebGLShader shader); | |
1459 GLboolean isTexture(WebGLTexture texture); | |
1460 void lineWidth(GLfloat width); | |
1461 void linkProgram(WebGLProgram program); | |
1462 void pixelStorei(GLenum pname, GLint param); | |
1463 void polygonOffset(GLfloat factor, GLfloat units); | |
1464 | |
1465 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, | |
1466 GLenum format, GLenum type, ArrayBufferView pixels); | |
1467 | |
1468 void renderbufferStorage(GLenum target, GLenum internalformat, | |
1469 GLsizei width, GLsizei height); | |
1470 void sampleCoverage(GLclampf value, GLboolean invert); | |
1471 void scissor(GLint x, GLint y, GLsizei width, GLsizei height); | |
1472 | |
1473 void shaderSource(WebGLShader shader, DOMString source); | |
1474 | |
1475 void stencilFunc(GLenum func, GLint ref, GLuint mask); | |
1476 void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); | |
1477 void stencilMask(GLuint mask); | |
1478 void stencilMaskSeparate(GLenum face, GLuint mask); | |
1479 void stencilOp(GLenum fail, GLenum zfail, GLenum zpass); | |
1480 void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
; | |
1481 | |
1482 void texImage2D(GLenum target, GLint level, GLenum internalformat, | |
1483 GLsizei width, GLsizei height, GLint border, GLenum format, | |
1484 GLenum type, ArrayBufferView pixels); | |
1485 void texImage2D(GLenum target, GLint level, GLenum internalformat, | |
1486 GLenum format, GLenum type, ImageData pixels); | |
1487 void texImage2D(GLenum target, GLint level, GLenum internalformat, | |
1488 GLenum format, GLenum type, HTMLImageElement image) raises (
DOMException); | |
1489 void texImage2D(GLenum target, GLint level, GLenum internalformat, | |
1490 GLenum format, GLenum type, HTMLCanvasElement canvas) raises
(DOMException); | |
1491 void texImage2D(GLenum target, GLint level, GLenum internalformat, | |
1492 GLenum format, GLenum type, HTMLVideoElement video) raises (
DOMException); | |
1493 | |
1494 void texParameterf(GLenum target, GLenum pname, GLfloat param); | |
1495 void texParameteri(GLenum target, GLenum pname, GLint param); | |
1496 | |
1497 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
| |
1498 GLsizei width, GLsizei height, | |
1499 GLenum format, GLenum type, ArrayBufferView pixels); | |
1500 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
| |
1501 GLenum format, GLenum type, ImageData pixels); | |
1502 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
| |
1503 GLenum format, GLenum type, HTMLImageElement image) raise
s (DOMException); | |
1504 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
| |
1505 GLenum format, GLenum type, HTMLCanvasElement canvas) rai
ses (DOMException); | |
1506 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
| |
1507 GLenum format, GLenum type, HTMLVideoElement video) raise
s (DOMException); | |
1508 | |
1509 void uniform1f(WebGLUniformLocation location, GLfloat x); | |
1510 void uniform1fv(WebGLUniformLocation location, Float32Array v); | |
1511 void uniform1fv(WebGLUniformLocation location, float[] v); | |
1512 void uniform1i(WebGLUniformLocation location, GLint x); | |
1513 void uniform1iv(WebGLUniformLocation location, Int32Array v); | |
1514 void uniform1iv(WebGLUniformLocation location, long[] v); | |
1515 void uniform2f(WebGLUniformLocation location, GLfloat x, GLfloat y); | |
1516 void uniform2fv(WebGLUniformLocation location, Float32Array v); | |
1517 void uniform2fv(WebGLUniformLocation location, float[] v); | |
1518 void uniform2i(WebGLUniformLocation location, GLint x, GLint y); | |
1519 void uniform2iv(WebGLUniformLocation location, Int32Array v); | |
1520 void uniform2iv(WebGLUniformLocation location, long[] v); | |
1521 void uniform3f(WebGLUniformLocation location, GLfloat x, GLfloat y, GLfloat
z); | |
1522 void uniform3fv(WebGLUniformLocation location, Float32Array v); | |
1523 void uniform3fv(WebGLUniformLocation location, float[] v); | |
1524 void uniform3i(WebGLUniformLocation location, GLint x, GLint y, GLint z); | |
1525 void uniform3iv(WebGLUniformLocation location, Int32Array v); | |
1526 void uniform3iv(WebGLUniformLocation location, long[] v); | |
1527 void uniform4f(WebGLUniformLocation location, GLfloat x, GLfloat y, GLfloat
z, GLfloat w); | |
1528 void uniform4fv(WebGLUniformLocation location, Float32Array v); | |
1529 void uniform4fv(WebGLUniformLocation location, float[] v); | |
1530 void uniform4i(WebGLUniformLocation location, GLint x, GLint y, GLint z, GLi
nt w); | |
1531 void uniform4iv(WebGLUniformLocation location, Int32Array v); | |
1532 void uniform4iv(WebGLUniformLocation location, long[] v); | |
1533 | |
1534 void uniformMatrix2fv(WebGLUniformLocation location, GLboolean transpose, | |
1535 Float32Array value); | |
1536 void uniformMatrix2fv(WebGLUniformLocation location, GLboolean transpose, | |
1537 float[] value); | |
1538 void uniformMatrix3fv(WebGLUniformLocation location, GLboolean transpose, | |
1539 Float32Array value); | |
1540 void uniformMatrix3fv(WebGLUniformLocation location, GLboolean transpose, | |
1541 float[] value); | |
1542 void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose, | |
1543 Float32Array value); | |
1544 void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose, | |
1545 float[] value); | |
1546 | |
1547 void useProgram(WebGLProgram program); | |
1548 void validateProgram(WebGLProgram program); | |
1549 | |
1550 void vertexAttrib1f(GLuint indx, GLfloat x); | |
1551 void vertexAttrib1fv(GLuint indx, Float32Array values); | |
1552 void vertexAttrib1fv(GLuint indx, float[] values); | |
1553 void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); | |
1554 void vertexAttrib2fv(GLuint indx, Float32Array values); | |
1555 void vertexAttrib2fv(GLuint indx, float[] values); | |
1556 void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); | |
1557 void vertexAttrib3fv(GLuint indx, Float32Array values); | |
1558 void vertexAttrib3fv(GLuint indx, float[] values); | |
1559 void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
; | |
1560 void vertexAttrib4fv(GLuint indx, Float32Array values); | |
1561 void vertexAttrib4fv(GLuint indx, float[] values); | |
1562 void vertexAttribPointer(GLuint indx, GLint size, GLenum type, | |
1563 GLboolean normalized, GLsizei stride, GLintptr offs
et); | |
1564 | |
1565 void viewport(GLint x, GLint y, GLsizei width, GLsizei height); | |
1566 };</pre> | |
1567 | |
1568 <!-- ===========================================================================
============================ --> | |
1569 | |
1570 <h4>Attributes</h4> | |
1571 | |
1572 <p> | |
1573 The following attributes are available: | |
1574 </p> | |
1575 | |
1576 <dl class="methods"> | |
1577 <dt> | |
1578 <code class=attribute-name> | |
1579 <a id="DOM-WebGLRenderingContext-canvas"> | |
1580 canvas | |
1581 </a> | |
1582 </code> | |
1583 of type <code>HTMLCanvasElement</code> | |
1584 <dd> | |
1585 A reference to the canvas element which created this context. | |
1586 | |
1587 <dt> | |
1588 <code class=attribute-name> | |
1589 <a id="DOM-WebGLRenderingContext-drawingBufferWidth"> | |
1590 drawingBufferWidth | |
1591 </a> | |
1592 </code> | |
1593 of type <code>GLsizei</code> | |
1594 <dd> | |
1595 The actual width of the drawing buffer. May be different from the | |
1596 <code>width</code> attribute of the <code>HTMLCanvasElement</code> i
f | |
1597 the implementation is unable to satisfy the requested widthor height
. | |
1598 | |
1599 <dt> | |
1600 <code class=attribute-name> | |
1601 <a id="DOM-WebGLRenderingContext-drawingBufferHeight"> | |
1602 drawingBufferHeight | |
1603 </a> | |
1604 </code> | |
1605 of type <code>GLsizei</code> | |
1606 <dd> | |
1607 The actual height of the drawing buffer. May be different from the | |
1608 <code>height</code> attribute of the <code>HTMLCanvasElement</code>
if | |
1609 the implementation is unable to satisfy the requested width or heigh
t. | |
1610 </dl> | |
1611 | |
1612 <!-- ===========================================================================
============================ --> | |
1613 | |
1614 <h4>Getting information about the context</h4> | |
1615 | |
1616 <dl class="methods"> | |
1617 <dt class="idl-code">WebGLContextAttributes getContextAttributes() | |
1618 <dd> | |
1619 Returns the WebGLContextAttributes describing the current drawing bu
ffer. | |
1620 </dl> | |
1621 | |
1622 <!-- ===========================================================================
============================ --> | |
1623 | |
1624 <h4>Setting and getting state</h4> | |
1625 | |
1626 <p> | |
1627 OpenGL ES 2.0 maintains state values for use in rendering. All the calls
in this | |
1628 group behave identically to their OpenGL counterparts unless otherwise n
oted. | |
1629 </p> | |
1630 | |
1631 <dl class="methods"> | |
1632 <dt class="idl-code">void activeTexture(GLenum texture) | |
1633 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7">OpenGL ES 2.0 §3.
7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glActiveTexture.xml">man page</a>)</span> | |
1634 <dt class="idl-code"void blendColor(GLclampf red, GLclampf green, GLclam
pf blue, GLclampf alpha) | |
1635 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 §
4.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBlendColor.xml">man page</a>)</span> | |
1636 <dt class="idl-code">void blendEquation(GLenum mode) | |
1637 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 §
4.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBlendEquation.xml">man page</a>)</span> | |
1638 <dt class="idl-code">void blendEquationSeparate(GLenum modeRGB, GLenum m
odeAlpha) | |
1639 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 §
4.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBlendEquationSeparate.xml">man page</a>)</span> | |
1640 <dt class="idl-code">void blendFunc(GLenum sfactor, GLenum dfactor) | |
1641 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 §
4.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBlendFunc.xml">man page</a>)</span> | |
1642 <dd> | |
1643 See <a href="#CONSTANT_COLOR_BLEND">Blending With Constant Color
</a> for limitations imposed | |
1644 by WebGL. | |
1645 <dt class="idl-code">void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB
, GLenum srcAlpha, GLenum dstAlpha) | |
1646 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 §
4.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBlendFuncSeparate.xml">man page</a>)</span> | |
1647 <dd> | |
1648 See <a href="#CONSTANT_COLOR_BLEND">Blending With Constant Color
</a> for limitations imposed | |
1649 by WebGL. | |
1650 <dt class="idl-code">void clearColor(GLclampf red, GLclampf green, GLcla
mpf blue, GLclampf alpha) | |
1651 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 §
4.2.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glClearColor.xml">man page</a>)</span> | |
1652 <dt class="idl-code">void clearDepth(GLclampf depth) | |
1653 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 §
4.2.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glClearDepthf.xml">man page</a>)</span> | |
1654 <dd> | |
1655 <code>depth</code> value is clamped to the range 0 to 1. | |
1656 <dt class="idl-code">void clearStencil(GLint s) | |
1657 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 §
4.2.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glClearStencil.xml">man page</a>)</span> | |
1658 <dt class="idl-code">void colorMask(GLboolean red, GLboolean green, GLbo
olean blue, GLboolean alpha) | |
1659 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 §
4.2.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glColorMask.xml">man page</a>)</span> | |
1660 <dt class="idl-code">void cullFace(GLenum mode) | |
1661 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.5.1">OpenGL ES 2.0 §
3.5.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glCullFace.xml">man page</a>)</span> | |
1662 <dt class="idl-code">void depthFunc(GLenum func) | |
1663 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.5">OpenGL ES 2.0 §
4.1.5</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glDepthFunc.xml">man page</a>)</span> | |
1664 <dt class="idl-code">void depthMask(GLboolean flag) | |
1665 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 §
4.2.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glDepthMask.xml">man page</a>)</span> | |
1666 <dt class="idl-code">void depthRange(GLclampf zNear, GLclampf zFar) | |
1667 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.12.1">OpenGL ES 2.0 §
;2.12.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glDepthRangef.xml">man page</a>)</span> | |
1668 <dd> | |
1669 <code>zNear</code> and <code>zFar</code> values are clamped to t
he range 0 to 1 and | |
1670 <code>zNear</code> must be less than or equal to <code>zFar</cod
e>; see | |
1671 <a href="#VIEWPORT_DEPTH_RANGE">Viewport Depth Range</a>. | |
1672 <dt class="idl-code">void disable(GLenum cap) | |
1673 <span class="gl-spec">(<a class="nonnormative" href="http://www.khro
nos.org/opengles/sdk/2.0/docs/man/xhtml/glDisable.xml">man page</a>)</span> | |
1674 <dt class="idl-code">void enable(GLenum cap) | |
1675 <span class="gl-spec">(<a class="nonnormative" href="http://www.khro
nos.org/opengles/sdk/2.0/docs/man/xhtml/glEnable.xml">man page</a>)</span> | |
1676 <dt class="idl-code">void frontFace(GLenum mode) | |
1677 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.5.1">OpenGL ES 2.0 §
3.5.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glFrontFace.xml">man page</a>)</span> | |
1678 <dt class="idl-code">any getParameter(GLenum pname) | |
1679 <a class="gl-spec" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glGet.xml"> | |
1680 (glGet OpenGL ES 2.0 man page) | |
1681 </a> | |
1682 <a class="gl-spec" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glGetString.xml"> | |
1683 (glGetString OpenGL ES 2.0 man page) | |
1684 </a> | |
1685 <dd> | |
1686 Return the value for the passed pname. The type returned is the natu
ral type for the | |
1687 requested pname, as given in the following table: | |
1688 <table class="foo"> | |
1689 <tr><th>pname</th><th>returned type</th></tr> | |
1690 <tr><td>ACTIVE_TEXTURE</td><td>unsigned long</td></tr> | |
1691 <tr><td>ALIASED_LINE_WIDTH_RANGE</td><td>Float32Array (with 2 el
ements)</td></tr> | |
1692 <tr><td>ALIASED_POINT_SIZE_RANGE</td><td>Float32Array (with 2 el
ements)</td></tr> | |
1693 <tr><td>ALPHA_BITS</td><td>long</td></tr> | |
1694 <tr><td>ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</td></tr> | |
1695 <tr><td>BLEND</td><td>boolean</td></tr> | |
1696 <tr><td>BLEND_COLOR</td><td>Float32Array (with 4 values)</td></t
r> | |
1697 <tr><td>BLEND_DST_ALPHA</td><td>unsigned long</td></tr> | |
1698 <tr><td>BLEND_DST_RGB</td><td>unsigned long</td></tr> | |
1699 <tr><td>BLEND_EQUATION_ALPHA</td><td>unsigned long</td></tr> | |
1700 <tr><td>BLEND_EQUATION_RGB</td><td>unsigned long</td></tr> | |
1701 <tr><td>BLEND_SRC_ALPHA</td><td>unsigned long</td></tr> | |
1702 <tr><td>BLEND_SRC_RGB</td><td>unsigned long</td></tr> | |
1703 <tr><td>BLUE_BITS</td><td>long</td></tr> | |
1704 <tr><td>COLOR_CLEAR_VALUE</td><td>Float32Array (with 4 values)</
td></tr> | |
1705 <tr><td>COLOR_WRITEMASK</td><td>boolean[] (with 4 values)</td></
tr> | |
1706 <tr><td>COMPRESSED_TEXTURE_FORMATS</td><td>null</td></tr> | |
1707 <tr><td>CULL_FACE</td><td>boolean</td></tr> | |
1708 <tr><td>CULL_FACE_MODE</td><td>unsigned long</td></tr> | |
1709 <tr><td>CURRENT_PROGRAM</td><td>WebGLProgram</td></tr> | |
1710 <tr><td>DEPTH_BITS</td><td>long</td></tr> | |
1711 <tr><td>DEPTH_CLEAR_VALUE</td><td>float</td></tr> | |
1712 <tr><td>DEPTH_FUNC</td><td>unsigned long</td></tr> | |
1713 <tr><td>DEPTH_RANGE</td><td>Float32Array (with 2 elements)</td><
/tr> | |
1714 <tr><td>DEPTH_TEST</td><td>boolean</td></tr> | |
1715 <tr><td>DEPTH_WRITEMASK</td><td>boolean</td></tr> | |
1716 <tr><td>DITHER</td><td>boolean</td></tr> | |
1717 <tr><td>ELEMENT_ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</td></t
r> | |
1718 <tr><td>FRAMEBUFFER_BINDING</td><td>WebGLFramebuffer</td></tr> | |
1719 <tr><td>FRONT_FACE</td><td>unsigned long</td></tr> | |
1720 <tr><td>GENERATE_MIPMAP_HINT</td><td>unsigned long</td></tr> | |
1721 <tr><td>GREEN_BITS</td><td>long</td></tr> | |
1722 <tr><td>LINE_WIDTH</td><td>float</td></tr> | |
1723 <tr><td>MAX_COMBINED_TEXTURE_IMAGE_UNITS</td><td>long</td></tr> | |
1724 <tr><td>MAX_CUBE_MAP_TEXTURE_SIZE</td><td>long</td></tr> | |
1725 <tr><td>MAX_FRAGMENT_UNIFORM_VECTORS</td><td>long</td></tr> | |
1726 <tr><td>MAX_RENDERBUFFER_SIZE</td><td>long</td></tr> | |
1727 <tr><td>MAX_TEXTURE_IMAGE_UNITS</td><td>long</td></tr> | |
1728 <tr><td>MAX_TEXTURE_SIZE</td><td>long</td></tr> | |
1729 <tr><td>MAX_VARYING_VECTORS</td><td>long</td></tr> | |
1730 <tr><td>MAX_VERTEX_ATTRIBS</td><td>long</td></tr> | |
1731 <tr><td>MAX_VERTEX_TEXTURE_IMAGE_UNITS</td><td>long</td></tr> | |
1732 <tr><td>MAX_VERTEX_UNIFORM_VECTORS</td><td>long</td></tr> | |
1733 <tr><td>MAX_VIEWPORT_DIMS</td><td>Int32Array (with 2 elements)</
td></tr> | |
1734 <tr><td>NUM_COMPRESSED_TEXTURE_FORMATS</td><td>long</td></tr> | |
1735 <tr><td>PACK_ALIGNMENT</td><td>long</td></tr> | |
1736 <tr><td>POLYGON_OFFSET_FACTOR</td><td>float</td></tr> | |
1737 <tr><td>POLYGON_OFFSET_FILL</td><td>boolean</td></tr> | |
1738 <tr><td>POLYGON_OFFSET_UNITS</td><td>float</td></tr> | |
1739 <tr><td>RED_BITS</td><td>long</td></tr> | |
1740 <tr><td>RENDERBUFFER_BINDING</td><td>WebGLRenderbuffer</td></tr> | |
1741 <tr><td>RENDERER</td><td>DOMString</td></tr> | |
1742 <tr><td>SAMPLE_BUFFERS</td><td>long</td></tr> | |
1743 <tr><td>SAMPLE_COVERAGE_INVERT</td><td>boolean</td></tr> | |
1744 <tr><td>SAMPLE_COVERAGE_VALUE</td><td>float</td></tr> | |
1745 <tr><td>SAMPLES</td><td>long</td></tr> | |
1746 <tr><td>SCISSOR_BOX</td><td>Int32Array (with 4 elements)</td></t
r> | |
1747 <tr><td>SCISSOR_TEST</td><td>boolean</td></tr> | |
1748 <tr><td>SHADING_LANGUAGE_VERSION</td><td>DOMString</td></tr> | |
1749 <tr><td>STENCIL_BACK_FAIL</td><td>unsigned long</td></tr> | |
1750 <tr><td>STENCIL_BACK_FUNC</td><td>unsigned long</td></tr> | |
1751 <tr><td>STENCIL_BACK_PASS_DEPTH_FAIL</td><td>unsigned long</td><
/tr> | |
1752 <tr><td>STENCIL_BACK_PASS_DEPTH_PASS</td><td>unsigned long</td><
/tr> | |
1753 <tr><td>STENCIL_BACK_REF</td><td>long</td></tr> | |
1754 <tr><td>STENCIL_BACK_VALUE_MASK</td><td>unsigned long</td></tr> | |
1755 <tr><td>STENCIL_BACK_WRITEMASK</td><td>unsigned long</td></tr> | |
1756 <tr><td>STENCIL_BITS</td><td>long</td></tr> | |
1757 <tr><td>STENCIL_CLEAR_VALUE</td><td>long</td></tr> | |
1758 <tr><td>STENCIL_FAIL</td><td>unsigned long</td></tr> | |
1759 <tr><td>STENCIL_FUNC</td><td>unsigned long</td></tr> | |
1760 <tr><td>STENCIL_PASS_DEPTH_FAIL</td><td>unsigned long</td></tr> | |
1761 <tr><td>STENCIL_PASS_DEPTH_PASS</td><td>unsigned long</td></tr> | |
1762 <tr><td>STENCIL_REF</td><td>long</td></tr> | |
1763 <tr><td>STENCIL_TEST</td><td>boolean</td></tr> | |
1764 <tr><td>STENCIL_VALUE_MASK</td><td>unsigned long</td></tr> | |
1765 <tr><td>STENCIL_WRITEMASK</td><td>unsigned long</td></tr> | |
1766 <tr><td>SUBPIXEL_BITS</td><td>long</td></tr> | |
1767 <tr><td>TEXTURE_BINDING_2D</td><td>WebGLTexture</td></tr> | |
1768 <tr><td>TEXTURE_BINDING_CUBE_MAP</td><td>WebGLTexture</td></tr> | |
1769 <tr><td>UNPACK_ALIGNMENT</td><td>int</td></tr> | |
1770 <tr><td>UNPACK_COLORSPACE_CONVERSION_WEBGL</td><td>unsigned long
</td></tr> | |
1771 <tr><td>UNPACK_FLIP_Y_WEBGL</td><td>boolean</td></tr> | |
1772 <tr><td>UNPACK_PREMULTIPLY_ALPHA_WEBGL</td><td>boolean</td></tr> | |
1773 <tr><td>VENDOR</td><td>DOMString</td></tr> | |
1774 <tr><td>VERSION</td><td>DOMString</td></tr> | |
1775 <tr><td>VIEWPORT</td><td>Int32Array (with 4 elements)</td></tr> | |
1776 </table><br> | |
1777 <p>The following <em>pname</em> arguments return a string describing
some aspect of the current WebGL implementation:</p> | |
1778 <table> | |
1779 <tr><td>VERSION</td> | |
1780 <td>Returns a version or release number of the form <code>WebG
L<space>1.0<space><vendor-specific information></code>.</td></
tr> | |
1781 <tr><td>SHADING_LANGUAGE_VERSION</td> | |
1782 <td>Returns a version or release number of the form <code>WebG
L<space>GLSL<space>ES<space>1.0<space><vendor-specifi
c information></code>.</td></tr> | |
1783 <tr><td>VENDOR</td> | |
1784 <td>Returns the company responsible for this WebGL implementat
ion. This name does not change from release to release.</td></tr> | |
1785 <tr><td>RENDERER</td> | |
1786 <td>Returns the name of the renderer. This name is typically s
pecific to a particular configuration of a hardware platform. It does not change
from release to release.</td></tr> | |
1787 </table><br> | |
1788 <p>See <a href="#EXTENSION_QUERIES">Extension Queries</a> for inform
ation on querying the | |
1789 available extensions in the current WebGL implementation.</p> | |
1790 <dt class="idl-code">GLenum getError() | |
1791 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.5">OpenGL ES 2.0 §2.
5</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glGetError.xml">man page</a>)</span> | |
1792 <dd> | |
1793 See <a href="#WEBGLCONTEXTEVENT">WebGLContextEvent</a> for documenta
tion of a | |
1794 WebGL-specific return value from getError. | |
1795 <dt class="idl-code">void hint(GLenum target, GLenum mode) | |
1796 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-5.2">OpenGL ES 2.0 §5.
2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glHint.xml">man page</a>)</span> | |
1797 <dt class="idl-code">GLboolean isEnabled(GLenum cap) | |
1798 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.1">OpenGL ES 2.0 §
6.1.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsEnabled.xml">man page</a>)</span> | |
1799 <dt class="idl-code">void lineWidth(GLfloat width) | |
1800 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.4">OpenGL ES 2.0 §3.
4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glLineWidth.xml">man page</a>)</span> | |
1801 <dt class="idl-code">void pixelStorei(GLenum pname, GLint param) | |
1802 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.6.1">OpenGL ES 2.0 §
3.6.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glPixelStorei.xml">man page</a>)</span> | |
1803 <dd> | |
1804 In addition to the parameters in the OpenGL ES 2.0 specification
, the WebGL | |
1805 specification accepts the parameters <code>UNPACK_FLIP_Y_WEBGL</
code>, | |
1806 <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> | |
1807 and <code>UNPACK_COLORSPACE_CONVERSION_WEBGL</code>. See <a href
="#PIXEL_STORAGE_PARAMETERS">Pixel | |
1808 Storage Parameters</a> for documentation of these parameters. | |
1809 <dt class="idl-code">void polygonOffset(GLfloat factor, GLfloat units) | |
1810 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.5.2">OpenGL ES 2.0 §
3.5.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glPolygonOffset.xml">man page</a>)</span> | |
1811 <dt class="idl-code">void sampleCoverage(GLclampf value, GLboolean inver
t) | |
1812 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.3">OpenGL ES 2.0 §
4.1.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glSampleCoverage.xml">man page</a>)</span> | |
1813 <dt class="idl-code">void stencilFunc(GLenum func, GLint ref, GLuint mas
k) | |
1814 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 §
4.1.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilFunc.xml">man page</a>)</span> | |
1815 <dt class="idl-code">void stencilFuncSeparate(GLenum face, GLenum func,
GLint ref, GLuint mask) | |
1816 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 §
4.1.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilFuncSeparate.xml">man page</a>)</span> | |
1817 <dd> | |
1818 See <a href="#STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and
Reference Value</a> for information | |
1819 on WebGL specific limitations to the allowable argument values. | |
1820 <dt class="idl-code">void stencilMask(GLuint mask) | |
1821 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 §
4.2.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilMask.xml">man page</a>)</span> | |
1822 <dd> | |
1823 See <a href="#STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and
Reference Value</a> for information | |
1824 on WebGL specific limitations to the allowable mask values. | |
1825 <dt class="idl-code">void stencilMaskSeparate(GLenum face, GLuint mask) | |
1826 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 §
4.2.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilMaskSeparate.xml">man page</a>)</span> | |
1827 <dt class="idl-code">void stencilOp(GLenum fail, GLenum zfail, GLenum zp
ass) | |
1828 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 §
4.1.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilOp.xml">man page</a>)</span> | |
1829 <dt class="idl-code">void stencilOpSeparate(GLenum face, GLenum fail, GL
enum zfail, GLenum zpass) | |
1830 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 §
4.1.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glStencilOpSeparate.xml">man page</a>)</span> | |
1831 </dl> | |
1832 | |
1833 <!-- ===========================================================================
============================ --> | |
1834 | |
1835 <h4>Viewing and clipping</h4> | |
1836 | |
1837 <p> | |
1838 The viewport specifies the affine transformation of x and y from normali
zed device | |
1839 coordinates to window coordinates. The size of the drawing buffer is det
ermined by | |
1840 the HTMLCanvasElement. The scissor box defines a rectangle which constra
ins drawing. | |
1841 When the scissor test is enabled only pixels that lie within the scisso
r box can | |
1842 be modified by drawing commands. When enabled drawing can only occur ins
ide the | |
1843 intersection of the viewport, canvas area and the scissor box. When the
scissor test | |
1844 is not enabled drawing can only occur inside the intersection of the vie
wport and | |
1845 canvas area. | |
1846 </p> | |
1847 | |
1848 <dl class="methods"> | |
1849 <dt class="idl-code">void scissor(GLint x, GLint y, GLsizei width, GLsiz
ei height) | |
1850 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.1.2">OpenGL ES 2.0 §
4.1.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glScissor.xml">man page</a>)</span> | |
1851 | |
1852 <dt class="idl-code">void viewport(GLint x, GLint y, GLsizei width, GLsi
zei height) | |
1853 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.12.1">OpenGL ES 2.0 §
;2.12.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glViewport.xml">man page</a>)</span> | |
1854 </dl> | |
1855 | |
1856 <!-- ===========================================================================
============================ --> | |
1857 | |
1858 <h4>Buffer objects</h4> | |
1859 | |
1860 <p> | |
1861 Buffer objects (sometimes referred to as VBOs) hold vertex attribute dat
a for the GLSL | |
1862 shaders. | |
1863 </p> | |
1864 | |
1865 <dl class="methods"> | |
1866 <dt class="idl-code">void bindBuffer(GLenum target, WebGLBuffer buffer) | |
1867 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBindBuffer.xml">man page</a>)</span> | |
1868 <dd> | |
1869 Binds the given WebGLBuffer object to the given binding point (targe
t), either | |
1870 ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER. If the buffer is null then any
buffer currently | |
1871 bound to this target is unbound. A given WebGLBuffer object may only
be bound to one of | |
1872 the ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target in its lifetime. An
attempt to bind a | |
1873 buffer object to the other target will generate an <code>INVALID_OPE
RATION</code> error, and the | |
1874 current binding will remain untouched. | |
1875 | |
1876 <dt class="idl-code">void bufferData(GLenum target, GLsizeiptr size, GLe
num usage) | |
1877 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBufferData.xml">man page</a>)</span> | |
1878 <dd> | |
1879 Set the size of the currently bound WebGLBuffer object for the passe
d target. The | |
1880 buffer is initialized to 0. | |
1881 | |
1882 <dt><p class="idl-code">void bufferData(GLenum target, ArrayBufferView d
ata, GLenum usage)</p> | |
1883 <p class="idl-code">void bufferData(GLenum target, ArrayBuffer data,
GLenum usage) | |
1884 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBufferData.xml">man page</a>)</span></p> | |
1885 <dd> | |
1886 Set the size of the currently bound WebGLBuffer object for the passe
d target to the | |
1887 size of the passed data, then write the contents of data to the buff
er object. | |
1888 <br><br> | |
1889 If the passed data is null then an <code>INVALID_VALUE</code> error
is generated. | |
1890 <dt><p class="idl-code">void bufferSubData(GLenum target, GLintptr offse
t, ArrayBufferView data)</p> | |
1891 <p class="idl-code">void bufferSubData(GLenum target, GLintptr offse
t, ArrayBuffer data) | |
1892 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glBufferSubData.xml">man page</a>)</span></p> | |
1893 <dd> | |
1894 For the WebGLBuffer object bound to the passed target write the pass
ed data starting | |
1895 at the passed offset. If the data would be written past the end of t
he buffer object | |
1896 an <code>INVALID_VALUE</code> error is generated. | |
1897 | |
1898 <dt class="idl-code">WebGLBuffer createBuffer() | |
1899 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/
sdk/2.0/docs/man/xhtml/glGenBuffers.xml">glGenBuffers</a>)</span> | |
1900 <dd> | |
1901 Create a WebGLBuffer object and initialize it with a buffer object n
ame as if by | |
1902 calling glGenBuffers. | |
1903 | |
1904 <dt class="idl-code">void deleteBuffer(WebGLBuffer buffer) | |
1905 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.9">OpenGL ES 2.0 §2.
9</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/
sdk/2.0/docs/man/xhtml/glDeleteBuffers.xml">glDeleteBuffers</a>)</span> | |
1906 <dd> | |
1907 Delete the buffer object contained in the passed WebGLBuffer as if b
y calling | |
1908 glDeleteBuffers. If the buffer has already been deleted the call has
no effect. | |
1909 Note that the buffer object will be deleted when the WebGLBuffer obj
ect is destroyed. | |
1910 This method merely gives the author greater control over when the bu
ffer object is | |
1911 destroyed. | |
1912 | |
1913 <dt class="idl-code">any getBufferParameter(GLenum target, GLenum pname) | |
1914 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 §
6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetBufferParameteriv.xml">glGetBufferParameteriv</a
>)</span> | |
1915 <dd> | |
1916 Return the value for the passed pname. The type returned is the natu
ral type for the | |
1917 requested pname, as given in the following table: | |
1918 <table class="foo"> | |
1919 <tr><th>pname</th><th>returned type</th></tr> | |
1920 <tr><td>BUFFER_SIZE</td><td>long</td></tr> | |
1921 <tr><td>BUFFER_USAGE</td><td>unsigned long</td></tr> | |
1922 </table> | |
1923 <dt class="idl-code">GLboolean isBuffer(WebGLBuffer buffer) | |
1924 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.6">OpenGL ES 2.0 §
6.1.6</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsBuffer.xml">man page</a>)</span> | |
1925 </dl> | |
1926 | |
1927 <!-- ===========================================================================
============================ --> | |
1928 | |
1929 <h4>Framebuffer objects</h4> | |
1930 | |
1931 <p> | |
1932 Framebuffer objects provide an alternative rendering target to the drawi
ng buffer. They | |
1933 are a collection of color, alpha, depth and stencil buffers and are ofte
n used to | |
1934 render an image that will later be used as a texture. | |
1935 </p> | |
1936 | |
1937 <dl class="methods"> | |
1938 <dt class="idl-code">void bindFramebuffer(GLenum target, WebGLFramebuffe
r framebuffer) | |
1939 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §
4.4.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBindFramebuffer.xml">man page</a>)</span> | |
1940 <dd> | |
1941 Bind the given <code class="interface">WebGLFramebuffer</code> objec
t to the given binding point | |
1942 (<code class="param">target</code>), which must be <code class="enum
">FRAMEBUFFER</code>. | |
1943 If <code class="param">framebuffer</code> is null, the default frame
buffer provided by the context | |
1944 is bound and attempts to modify or query state on <code class="param
">target</code> <code class="enum">FRAMEBUFFER</code> | |
1945 will generate an <code class="error">INVALID_OPERATION</code> error. | |
1946 | |
1947 <dt class="idl-code">GLenum checkFramebufferStatus(GLenum target) | |
1948 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.5">OpenGL ES 2.0 §
4.4.5</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glCheckFramebufferStatus.xml">man page</a>)</span> | |
1949 <dt class="idl-code">WebGLFramebuffer createFramebuffer() | |
1950 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §
4.4.1</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGenFramebuffers.xml">glGenFramebuffers</a>)</span> | |
1951 <dd> | |
1952 Create a WebGLFramebuffer object and initialize it with a framebuffe
r object name as if by | |
1953 calling glGenFramebuffers. | |
1954 | |
1955 <dt class="idl-code">void deleteFramebuffer(WebGLFramebuffer buffer) | |
1956 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 §
4.4.1</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glDeleteFramebuffers.xml">glDeleteFramebuffers</a>)</
span> | |
1957 <dd> | |
1958 Delete the framebuffer object contained in the passed WebGLFramebuff
er as if by calling | |
1959 glDeleteFramebuffers. If the framebuffer has already been deleted th
e call has no effect. | |
1960 Note that the framebuffer object will be deleted when the WebGLFrame
buffer object is destroyed. | |
1961 This method merely gives the author greater control over when the fr
amebuffer object is | |
1962 destroyed. | |
1963 | |
1964 <dt class="idl-code">void framebufferRenderbuffer(GLenum target, GLenum
attachment, | |
1965 GLenum renderbuffertarget, | |
1966 WebGLRenderbuffer renderbuffer) | |
1967 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glFramebufferRenderbuffer.xml">man page</a>)</span></dt> | |
1968 <dt class="idl-code">void framebufferTexture2D(GLenum target, GLenum att
achment, GLenum textarget, | |
1969 WebGLTexture texture, GLint level) | |
1970 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glFramebufferTexture2D.xml">man page</a>)</span> | |
1971 <dt class="idl-code">any getFramebufferAttachmentParameter(GLenum target
, GLenum attachment, | |
1972 GLenum pname) | |
1973 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 §
6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetFramebufferAttachmentParameteriv.xml">glGetFrame
bufferAttachmentParameteriv</a>)</span> | |
1974 <dd> | |
1975 Return the value for the passed pname given the passed target and at
tachment. The type | |
1976 returned is the natural type for the requested pname, as given in th
e following table: | |
1977 <table class="foo"> | |
1978 <tr><th>pname</th><th>returned type</th></tr> | |
1979 <tr><td>FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE</td><td>unsigned long
</td></tr> | |
1980 <tr><td>FRAMEBUFFER_ATTACHMENT_OBJECT_NAME</td><td>WebGLRenderbu
ffer or WebGLTexture</td></tr> | |
1981 <tr><td>FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL</td><td>long</td></
tr> | |
1982 <tr><td>FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE</td><td>lon
g</td></tr> | |
1983 </table> | |
1984 <dt class="idl-code">GLboolean isFramebuffer(WebGLFramebuffer framebuffe
r) | |
1985 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.7">OpenGL ES 2.0 §
6.1.7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsFramebuffer.xml">man page</a>)</span> | |
1986 <dd> | |
1987 Return true if the passed WebGLFramebuffer is valid and false otherw
ise. | |
1988 </dl> | |
1989 | |
1990 <!-- ===========================================================================
============================ --> | |
1991 | |
1992 <h4>Renderbuffer objects</h4> | |
1993 | |
1994 <p> | |
1995 Renderbuffer objects are used to provide storage for the individual buff
ers used in a | |
1996 framebuffer object. | |
1997 </p> | |
1998 | |
1999 <dl class="methods"> | |
2000 <dt class="idl-code">void bindRenderbuffer(GLenum target, WebGLRenderbuf
fer renderbuffer) | |
2001 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glBindRenderbuffer.xml">man page</a>)</span> | |
2002 <dd> | |
2003 Bind the given <code class="interface">WebGLRenderbuffer</code> obje
ct to the given binding point | |
2004 (<code class="param">target</code>), which must be <code class="enum
">RENDERBUFFER</code>. | |
2005 If <code class="param">renderbuffer</code> is null the renderbuffer
object currently bound to | |
2006 this <code class="param">target</code> is unbound. | |
2007 | |
2008 <dt class="idl-code">WebGLRenderbuffer createRenderbuffer() | |
2009 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGenRenderbuffers.xml">glGenRenderbuffers</a>)</span
> | |
2010 <dd> | |
2011 Create a WebGLRenderbuffer object and initialize it with a renderbuf
fer object name as if by | |
2012 calling glGenRenderbuffers. | |
2013 | |
2014 <dt class="idl-code">void deleteRenderbuffer(WebGLRenderbuffer renderbuf
fer) | |
2015 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glDeleteRenderbuffers.xml">glDeleteRenderbuffers</a>)
</span> | |
2016 <dd> | |
2017 Delete the renderbuffer object contained in the passed WebGLRenderbu
ffer as if by calling | |
2018 glDeleteRenderbuffers. If the renderbuffer has already been deleted
the call has no effect. | |
2019 Note that the renderbuffer object will be deleted when the WebGLRend
erbuffer object is destroyed. | |
2020 This method merely gives the author greater control over when the re
nderbuffer object is | |
2021 destroyed. | |
2022 <dt class="idl-code">any getRenderbufferParameter(GLenum target, GLenum
pname) | |
2023 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 §
6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetRenderbufferParameteriv.xml">glGetRenderbufferPa
rameteriv</a>)</span> | |
2024 <dd> | |
2025 Return the value for the passed pname given the passed target. The t
ype returned is the natural | |
2026 type for the requested pname, as given in the following table: | |
2027 <table class="foo"> | |
2028 <tr><th>pname</th><th>returned type</th></tr> | |
2029 <tr><td>RENDERBUFFER_WIDTH</td><td>long</td></tr> | |
2030 <tr><td>RENDERBUFFER_HEIGHT</td><td>long</td></tr> | |
2031 <tr><td>RENDERBUFFER_INTERNAL_FORMAT</td><td>unsigned long</td><
/tr> | |
2032 <tr><td>RENDERBUFFER_RED_SIZE</td><td>long</td></tr> | |
2033 <tr><td>RENDERBUFFER_GREEN_SIZE</td><td>long</td></tr> | |
2034 <tr><td>RENDERBUFFER_BLUE_SIZE</td><td>long</td></tr> | |
2035 <tr><td>RENDERBUFFER_ALPHA_SIZE</td><td>long</td></tr> | |
2036 <tr><td>RENDERBUFFER_DEPTH_SIZE</td><td>long</td></tr> | |
2037 <tr><td>RENDERBUFFER_STENCIL_SIZE</td><td>long</td></tr> | |
2038 </table> | |
2039 <dt class="idl-code">GLboolean isRenderbuffer(WebGLRenderbuffer renderbu
ffer) | |
2040 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.7">OpenGL ES 2.0 §
6.1.7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsRenderbuffer.xml">man page</a>)</span> | |
2041 <dd> | |
2042 Return true if the passed WebGLRenderbuffer is valid and false other
wise. | |
2043 <dt class="idl-code">void renderbufferStorage(GLenum target, GLenum inte
rnalformat, | |
2044 GLsizei width, GLsizei height) | |
2045 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 §
4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glRenderbufferStorage.xml">man page</a>)</span> | |
2046 </dl> | |
2047 | |
2048 <!-- ===========================================================================
============================ --> | |
2049 | |
2050 <h4>Texture objects</h4> | |
2051 | |
2052 <p> | |
2053 Texture objects provide storage and state for texturing operations. If n
o WebGLTexture is bound | |
2054 (e.g., passing null or 0 to bindTexture) then attempts to modify or quer
y the texture object shall | |
2055 generate an <code>INVALID_OPERATION</code> error. This is indicated in t
he functions below. | |
2056 </p> | |
2057 | |
2058 <dl class="methods"> | |
2059 <dt class="idl-code">void bindTexture(GLenum target, WebGLTexture textur
e) | |
2060 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §
;3.7.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glBindTexture.xml">man page</a>)</span> | |
2061 <dt class="idl-code">void copyTexImage2D(GLenum target, GLint level, GLe
num internalformat, | |
2062 GLint x, GLint y, GLsizei width, GLsizei height, | |
2063 GLint border) | |
2064 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 §
3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glCopyTexImage2D.xml">man page</a>)</span> | |
2065 <dd> | |
2066 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2067 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2068 | |
2069 For any pixel lying outside the frame buffer, all channels of the as
sociated texel are | |
2070 initialized to 0; see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading P
ixels Outside the | |
2071 Framebuffer</a>. | |
2072 <dt class="idl-code">void copyTexSubImage2D(GLenum target, GLint level,
GLint xoffset, GLint yoffset, | |
2073 GLint x, GLint y, GLsizei width, GLsizei height) | |
2074 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 §
3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glCopyTexSubImage2D.xml">man page</a>)</span> | |
2075 <dd> | |
2076 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2077 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2078 | |
2079 For any pixel lying outside the frame buffer, all channels of the as
sociated texel are | |
2080 initialized to 0; see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading P
ixels Outside the | |
2081 Framebuffer</a>. | |
2082 <dt class="idl-code">WebGLTexture createTexture() | |
2083 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §
;3.7.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGenTextures.xml">man page</a>)</span> | |
2084 <dd> | |
2085 Create a WebGLTexture object and initialize it with a texture object
name as if by | |
2086 calling glGenTextures. | |
2087 | |
2088 <dt class="idl-code">void deleteTexture(WebGLTexture texture) | |
2089 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 §
;3.7.13</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glDeleteTextures.xml">man page</a>)</span> | |
2090 <dd> | |
2091 Delete the texture object contained in the passed WebGLTexture as if
by calling | |
2092 glDeleteTextures. If the texture has already been deleted the call h
as no effect. | |
2093 Note that the texture object will be deleted when the WebGLTexture o
bject is destroyed. | |
2094 This method merely gives the author greater control over when the te
xture object is | |
2095 destroyed. | |
2096 <dt class="idl-code">void generateMipmap(GLenum target) | |
2097 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.11">OpenGL ES 2.0 §
;3.7.11</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGenerateMipmap.xml">man page</a>)</span> | |
2098 <dd> | |
2099 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2100 <code>INVALID_OPERATION</code> error is generated. | |
2101 <dt class="idl-code">any getTexParameter(GLenum target, GLenum pname) | |
2102 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 §
6.1.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetTexParameter.xml">man page</a>)</span> | |
2103 <dd> | |
2104 Return the value for the passed pname given the passed target. The t
ype returned is the natural type for the | |
2105 requested pname, as given in the following table: | |
2106 <table class="foo"> | |
2107 <tr><th>pname</th><th>returned type</th></tr> | |
2108 <tr><td>TEXTURE_MAG_FILTER</td><td>unsigned long</td></tr> | |
2109 <tr><td>TEXTURE_MIN_FILTER</td><td>unsigned long</td></tr> | |
2110 <tr><td>TEXTURE_WRAP_S</td><td>unsigned long</td></tr> | |
2111 <tr><td>TEXTURE_WRAP_T</td><td>unsigned long</td></tr> | |
2112 </table> | |
2113 <dd> | |
2114 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2115 <code>INVALID_OPERATION</code> error is generated. | |
2116 <dt class="idl-code">GLboolean isTexture(WebGLTexture texture) | |
2117 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.4">OpenGL ES 2.0 §
6.1.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsTexture.xml">man page</a>)</span> | |
2118 <dd> | |
2119 Return true if the passed WebGLTexture is valid and false otherwise. | |
2120 <dt class="idl-code"><a name="TEXIMAGE2D">void texImage2D</a>(GLenum tar
get, GLint level, GLenum internalformat, | |
2121 GLsizei width, GLsizei height, GLint border, GLenum format, | |
2122 GLenum type, ArrayBufferView pixels) | |
2123 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.1">OpenGL ES 2.0 §
3.7.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexImage2D.xml">man page</a>)</span> | |
2124 <dd> | |
2125 If <code>pixels</code> is null, a buffer of sufficient size initiali
zed to 0 is | |
2126 passed. <br><br> | |
2127 | |
2128 If <code>pixels</code> is non-null, the type of <code>pixels</code>
must match the type | |
2129 of the data to be read. If it is UNSIGNED_BYTE, a Uint8Array must be
supplied; if it is | |
2130 UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_SHORT_5_5_
5_1, a Uint16Array | |
2131 must be supplied. If the types do not match, an INVALID_OPERATION er
ror is generated. | |
2132 <br><br> | |
2133 | |
2134 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2135 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2136 | |
2137 See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a>
for WebGL-specific | |
2138 pixel storage parameters that affect the behavior of this function. | |
2139 <dt><p class="idl-code"><a name="TEXIMAGE2D_HTML">void texImage2D</a>(GL
enum target, GLint level, GLenum internalformat, | |
2140 GLenum format, GLenum type, ImageData pixels)</p> | |
2141 <p class="idl-code">void texImage2D(GLenum target, GLint level, GLen
um internalformat, | |
2142 GLenum format, GLenum type, HTMLImageElement image) raises (
DOMException)</p> | |
2143 <p class="idl-code">void texImage2D(GLenum target, GLint level, GLen
um internalformat, | |
2144 GLenum format, GLenum type, HTMLCanvasElement canvas) raises
(DOMException)</p> | |
2145 <p class="idl-code">void texImage2D(GLenum target, GLint level, GLen
um internalformat, | |
2146 GLenum format, GLenum type, HTMLVideoElement video) raises (
DOMException) | |
2147 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.1">OpenGL ES 2.0 §
3.7.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexImage2D.xml">man page</a>)</span></p> | |
2148 <dd> | |
2149 Uploads the given element or image data to the currently bound WebGL
Texture. <br><br> | |
2150 | |
2151 The source image data is conceptually first converted to the data ty
pe and format | |
2152 specified by the <em>format</em> and <em>type</em> arguments, and th
en transferred to | |
2153 the OpenGL implementation. If a packed pixel format is specified whi
ch would imply loss | |
2154 of bits of precision from the image data, this loss of precision mus
t occur. <br><br> | |
2155 | |
2156 If the source image is an RGB or RGBA lossless image with 8 bits per
channel, the | |
2157 browser guarantees that the full precision of all channels is preser
ved. <br><br> | |
2158 | |
2159 If the original image contains an alpha channel and the | |
2160 <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel storage parameter
is false, then the | |
2161 RGB values are guaranteed to never have been premultiplied by the al
pha channel, whether | |
2162 those values are derived directly from the original file format or c
onverted from some | |
2163 other color format. <br><br> | |
2164 | |
2165 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2166 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2167 | |
2168 If this function is called with an <code>HTMLImageElement</code> | |
2169 or <code>HTMLVideoElement</code> whose origin differs from the origi
n of the containing | |
2170 Document, or with an <code>HTMLCanvasElement</code> whose <i>origin-
clean</i> flag is | |
2171 set to false, a <code>SECURITY_ERR</code> exception must be | |
2172 raised. See <a href="#ORIGIN_RESTRICTIONS">Origin Restrictions</a>.<
br><br> | |
2173 | |
2174 See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a>
for WebGL-specific | |
2175 pixel storage parameters that affect the behavior of this function. | |
2176 <dt class="idl-code">void texParameterf(GLenum target, GLenum pname, GLf
loat param) | |
2177 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.4">OpenGL ES 2.0 §
3.7.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexParameter.xml">man page</a>)</span> | |
2178 <dd> | |
2179 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2180 <code>INVALID_OPERATION</code> error is generated. | |
2181 <dt class="idl-code">void texParameteri(GLenum target, GLenum pname, GLi
nt param) | |
2182 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.4">OpenGL ES 2.0 §
3.7.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexParameter.xml">man page</a>)</span> | |
2183 <dd> | |
2184 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2185 <code>INVALID_OPERATION</code> error is generated. | |
2186 <dt class="idl-code">void texSubImage2D(GLenum target, GLint level, GLin
t xoffset, GLint yoffset, | |
2187 GLsizei width, GLsizei height, | |
2188 GLenum format, GLenum type, ArrayBufferView pixels) | |
2189 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 §
3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexSubImage2D.xml">man page</a>)</span> | |
2190 <dd> | |
2191 See <a href="#TEXIMAGE2D">texImage2D</a> for restrictions on the <em
>format</em> | |
2192 and <em>pixels</em> arguments. <br><br> | |
2193 | |
2194 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2195 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2196 | |
2197 See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a>
for WebGL-specific | |
2198 pixel storage parameters that affect the behavior of this function. | |
2199 <dt><p class="idl-code">void texSubImage2D(GLenum target, GLint level, G
Lint xoffset, GLint yoffset, | |
2200 GLenum format, GLenum type, ImageData pixels)</p> | |
2201 <p class="idl-code">void texSubImage2D(GLenum target, GLint level, G
Lint xoffset, GLint yoffset, | |
2202 GLenum format, GLenum type, HTMLImageElement image) raise
s (DOMException)</p> | |
2203 <p class="idl-code">void texSubImage2D(GLenum target, GLint level, G
Lint xoffset, GLint yoffset, | |
2204 GLenum format, GLenum type, HTMLCanvasElement canvas) rai
ses (DOMException)</p> | |
2205 <p class="idl-code">void texSubImage2D(GLenum target, GLint level, G
Lint xoffset, GLint yoffset, | |
2206 GLenum format, GLenum type, HTMLVideoElement video) raise
s (DOMException) | |
2207 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 §
3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glTexSubImage2D.xml">man page</a>)</span></p> | |
2208 <dd> | |
2209 Updates a sub-rectangle of the currently bound WebGLTexture with the
contents of the | |
2210 given element or image data. <br><br> | |
2211 | |
2212 See <a href="#TEXIMAGE2D_HTML">texImage2D</a> for the interpretation
of | |
2213 the <em>format</em> and <em>type</em> arguments. <br><br> | |
2214 | |
2215 If an attempt is made to call this function with no WebGLTexture bou
nd (see above), an | |
2216 <code>INVALID_OPERATION</code> error is generated. <br><br> | |
2217 | |
2218 If this function is called with an <code>HTMLImageElement</code> | |
2219 or <code>HTMLVideoElement</code> whose origin differs from the origi
n of the containing | |
2220 Document, or with an <code>HTMLCanvasElement</code> whose <i>origin-
clean</i> flag is | |
2221 set to false, a <code>SECURITY_ERR</code> exception must be | |
2222 raised. See <a href="#ORIGIN_RESTRICTIONS">Origin Restrictions</a>.<
br><br> | |
2223 | |
2224 See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a>
for WebGL-specific | |
2225 pixel storage parameters that affect the behavior of this function. | |
2226 </dl> | |
2227 | |
2228 <!-- ===========================================================================
============================ --> | |
2229 | |
2230 <h4>Programs and Shaders</h4> | |
2231 | |
2232 <p> | |
2233 Rendering with OpenGL ES 2.0 requires the use of <i>shaders</i>, written
in OpenGL ES's shading language, GLSL ES. | |
2234 Shaders must be loaded with a source string (shaderSource), compiled | |
2235 (compileShader) and attached to a <i>program</i> (attachShader) which mu
st be linked | |
2236 (linkProgram) and then used (useProgram). | |
2237 </p> | |
2238 | |
2239 <dl class="methods"> | |
2240 <dt class="idl-code">void attachShader(WebGLProgram program, WebGLShader
shader) | |
2241 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glAttachShader.xml">man page</a>)</span> | |
2242 <dt class="idl-code">void bindAttribLocation(WebGLProgram program, GLuin
t index, DOMString name) | |
2243 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glBindAttribLocation.xml">man page</a>)</span> | |
2244 <dd> | |
2245 See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the G
LSL Source Character | |
2246 Set</a> for additional validation performed by WebGL implementations
. | |
2247 <dt class="idl-code">void compileShader(WebGLShader shader) | |
2248 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §
;2.10.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glCompileShader.xml">man page</a>)</span> | |
2249 <dt class="idl-code">WebGLProgram createProgram() | |
2250 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glCreateProgram.xml">man page</a>)</span> | |
2251 <dd> | |
2252 Create a WebGLProgram object and initialize it with a program object
name as if by | |
2253 calling glCreateProgram. | |
2254 | |
2255 <dt class="idl-code">WebGLShader createShader(type) | |
2256 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §
;2.10.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glCreateShader.xml">man page</a>)</span> | |
2257 <dd> | |
2258 Create a WebGLShader object and initialize it with a shader object n
ame as if by | |
2259 calling glCreateShader. | |
2260 | |
2261 <dt class="idl-code">void deleteProgram(WebGLProgram program) | |
2262 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glDeleteProgram.xml">man page</a>)</span> | |
2263 <dd> | |
2264 Delete the program object contained in the passed WebGLProgram as if
by calling | |
2265 glDeleteProgram. If the program has already been deleted the call ha
s no effect. | |
2266 Note that the program object will be deleted when the WebGLProgram o
bject is destroyed. | |
2267 This method merely gives the author greater control over when the pr
ogram object is | |
2268 destroyed. | |
2269 <dt class="idl-code">void deleteShader(WebGLShader shader) | |
2270 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §
;2.10.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glDeleteShader.xml">man page</a>)</span> | |
2271 <dd> | |
2272 Delete the shader object contained in the passed WebGLShader as if b
y calling | |
2273 glDeleteShader. If the shader has already been deleted the call has
no effect. | |
2274 Note that the shader object will be deleted when the WebGLShader obj
ect is destroyed. | |
2275 This method merely gives the author greater control over when the sh
ader object is | |
2276 destroyed. | |
2277 <dt class="idl-code">void detachShader(WebGLProgram program, WebGLShader
shader) | |
2278 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glDetachShader.xml">man page</a>)</span> | |
2279 <dt class="idl-code">WebGLShader[ ] getAttachedShaders(WebGLProgram prog
ram) | |
2280 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetAttachedShaders.xml">man page</a>)</span> | |
2281 <dd> | |
2282 Return the list of shaders attached to the passed program. | |
2283 <dt class="idl-code">any getProgramParameter(WebGLProgram program, GLenu
m pname) | |
2284 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetProgramiv.xml">man page</a>)</span> | |
2285 <dd> | |
2286 Return the value for the passed pname given the passed program. The
type returned is the natural | |
2287 type for the requested pname, as given in the following table: | |
2288 <table class="foo"> | |
2289 <tr><th>pname</th><th>returned type</th></tr> | |
2290 <tr><td>DELETE_STATUS</td><td>boolean</td></tr> | |
2291 <tr><td>LINK_STATUS</td><td>boolean</td></tr> | |
2292 <tr><td>VALIDATE_STATUS</td><td>boolean</td></tr> | |
2293 <tr><td>ATTACHED_SHADERS</td><td>long</td></tr> | |
2294 <tr><td>ACTIVE_ATTRIBUTES</td><td>long</td></tr> | |
2295 <tr><td>ACTIVE_UNIFORMS</td><td>long</td></tr> | |
2296 </table> | |
2297 <dt class="idl-code">DOMString getProgramInfoLog(WebGLProgram program) | |
2298 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetProgramInfoLog.xml">man page</a>)</span> | |
2299 <dt class="idl-code">any getShaderParameter(WebGLShader shader, GLenum p
name) | |
2300 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetShaderiv.xml">man page</a>)</span> | |
2301 <dd> | |
2302 Return the value for the passed pname given the passed shader. The t
ype returned is the natural | |
2303 type for the requested pname, as given in the following table: | |
2304 <table class="foo"> | |
2305 <tr><th>pname</th><th>returned type</th></tr> | |
2306 <tr><td>SHADER_TYPE</td><td>unsigned long</td></tr> | |
2307 <tr><td>DELETE_STATUS</td><td>boolean</td></tr> | |
2308 <tr><td>COMPILE_STATUS</td><td>boolean</td></tr> | |
2309 </table> | |
2310 <dt class="idl-code">DOMString getShaderInfoLog(WebGLShader shader) | |
2311 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetShaderInfoLog.xml">man page</a>)</span> | |
2312 <dt class="idl-code">DOMString getShaderSource(WebGLShader shader) | |
2313 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetShaderSource.xml">man page</a>)</span> | |
2314 <dt class="idl-code">GLboolean isProgram(WebGLProgram program) | |
2315 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsProgram.xml">man page</a>)</span> | |
2316 <dd> | |
2317 Return true if the passed WebGLProgram is valid and false otherwise. | |
2318 <dt class="idl-code">GLboolean isShader(WebGLShader shader) | |
2319 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glIsShader.xml">man page</a>)</span> | |
2320 <dd> | |
2321 Return true if the passed WebGLShader is valid and false otherwise. | |
2322 <dt class="idl-code">void linkProgram(WebGLProgram program) | |
2323 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glLinkProgram.xml">man page</a>)</span> | |
2324 <dt class="idl-code">void shaderSource(WebGLShader shader, DOMString sou
rce) | |
2325 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 §
;2.10.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glShaderSource.xml">man page</a>)</span> | |
2326 <dd> | |
2327 See <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</
a> | |
2328 and <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the G
LSL Source Character | |
2329 Set</a> for additional constructs supported by and validation perfor
med by WebGL | |
2330 implementations. | |
2331 <dt class="idl-code">void useProgram(WebGLProgram program) | |
2332 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 §
;2.10.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glUseProgram.xml">man page</a>)</span> | |
2333 <dt class="idl-code">void validateProgram(WebGLProgram program) | |
2334 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.5">OpenGL ES 2.0 §
;2.10.5</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glValidateProgram.xml">man page</a>)</span> | |
2335 </dl> | |
2336 | |
2337 <!-- ===========================================================================
============================ --> | |
2338 | |
2339 <h4>Uniforms and attributes</h4> | |
2340 | |
2341 <p> | |
2342 Values used by the shaders are passed in as uniforms or vertex attribute
s. | |
2343 </p> | |
2344 | |
2345 <dl class="methods"> | |
2346 <dt class="idl-code">void disableVertexAttribArray(GLuint index) | |
2347 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.8">OpenGL ES 2.0 §2.
8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glDisableVertexAttribArray.xml">man page</a>)</span> | |
2348 <dt class="idl-code">void enableVertexAttribArray(GLuint index) | |
2349 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.8">OpenGL ES 2.0 §2.
8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glEnableVertexAttribArray.xml">man page</a>)</span> | |
2350 <dd> | |
2351 Enable the vertex attribute at <code>index</code> as an array. WebGL
imposes additional | |
2352 rules beyond OpenGL ES 2.0 regarding enabled vertex attributes; | |
2353 see <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes
and Range | |
2354 Checking</a>. | |
2355 <dt class="idl-code">WebGLActiveInfo getActiveAttrib(WebGLProgram progra
m, GLuint index) | |
2356 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGetActiveAttrib.xml">man page</a>)</span> | |
2357 <dd> | |
2358 Returns information about the size, type and name of the vertex attr
ibute at the | |
2359 passed index of the passed program object. | |
2360 <dt class="idl-code">WebGLActiveInfo getActiveUniform(WebGLProgram progr
am, GLuint index) | |
2361 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGetActiveUniform.xml">man page</a>)</span> | |
2362 <dd> | |
2363 Returns information about the size, type and name of the uniform at
the | |
2364 passed index of the passed program object. | |
2365 <dt class="idl-code">GLint getAttribLocation(WebGLProgram program, DOMSt
ring name) | |
2366 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGetAttribLocation.xml">man page</a>)</span> | |
2367 <dd> | |
2368 See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the G
LSL Source Character | |
2369 Set</a> for additional validation performed by WebGL implementations
. | |
2370 <dt class="idl-code">any getUniform(WebGLProgram program, WebGLUniformLo
cation location) | |
2371 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetUniform.xml">man page</a>)</span> | |
2372 <dd> | |
2373 Return the uniform value at the passed location in the passed progra
m. The type returned is | |
2374 dependent on the uniform type, as shown in the following table: | |
2375 <table class="foo"> | |
2376 <tr><th>uniform type</th><th>returned type</th></tr> | |
2377 <tr><td>boolean</td><td>boolean</td></tr> | |
2378 <tr><td>int</td><td>long</td></tr> | |
2379 <tr><td>float</td><td>float</td></tr> | |
2380 <tr><td>vec2</td><td>Float32Array (with 2 elements)</td></tr> | |
2381 <tr><td>ivec2</td><td>Int32Array (with 2 elements)</td></tr> | |
2382 <tr><td>bvec2</td><td>boolean[] (with 2 elements)</td></tr> | |
2383 <tr><td>vec3</td><td>Float32Array (with 3 elements)</td></tr> | |
2384 <tr><td>ivec3</td><td>Int32Array (with 3 elements)</td></tr> | |
2385 <tr><td>bvec3</td><td>boolean[] (with 3 elements)</td></tr> | |
2386 <tr><td>vec4</td><td>Float32Array (with 4 elements)</td></tr> | |
2387 <tr><td>ivec4</td><td>Int32Array (with 4 elements)</td></tr> | |
2388 <tr><td>bvec4</td><td>boolean[] (with 4 elements)</td></tr> | |
2389 <tr><td>mat2</td><td>Float32Array (with 4 elements)</td></tr> | |
2390 <tr><td>mat3</td><td>Float32Array (with 9 elements)</td></tr> | |
2391 <tr><td>mat4</td><td>Float32Array (with 16 elements)</td></tr> | |
2392 </table> | |
2393 <dt class="idl-code">WebGLUniformLocation getUniformLocation(WebGLProgra
m program, DOMString name) | |
2394 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glGetUniformLocation.xml">man page</a>)</span> | |
2395 <dd> | |
2396 Return a WebGLUniformLocation object that represents the location of
a specific uniform variable | |
2397 within a program object. The return value is null if name does not c
orrespond to an active uniform | |
2398 variable in the passed program. <br><br> | |
2399 | |
2400 See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the G
LSL Source Character | |
2401 Set</a> for additional validation performed by WebGL implementations
. | |
2402 <dt class="idl-code">any getVertexAttrib(GLuint index, GLenum pname) | |
2403 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glGetVertexAttrib.xml">man page</a>)</span> | |
2404 <dd> | |
2405 Return the information requested in pname about the vertex attribute
at the passed index. The | |
2406 type returned is dependent on the information requested, as shown in
the following table: | |
2407 <table class="foo"> | |
2408 <tr><th>pname</th><th>returned type</th></tr> | |
2409 <tr><td>VERTEX_ATTRIB_ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</
td></tr> | |
2410 <tr><td>VERTEX_ATTRIB_ARRAY_ENABLED</td><td>boolean</td></tr> | |
2411 <tr><td>VERTEX_ATTRIB_ARRAY_SIZE</td><td>long</td></tr> | |
2412 <tr><td>VERTEX_ATTRIB_ARRAY_STRIDE</td><td>long</td></tr> | |
2413 <tr><td>VERTEX_ATTRIB_ARRAY_TYPE</td><td>unsigned long</td></tr> | |
2414 <tr><td>VERTEX_ATTRIB_ARRAY_NORMALIZED</td><td>boolean</td></tr> | |
2415 <tr><td>CURRENT_VERTEX_ATTRIB</td><td>Float32Array (with 4 eleme
nts)</td></tr> | |
2416 </table> | |
2417 <dt class="idl-code">GLsizeiptr getVertexAttribOffset(GLuint index, GLen
um pname) | |
2418 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 §
6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/openg
les/sdk/2.0/docs/man/xhtml/glGetVertexAttribPointerv.xml">man page</a>)</span> | |
2419 <dt><p class="idl-code">void uniform[1234][fi](WebGLUniformLocation loca
tion, ...)</p> | |
2420 <p class="idl-code">void uniform[1234][fi]v(WebGLUniformLocation loc
ation, ...) | |
2421 <p class="idl-code">void uniformMatrix[234]fv(WebGLUniformLocation l
ocation, GLboolean transpose, ...) | |
2422 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 §
;2.10.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2
.0/docs/man/xhtml/glUniform.xml">man page</a>)</span></p> | |
2423 <dd> | |
2424 Each of the uniform* functions above sets the specified uniform or u
niforms to the | |
2425 values provided. If the passed <code>location</code> is not null and
was not obtained | |
2426 from the currently used program via an earlier call to <code>getUnif
ormLocation</code>, | |
2427 an <code>INVALID_OPERATION</code> error will be generated. If the pa
ssed | |
2428 <code>location</code> is null, the data passed in will be silently i
gnored and | |
2429 no uniform variables will be changed. | |
2430 <br><br> | |
2431 If the array passed to any of the vector forms (those ending in <cod
e>v</code>) has an | |
2432 invalid length, an <code>INVALID_VALUE</code> error will be generate
d. The length is | |
2433 invalid if it is too short for or is not an integer multiple of the
assigned type. | |
2434 <dt><p class="idl-code">void vertexAttrib[1234]f(GLuint indx, ...)</p> | |
2435 <p class="idl-code">void vertexAttrib[1234]fv(GLuint indx, ...) | |
2436 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.7">OpenGL ES 2.0 §2.
7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glVertexAttrib.xml">man page</a>)</span></p> | |
2437 <dd> | |
2438 Sets the vertex attribute at the passed index to the given constant v
alue. Values set via the | |
2439 <code>vertexAttrib</code> are guaranteed to be returned from the <cod
e>getVertexAttrib</code> function | |
2440 with the <code>CURRENT_VERTEX_ATTRIB</code> param, even if there have
been intervening calls to | |
2441 <code>drawArrays</code> or <code>drawElements</code>. | |
2442 <dt class="idl-code">void vertexAttribPointer(GLuint indx, GLint size, GL
enum type, | |
2443 GLboolean normalized, GLsizei stride, GLintptr offse
t) | |
2444 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.8">OpenGL ES 2.0 §2.
8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glVertexAttribPointer.xml">man page</a>)</span> | |
2445 <dd> | |
2446 Assign the WebGLBuffer object currently bound to the ARRAY_BUFFER ta
rget to the vertex | |
2447 attribute at the passed index. Size is number of components per attr
ibute. Stride and | |
2448 offset are in units of bytes. Passed stride and offset must be appro
priate for the | |
2449 passed type and size or an <code>INVALID_OPERATION</code> error will
be | |
2450 generated; see <a href="#BUFFER_OFFSET_AND_STRIDE">Buffer Offset and
Stride | |
2451 Requirements</a>. If no WebGLBuffer is bound to the ARRAY_BUFFER tar
get, | |
2452 an <code>INVALID_OPERATION</code> error will be generated. In WebGL,
the maximum | |
2453 supported stride is 255; see <a href="#VERTEX_STRIDE"> Vertex Attrib
ute Data Stride</a>. | |
2454 </dl> | |
2455 | |
2456 <!-- ===========================================================================
============================ --> | |
2457 | |
2458 <h4>Writing to the drawing buffer</h4> | |
2459 | |
2460 <p> | |
2461 OpenGL ES 2.0 has 3 calls which can render to the drawing buffer: <code>
clear</code>, | |
2462 <code>drawArrays</code> and <code>drawElements</code>. Furthermore rende
ring can | |
2463 be directed to the drawing buffer or to a Framebuffer object. When rende
ring is | |
2464 directed to the drawing buffer, making any of the 3 rendering calls shal
l | |
2465 cause the drawing buffer to be presented to the HTML page compositor at
the start | |
2466 of the next compositing operation. | |
2467 </p> | |
2468 | |
2469 <dl class="methods"> | |
2470 <dt class="idl-code">void clear(GLbitfield mask) | |
2471 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 §
4.2.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glClear.xml">man page</a>)</span> | |
2472 <dt class="idl-code">void drawArrays(GLenum mode, GLint first, GLsizei c
ount) | |
2473 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.8">OpenGL ES 2.0 §2.
8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glDrawArrays.xml">man page</a>)</span> | |
2474 <dd> | |
2475 If <em>first</em> is negative, an <code>INVALID_VALUE</code> error w
ill be generated. | |
2476 <dt class="idl-code">void drawElements(GLenum mode, GLsizei count, GLenu
m type, GLintptr offset) | |
2477 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-2.8">OpenGL ES 2.0 §2.
8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glDrawElements.xml">man page</a>)</span> | |
2478 <dd> | |
2479 Draw using the currently bound element array buffer. The given offs
et is in bytes, and | |
2480 must be a valid multiple of the size of the given type or an <code>I
NVALID_OPERATION</code> | |
2481 error will be generated; see <a href="#BUFFER_OFFSET_AND_STRIDE">Buf
fer Offset and Stride | |
2482 Requirements</a>. If <code>count</code> is greater than zero, then a
non-null | |
2483 <code>WebGLBuffer</code> must be bound to the <code>ELEMENT_ARRAY_BU
FFER</code> binding | |
2484 point or an <code>INVALID_OPERATION</code> error will be generated.<
br><br> | |
2485 | |
2486 WebGL performs additional error checking beyond that specified in Op
enGL ES 2.0 during | |
2487 calls to <code>drawArrays</code> | |
2488 and <code>drawElements</code>. See <a href="#ATTRIBS_AND_RANGE_CHECK
ING">Enabled Vertex | |
2489 Attributes and Range Checking</a>. | |
2490 <dt class="idl-code">void finish() | |
2491 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-5.1">OpenGL ES 2.0 §5.
1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glFinish.xml">man page</a>)</span> | |
2492 <dt class="idl-code">void flush() | |
2493 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-5.1">OpenGL ES 2.0 §5.
1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/doc
s/man/xhtml/glFlush.xml">man page</a>)</span> | |
2494 </dl> | |
2495 | |
2496 <!-- ===========================================================================
============================ --> | |
2497 | |
2498 <h4><a name="readpixels">Reading back pixels</a></h4> | |
2499 | |
2500 <p> | |
2501 Pixels in the current framebuffer can be read back into an ArrayBufferVi
ew object. | |
2502 </p> | |
2503 | |
2504 <dl class="methods"> | |
2505 <dt class="idl-code">void readPixels(GLint x, GLint y, GLsizei width, GL
sizei height, | |
2506 GLenum format, GLenum type, ArrayBufferView pixels) | |
2507 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles
/specs/2.0/es_full_spec_2.0.24.pdf#nameddest=section-4.3.1">OpenGL ES 2.0 §
4.3.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0
/docs/man/xhtml/glReadPixels.xml">man page</a>)</span> | |
2508 <dd> | |
2509 Fills <code>pixels</code> with the pixel data in the specified recta
ngle of the frame | |
2510 buffer. The data returned from readPixels must be up-to-date as of t
he most recently | |
2511 sent drawing command. | |
2512 <br><br> | |
2513 | |
2514 The type of <code>pixels</code> must match the type of the data to b
e read. For example, | |
2515 if it is UNSIGNED_BYTE, a Uint8Array must be supplied; if it is UNSI
GNED_SHORT_5_6_5, | |
2516 UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_SHORT_5_5_5_1, a Uint16Array mus
t be supplied. If | |
2517 the types do not match, an INVALID_OPERATION error is generated. | |
2518 <br><br> | |
2519 | |
2520 The following are the allowed format and type combinations: | |
2521 | |
2522 <table class="foo"> | |
2523 <tr><th>format</th><th>type</th></tr> | |
2524 <tr><td>RGBA</td><td>UNSIGNED_BYTE</td></tr> | |
2525 </table> | |
2526 | |
2527 If <code>pixels</code> is null, an INVALID_VALUE error is generated.
If | |
2528 <code>pixels</code> is non-null, but is not large enough to retrieve
all of the pixels | |
2529 in the specified rectangle taking into account pixel store modes, an
INVALID_OPERATION | |
2530 value is generated. | |
2531 <br><br> | |
2532 | |
2533 For any pixel lying outside the frame buffer, the value read contain
s 0 in all channels; | |
2534 see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the
Framebuffer</a>. | |
2535 <br><br> | |
2536 | |
2537 </dl> | |
2538 | |
2539 <!-- ===========================================================================
============================ --> | |
2540 | |
2541 <h4>Detecting context lost events</h4> | |
2542 | |
2543 <p> | |
2544 Occurrences such as power events on mobile devices may cause the WebGL r
endering context to | |
2545 be lost at any time and require the application to rebuild it; | |
2546 see <a href="#WEBGLCONTEXTEVENT">WebGLContextEvent</a> for more details.
The | |
2547 following method assists in detecting context lost events. | |
2548 </p> | |
2549 | |
2550 <dl class="methods"> | |
2551 <dt class="idl-code">boolean isContextLost() | |
2552 <dd> | |
2553 Returns true if the context is in the lost state. | |
2554 </dl> | |
2555 | |
2556 <!-- ===========================================================================
============================ --> | |
2557 | |
2558 <h4>Detecting and enabling extensions</h4> | |
2559 | |
2560 <p> | |
2561 An implementation of WebGL must not support any additional parameters, c
onstants or functions | |
2562 without first enabling that functionality through the extension mechanis
m. The | |
2563 <code>getSupportedExtensions</code> function returns an array of the ext
ension strings supported | |
2564 by this implementation. Extension strings are case-insensitive. An exten
sion is enabled by | |
2565 passing one of those strings to the <code>getExtension</code> function.
This call returns an | |
2566 object which contains any constants or functions defined by that extensi
on. The definition of | |
2567 that object is specific to the extension and must be defined by the exte
nsion specification. | |
2568 </p> | |
2569 <p> | |
2570 Once an extension is enabled, no mechanism is provided to disable it. Mu
ltiple calls to | |
2571 <code>getExtension</code> with the same extension string shall return th
e same object. An | |
2572 attempt to use any features of an extension without first calling getExt
ension to enable it | |
2573 must generate an appropriate GL error and must not make use of the featu
re. | |
2574 </p> | |
2575 <p> | |
2576 This specification does not define any extensions. A separate <a href="#
refsREGISTRY">WebGL | |
2577 extension registry</a> defines extensions that may be supported by a par
ticular WebGL | |
2578 implementation. | |
2579 </p> | |
2580 | |
2581 <dl class="methods"> | |
2582 <dt class="idl-code">DOMString[ ] getSupportedExtensions() | |
2583 <dd> | |
2584 Returns an array of all the supported extension strings. Any string
in this list, when | |
2585 passed to <code>getExtension</code> must return a valid object. Any
other string passed to | |
2586 <code>getExtension</code> must return null. | |
2587 | |
2588 <dt class="idl-code">object getExtension(DOMString name) | |
2589 <dd> | |
2590 Returns an object if the passed extension is supported, or null if n
ot. The object | |
2591 returned from <code>getExtension</code> contains any constants or fu
nctions used by the | |
2592 extension, if any. A returned object may have no constants or functi
ons if the extension does | |
2593 not define any, but a unique object must still be returned. That obj
ect is used to indicate | |
2594 that the extension has been enabled. | |
2595 </dl> | |
2596 | |
2597 <!-- ===========================================================================
============================ --> | |
2598 | |
2599 <h3><a name="WEBGLCONTEXTEVENT">WebGLContextEvent</a></h3> | |
2600 | |
2601 <p> | |
2602 WebGL generates a WebGLContextEvent event in response to a status change
to the WebGL rendering context | |
2603 associated with the HTMLCanvasElement which has a listener for this even
t. Events are sent using | |
2604 the <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM Ev
ent System</a>. Event types can | |
2605 include the loss or restoration of state, or the inability to create a c
ontext. | |
2606 </p> | |
2607 <pre class="idl"> | |
2608 interface <dfn id="WebGLContextLostEvent">WebGLContextEvent</dfn> : Event { | |
2609 readonly attribute DOMString statusMessage; | |
2610 | |
2611 void initWebGLContextEvent(DOMString typeArg, | |
2612 boolean canBubbleArg, | |
2613 boolean cancelableArg, | |
2614 DOMString statusMessageArg); | |
2615 };</pre> | |
2616 | |
2617 <h4>Attributes</h4> | |
2618 | |
2619 <p> | |
2620 The following attributes are available: | |
2621 </p> | |
2622 | |
2623 <dl class="methods"> | |
2624 <dt><span class="prop-name"><code>statusMessage</code></span> of type <c
ode>DOMString</code> | |
2625 <dd> | |
2626 A string containing additional information, or the empty string if n
o additional information | |
2627 is available. | |
2628 </dl> | |
2629 | |
2630 <h4>Methods</h4> | |
2631 | |
2632 <p> | |
2633 The following methods are available: | |
2634 </p> | |
2635 | |
2636 <dl class="methods"> | |
2637 <dt class="idl-code">void initWebGLContextEvent(DOMString typeArg, boole
an canBubbleArg, boolean cancelableArg, | |
2638 DOMString statusMessageA
rg) | |
2639 <dd> | |
2640 Initialize the event created through the | |
2641 <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-
Event">Event</a> | |
2642 interface. This method may only be called before the event has been
dispatched via | |
2643 the <code>dispatchEvent</code> method, though it may be called multi
ple times during | |
2644 that phase if necessary. If called multiple times, the final invocat
ion takes | |
2645 precedence. | |
2646 <P> | |
2647 <b>Parameters</b> | |
2648 <dl> | |
2649 <dt><code>typeArg</code> of type <code>DOMString</code> | |
2650 <dd>Specifies the event type (see below). | |
2651 <dt><code>canBubbleArg</code> of type <code>boolean</code> | |
2652 <dd>Specifies whether or not the event can bubble. | |
2653 <dt><code>cancelableArg</code> of type <code>boolean</code> | |
2654 <dd>Specifies whether or not the event can be canceled. | |
2655 <dt><code>statusMessageArg</code> of type <code>DOMString</code> | |
2656 <dd>A string containing additional information, or the empty str
ing if no additional information is available. | |
2657 </dl> | |
2658 <b>No Return Value</b><br> | |
2659 <b>No Exceptions</b><br> | |
2660 </dl> | |
2661 | |
2662 <h4>Event Types</h4> | |
2663 | |
2664 <dl class="methods"> | |
2665 <dt class="idl-code">webglcontextlost | |
2666 <dd> | |
2667 This event occurs when some system activity external to WebGL causes
the rendering context | |
2668 associated with the HTMLCanvasElement receiving the event to lose al
l of its state. When this | |
2669 event type is delivered, the associated context is in a "lost" state
. While the context is | |
2670 in the lost state: | |
2671 | |
2672 <ul> | |
2673 <li> The context's <code>isContextLost</code> method returns <code>true<
/code>.<br> | |
2674 <li> All methods returning <code>void</code> return immediately.<br> | |
2675 <li> All methods returning nullable values or <code>any</code> return <c
ode>null</code>.<br> | |
2676 <li> <code>checkFramebufferStatus</code> returns <code>FRAMEBUFFER_UNSUP
PORTED</code>.<br> | |
2677 <li> <code>getAttribLocation</code> returns <code>-1</code>.<br> | |
2678 <li> <code>getError</code> returns <code>CONTEXT_LOST_WEBGL</code> the f
irst time it is | |
2679 called while the context is lost. Afterward it will return <code>NO
_ERROR</code> until | |
2680 the context has been restored.<br> | |
2681 <li> <code>getVertexAttribOffset</code> returns <code>0</code>.<br> | |
2682 <li> All <code>is</code> queries return <code>false</code>.<br> | |
2683 </ul> | |
2684 <p> | |
2685 The default behavior of the <code>webglcontextlost</code> event is t
o prevent | |
2686 the context from being restored. | |
2687 <p><p> | |
2688 The <code>statusMessage</code> attribute is always the empty string
for this event. | |
2689 <div class="example"> | |
2690 The following code prevents the default behavior of the <code>webglc
ontextlost</code> | |
2691 event and enables the <code>webglcontextrestored</code> event to be
delivered: | |
2692 <pre>canvas.addEventListener("webglcontextlost", function(e) { e.preventDefa
ult(); }, false); </pre> | |
2693 </div> | |
2694 </dl> | |
2695 | |
2696 <dl class="methods"> | |
2697 <dt class="idl-code">webglcontextrestored | |
2698 <dd> | |
2699 This event occurs when the WebGL implementation determines that a pr
eviously lost context can | |
2700 be restored. The system only restores the context if the default beh
avior for the | |
2701 <code>webglcontextlost</code> event is prevented on the HTMLCanvasEl
ement associated with | |
2702 the context. | |
2703 <p><p> | |
2704 Once the context is restored, WebGL resources such as textures and b
uffers that were created | |
2705 before the context was lost are no longer valid. The application mus
t reinitialize the | |
2706 context's state and recreate all such resources. | |
2707 <p><p> | |
2708 The <code>statusMessage</code> attribute is always the empty string
for this event. | |
2709 </dl> | |
2710 | |
2711 <dl class="methods"> | |
2712 <dt class="idl-code">webglcontextcreationerror | |
2713 <dd> | |
2714 This event occurs in response to a call to <code>getContext()</code>
on the HTMLCanvasElement | |
2715 receiving the event, when some error occurs during that call. When s
uch an error occurs | |
2716 the <code>getContext()</code> returns with a <code>null</code> value
. Later, at the normal | |
2717 event delivery time, this event is delivered with the details of the
failure. If the | |
2718 HTMLCanvasElement is listening for this event, it will be delivered
whenever | |
2719 <code>getContext()</code> returns <code>null</code>. | |
2720 <p> | |
2721 The <code>statusMessage</code> attribute may contain a platform depe
ndent string about the nature | |
2722 of the failure. | |
2723 </dl> | |
2724 | |
2725 <div class="example"> | |
2726 The following ECMAScript example shows how to register event listeners on a
Canvas called | |
2727 <code>canvas1</code> which will receive context lost and restored events and
restart the | |
2728 application. For completeness, it illustrates how an application performing
asynchronous image | |
2729 loading would handle a context lost event at an arbitrary point in time. | |
2730 <pre> | |
2731 window.onload = init; | |
2732 | |
2733 var g_gl; | |
2734 var g_canvas; | |
2735 var g_intervalId; | |
2736 var g_images = []; | |
2737 var g_imgURLs = [ | |
2738 "someimage.jpg", | |
2739 "someotherimage.jpg", | |
2740 "yetanotherimage.png" | |
2741 ]; | |
2742 | |
2743 function init() { | |
2744 g_canvas = document.getElementById("canvas1"); | |
2745 g_canvas.addEventListener("webglcontextlost", contextLostHandler, false); | |
2746 g_canvas.addEventListener("webglcontextrestored", contextRestoredHandler, fals
e); | |
2747 g_gl = canvas.getContext("webgl"); | |
2748 | |
2749 for (var ii = 0; ii < g_imgURLs.length; ++ii) { | |
2750 // Create an image tag. | |
2751 var image = document.createElement('img'); | |
2752 | |
2753 // Create a texture for this image. | |
2754 image.texture = g_gl.createTexture(); | |
2755 | |
2756 // Mark the image as not loaded. | |
2757 image.loaded = false; | |
2758 | |
2759 // Setup a load callback. | |
2760 image.onload = (function(image) { | |
2761 return function() { | |
2762 imageLoadedHandler(image); | |
2763 }; | |
2764 }(image)); | |
2765 | |
2766 // Start the image loading. | |
2767 image.src = g_imgURLs[ii]; | |
2768 | |
2769 // Remember the image. | |
2770 g_images.push(image); | |
2771 } | |
2772 | |
2773 g_intervalId = window.setInterval(renderHandler, 1000/60); | |
2774 } | |
2775 | |
2776 function renderHandler() { | |
2777 // draw with textures. | |
2778 // ... | |
2779 } | |
2780 | |
2781 function imageLoadedHandler(image) { | |
2782 // Mark the image as loaded. | |
2783 image.loaded = true; | |
2784 | |
2785 // Copy the image to the texture. | |
2786 updateTexture(image); | |
2787 } | |
2788 | |
2789 function updateTexture(image) { | |
2790 if (!g_gl.isContextLost() && image.loaded) { | |
2791 g_gl.bindTexture(g_gl.TEXTURE_2D, image.texture); | |
2792 g_gl.texImage2D(g_gl.TEXTURE_2D, 0, image); | |
2793 } | |
2794 } | |
2795 | |
2796 function contextLostHandler(event) { | |
2797 // allow the context to be restored. | |
2798 event.preventDefault(); | |
2799 // stop rendering. | |
2800 window.clearInterval(g_intervalId); | |
2801 } | |
2802 | |
2803 function contextRestoredHandler() { | |
2804 // create new textures for all images and restore their contents. | |
2805 for (var ii = 0; ii < g_images.length; ++ii) { | |
2806 g_images[ii].texture = g_gl.createTexture(); | |
2807 updateTexture(g_images[ii]); | |
2808 } | |
2809 | |
2810 // Start rendering again. | |
2811 g_intervalId = window.setInterval(renderHandler, 1000/60); | |
2812 } | |
2813 </pre> | |
2814 </div> | |
2815 | |
2816 <!-- ===========================================================================
============================ --> | |
2817 | |
2818 <h2><a name="webgl_gl_differences">Differences Between WebGL and OpenGL ES 2
.0</a></h2> | |
2819 | |
2820 <p> | |
2821 | |
2822 This section describes changes made to the WebGL API relative to the OpenGL ES 2
.0 API to improve | |
2823 portability across various operating systems and devices. | |
2824 | |
2825 </p> | |
2826 | |
2827 <h3>Buffer Object Binding</h3> | |
2828 | |
2829 <p> | |
2830 | |
2831 In the WebGL API, a given buffer object may only be bound to one of the <code>AR
RAY_BUFFER</code> or | |
2832 <code>ELEMENT_ARRAY_BUFFER</code> binding points in its lifetime. This restricti
on implies that a | |
2833 given buffer object may contain either vertices or indices, but not both. | |
2834 | |
2835 </p> | |
2836 <p> | |
2837 | |
2838 The type of a WebGLBuffer is initialized the first time it is passed as an argum
ent | |
2839 to <code>bindBuffer</code>. A subsequent call to <code>bindBuffer</code> which a
ttempts to bind the | |
2840 same WebGLBuffer to the other binding point will generate an <code>INVALID_OPERA
TION</code> error, and | |
2841 the state of the binding point will remain untouched. | |
2842 | |
2843 </p> | |
2844 | |
2845 <h3>No Client Side Arrays</h3> | |
2846 | |
2847 <p> | |
2848 | |
2849 The WebGL API does not support client-side arrays. If <code>vertexAttribPointer<
/code> is called | |
2850 without a <code>WebGLBuffer</code> bound to the <code>ARRAY_BUFFER</code> bindin
g point, | |
2851 an <code>INVALID_OPERATION</code> error is generated. If <code>drawElements</cod
e> is called with | |
2852 a <code>count</code> greater than zero, and no <code>WebGLBuffer</code> is bound
to | |
2853 the <code>ELEMENT_ARRAY_BUFFER</code> binding point, an <code>INVALID_OPERATION<
/code> error is | |
2854 generated. | |
2855 | |
2856 </p> | |
2857 | |
2858 <h3><a name="BUFFER_OFFSET_AND_STRIDE">Buffer Offset and Stride Requirements
</a></h3> | |
2859 | |
2860 <p> | |
2861 | |
2862 The <code>offset</code> arguments to <code>drawElements</code> and <code>vertexA
ttribPointer</code>, | |
2863 and the <code>stride</code> argument to <code>vertexAttribPointer</code>, must b
e a multiple of the | |
2864 size of the data type passed to the call, or an <code>INVALID_OPERATION</code> e
rror is generated. | |
2865 | |
2866 </p> | |
2867 | |
2868 | |
2869 <h3><a name="ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes and Range
Checking</a></h3> | |
2870 | |
2871 <p> | |
2872 | |
2873 If a vertex attribute is enabled as an array via <code>enableVertexAttribArray</
code> but no buffer | |
2874 is bound to that attribute via <code>bindBuffer</code> and <code>vertexAttribPoi
nter</code>, then | |
2875 calls to <code>drawArrays</code> or <code>drawElements</code> will generate an | |
2876 <code>INVALID_OPERATION</code> error. | |
2877 | |
2878 </p> | |
2879 <p> | |
2880 | |
2881 If a vertex attribute is enabled as an array, a buffer is bound to that attribut
e, and the attribute | |
2882 is consumed by the current program, then calls to <code>drawArrays</code> | |
2883 and <code>drawElements</code> will verify that each referenced vertex lies withi
n the storage of the | |
2884 bound buffer. If the range specified in <code>drawArrays</code> or any reference
d index | |
2885 in <code>drawElements</code> lies outside the storage of the bound buffer, an IN
VALID_OPERATION | |
2886 error is generated and no geometry is drawn. | |
2887 | |
2888 </p> | |
2889 <p> | |
2890 | |
2891 If a vertex attribute is enabled as an array, a buffer is bound to that attribut
e, but the attribute | |
2892 is not consumed by the current program, then regardless of the size of the bound
buffer, it will not | |
2893 cause any error to be generated during a call to <code>drawArrays</code> | |
2894 or <code>drawElements</code>. | |
2895 | |
2896 </p> | |
2897 | |
2898 <h3>Framebuffer Object Attachments</h3> | |
2899 | |
2900 <p> | |
2901 | |
2902 WebGL adds the <code>DEPTH_STENCIL_ATTACHMENT</code> framebuffer object attachme
nt point and | |
2903 the <code>DEPTH_STENCIL</code> renderbuffer internal format. To attach both dept
h and stencil | |
2904 buffers to a framebuffer object, call <code>renderbufferStorage</code> with | |
2905 the <code>DEPTH_STENCIL</code> internal format, and then call <code>framebufferR
enderbuffer</code> | |
2906 with the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point. | |
2907 | |
2908 </p> | |
2909 <p> | |
2910 | |
2911 A renderbuffer attached to the <code>DEPTH_ATTACHMENT</code> attachment point mu
st be allocated with | |
2912 the <code>DEPTH_COMPONENT16</code> internal format. A renderbuffer attached to | |
2913 the <code>STENCIL_ATTACHMENT</code> attachment point must be allocated with | |
2914 the <code>STENCIL_INDEX8</code> internal format. A renderbuffer attached to | |
2915 the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point must be allocated wit
h | |
2916 the <code>DEPTH_STENCIL</code> internal format. | |
2917 | |
2918 </p> | |
2919 <p> | |
2920 | |
2921 In the WebGL API, it is an error to concurrently attach renderbuffers to the fol
lowing combinations | |
2922 of attachment points: | |
2923 | |
2924 <ul> | |
2925 <li> <code>DEPTH_ATTACHMENT + DEPTH_STENCIL_ATTACHMENT</code> | |
2926 <li> <code>STENCIL_ATTACHMENT + DEPTH_STENCIL_ATTACHMENT</code> | |
2927 <li> <code>DEPTH_ATTACHMENT + STENCIL_ATTACHMENT</code> | |
2928 </ul> | |
2929 | |
2930 If any of the constraints above are violated, then: | |
2931 | |
2932 <ul> | |
2933 <li> <code>checkFramebufferStatus</code> must return <code>FRAMEBUFFER_UNSUPPORT
ED</code>. | |
2934 <li> The following calls, which either modify or read the framebuffer, must gene
rate | |
2935 an <code>INVALID_FRAMEBUFFER_OPERATION</code> error and return early, leavi
ng the contents of | |
2936 the framebuffer, destination texture or destination memory untouched. | |
2937 <ul> | |
2938 <li> clear | |
2939 <li> copyTexImage2D | |
2940 <li> copyTexSubImage2D | |
2941 <li> drawArrays | |
2942 <li> drawElements | |
2943 <li> readPixels | |
2944 </ul> | |
2945 </ul> | |
2946 | |
2947 <h3><a name="PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a></h3> | |
2948 | |
2949 <p> | |
2950 The WebGL API supports the following additional parameters to <code>pixelStorei<
/code>. | |
2951 | |
2952 <dl> | |
2953 <dt><code>UNPACK_FLIP_Y_WEBGL</code> of type <code>boolean</code> | |
2954 <dd>If set, then during any subsequent calls to <code>texImage2D</code> or | |
2955 <code>texSubImage2D</code>, the source data is flipped along the vertical axis,
so that conceptually | |
2956 the last row is the first one transferred. The default value is <code>false</cod
e>. Any non-zero | |
2957 value is interpreted as <code>true</code>. | |
2958 | |
2959 <dt><code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> of type <code>boolean</code> | |
2960 <dd>If set, then during any subsequent calls to <code>texImage2D</code> | |
2961 or <code>texSubImage2D</code>, the alpha channel of the source data, if present,
is multiplied into | |
2962 the color channels during the data transfer. The default value is <code>false</c
ode>. Any non-zero | |
2963 value is interpreted as <code>true</code>. | |
2964 | |
2965 <dt><code>UNPACK_COLORSPACE_CONVERSION_WEBGL</code> of type <code>unsigned long<
/code> | |
2966 <dd>If set to <code>BROWSER_DEFAULT_WEBGL</code>, then the browser's default col
orspace conversion | |
2967 is applied during subsequent <code>texImage2D</code> and <code>texSubImage2D</co
de> calls | |
2968 taking <code>HTMLImageElement</code>. The precise conversions may be specific to
both the browser | |
2969 and file type. If set to <code>NONE</code>, no colorspace conversion is applied.
The default value | |
2970 is <code>BROWSER_DEFAULT_WEBGL</code>. | |
2971 | |
2972 </dl> | |
2973 | |
2974 <h3><a name="READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the Framebuffer</
a></h3> | |
2975 | |
2976 <p> | |
2977 In the WebGL API, functions which read the framebuffer | |
2978 (<code>copyTexImage2D</code>, <code>copyTexSubImage2D</code>, and <code>readPixe
ls</code>) are | |
2979 defined to generate the RGBA value (0, 0, 0, 0) for any pixel which is outside o
f the bound | |
2980 framebuffer. | |
2981 </p> | |
2982 | |
2983 <h3><a name="STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and Reference Value</
a></h3> | |
2984 | |
2985 <p> | |
2986 In the WebGL API it is illegal to specify a different mask or reference value fo
r front facing and | |
2987 back facing triangles in stencil operations. A call to <code>drawArrays</code> | |
2988 or <code>drawElements</code> will generate an <code>INVALID_OPERATION</code> err
or if: | |
2989 | |
2990 <ul> | |
2991 <li> <code>STENCIL_WRITEMASK</code> != <code>STENCIL_BACK_WRITEMASK</code> (as s
pecified by <code>stencilMaskSeparate</code> for the <code>mask</code> parameter
associated with the FRONT and BACK values of <code>face</code>, respectively) | |
2992 <li> <code>STENCIL_VALUE_MASK</code> != <code>STENCIL_BACK_VALUE_MASK</code> (as
specified by <code>stencilFuncSeparate</code> for the <code>mask</code> paramet
er associated with the FRONT and BACK values of <code>face</code>, respectively) | |
2993 <li> <code>STENCIL_REF</code> != <code>STENCIL_BACK_REF</code> (as specified by
<code>stencilFuncSeparate</code> for the <code>ref</code> parameter associated w
ith the FRONT and BACK values of <code>face</code>, respectively) | |
2994 </ul> | |
2995 | |
2996 </p> | |
2997 | |
2998 <h3><a name="VERTEX_STRIDE">Vertex Attribute Data Stride</a></h3> | |
2999 | |
3000 <p> | |
3001 The WebGL API supports vertex attribute data strides up to 255 bytes. A call to | |
3002 <code>vertexAttribPointer</code> will generate an <code>INVALID_VALUE</code> err
or if the value for | |
3003 the stride parameter exceeds 255. | |
3004 </p> | |
3005 | |
3006 <h3><a name="VIEWPORT_DEPTH_RANGE">Viewport Depth Range</a></h3> | |
3007 | |
3008 <p> | |
3009 The WebGL API does not support depth ranges with where the near plane is mapped
to a value greater | |
3010 than that of the far plane. A call to <code>depthRange</code> will generate an | |
3011 <code>INVALID_OPERATION</code> error if <code>zNear</code> is greater than <code
>zFar</code>. | |
3012 </p> | |
3013 | |
3014 <h3><a name="CONSTANT_COLOR_BLEND">Blending With Constant Color</a></h3> | |
3015 | |
3016 <p> | |
3017 In the WebGL API, constant color and constant alpha cannot be used together as s
ource and | |
3018 destination factors in the blend function. A call to <code>blendFunc</code> will
generate an | |
3019 <code>INVALID_OPERATION</code> error if one of the two factors is set to <code>C
ONSTANT_COLOR</code> | |
3020 or <code>ONE_MINUS_CONSTANT_COLOR</code> and the other to <code>CONSTANT_ALPHA</
code> or | |
3021 <code>ONE_MINUS_CONSTANT_ALPHA</code>. A call to <code>blendFuncSeparate</code>
will generate an | |
3022 <code>INVALID_OPERATION</code> error if <code>srcRGB</code> is set to <code>CONS
TANT_COLOR</code> | |
3023 or <code>ONE_MINUS_CONSTANT_COLOR</code> and <code>dstRGB</code> is set to <code
>CONSTANT_ALPHA</code> or | |
3024 <code>ONE_MINUS_CONSTANT_ALPHA</code> or vice versa. | |
3025 </p> | |
3026 | |
3027 <h3>Fixed point support</h3> | |
3028 | |
3029 The WebGL API does not support the <code>GL_FIXED</code> data type. | |
3030 | |
3031 <h3>GLSL Constructs</h3> | |
3032 | |
3033 <p> | |
3034 Per <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</a>, identifi
ers starting with | |
3035 "webgl_" and "_webgl_" are reserved for use by WebGL. | |
3036 </p> | |
3037 | |
3038 <h3><a name="EXTENSION_QUERIES">Extension Queries</a></h3> | |
3039 | |
3040 <p> | |
3041 | |
3042 In the OpenGL ES 2.0 API, the available extensions are determined by calling | |
3043 <code>glGetString(GL_EXTENSIONS)</code>, which returns a space-separated list of
extension strings. | |
3044 In the WebGL API, the <code>EXTENSIONS</code> enumerant has been removed. | |
3045 Instead, <code>getSupportedExtensions</code> must be called to determine the set
of available | |
3046 extensions. | |
3047 | |
3048 </p> | |
3049 | |
3050 <h3><a name="IMPLEMENTATION_READ_FORMAT">Implementation Color Read Format an
d Type</a></h3> | |
3051 | |
3052 <p> | |
3053 | |
3054 In the OpenGL ES 2.0 API, the | |
3055 <code>IMPLEMENTATION_COLOR_READ_FORMAT</code> and | |
3056 <code>IMPLEMENTATION_COLOR_READ_TYPE</code> parameters are used to inform ap
plications of an | |
3057 additional format and type combination that may be passed to <code>ReadPixel
s</code>, in | |
3058 addition to the required <ncode>RGBA</code>/<code>UNSIGNED_BYTE</code> pair.
In WebGL 1.0, | |
3059 the supported format and type combinations to <code>ReadPixels</code> are do
cumented in the | |
3060 <a href="#readpixels">Reading back pixels</a> section. The <code>IMPLEMENTA
TION_COLOR_READ_FORMAT</code> | |
3061 and <code>IMPLEMENTATION_COLOR_READ_TYPE</code> enumerants have been removed
. | |
3062 </p> | |
3063 | |
3064 <h3><a name="COMPRESSED_TEXTURE_SUPPORT">Compressed Texture Support</a></h3> | |
3065 | |
3066 <p> | |
3067 WebGL does not support any compressed texture formats. Therefore the <code>C
ompressedTexImage2D</code> | |
3068 and <code>CompressedTexSubImage2D</code> functions are not included in this
specification. | |
3069 Likewise the <code>COMPRESSED_TEXTURE_FORMATS</code> and <code>NUM_COMPRESSE
D_TEXTURE_FORMATS</code> | |
3070 parameters to <code>getParameter</code> will return the value null or zero. | |
3071 </p> | |
3072 | |
3073 <h3><a name="MAX_GLSL_TOKEN_SIZE">Maximum GLSL Token Size</a></h3> | |
3074 | |
3075 <p> | |
3076 The GLSL ES spec <a href="#refsGLES20GLSL">[GLES20GLSL]</a> does not define
a limit to the | |
3077 length of tokens. WebGL requires support of tokens up to 256 characters in l
ength. Shaders | |
3078 containing tokens longer than 256 characters must fail to compile. | |
3079 </p> | |
3080 | |
3081 <h3><a name="CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Sourc
e Character Set</a></h3> | |
3082 | |
3083 <p> | |
3084 The GLSL ES spec <a href="#refsGLES20GLSL">[GLES20GLSL]</a> defines the sour
ce character set for | |
3085 the OpenGL ES shading language to be ISO/IEC 646:1991, commonly called ASCII
<a href="#refsASCII">[ASCII]</a>. | |
3086 If a string containing a character not in this set is passed to any of the s
hader-related entry | |
3087 points <code>bindAttribLocation</code>, <code>getAttribLocation</code>, <cod
e>getUniformLocation</code>, | |
3088 or <code>shaderSource</code>, an <code>INVALID_VALUE</code> error will be ge
nerated. The exception is | |
3089 that any character allowed in an HTML DOMString <a href="#refsDOMSTRING">[DO
MSTRING]</a> may be used | |
3090 in GLSL comments. Such use must not generate an error. | |
3091 </p> | |
3092 | |
3093 <div class="note"> | |
3094 <p> | |
3095 Some GLSL implementations disallow characters outside the ASCII range, e
ven in comments. The | |
3096 WebGL implementation needs to prevent errors in such cases. The recommen
ded technique is to | |
3097 preprocess the GLSL string, removing all comments, but maintaining the l
ine numbering for | |
3098 debugging purposes by inserting newline characters as needed. | |
3099 </p> | |
3100 </div> | |
3101 | |
3102 <h3>String Length Queries</h3> | |
3103 | |
3104 <p> | |
3105 In the WebGL API, the enumerants <code>INFO_LOG_LENGTH</code>, <code>SHADER_
SOURCE_LENGTH</code>, | |
3106 <code>ACTIVE_UNIFORM_MAX_LENGTH</code>, and <code>ACTIVE_ATTRIB_MAX_LENGTH</
code> have been removed. In | |
3107 the OpenGL ES 2.0 API, these enumerants are needed to determine the size of
buffers passed to calls | |
3108 like <code>glGetActiveAttrib</code>. In the WebGL API, the analogous calls (
<code>getActiveAttrib</code>, | |
3109 <code>getActiveUniform</code>, <code>getProgramInfoLog</code>, <code>getShad
erInfoLog</code>, and | |
3110 <code>getShaderSource</code>) all return <code>DOMString</code>. | |
3111 </p> | |
3112 | |
3113 <!-- ===========================================================================
============================ --> | |
3114 | |
3115 <h2>References</h2> | |
3116 | |
3117 <h3>Normative references</h3> | |
3118 <dl> | |
3119 | |
3120 <dt id="refsCANVAS">[CANVAS]</dt> | |
3121 <dd><cite><a href="http://www.w3.org/TR/html5/the-canvas-element.html"> | |
3122 HTML5: The Canvas Element</a></cite>, | |
3123 World Wide Web Consortium (W3C). | |
3124 </dd> | |
3125 <dt id="refsTYPEDARRAYS">[TYPEDARRAYS]</dt> | |
3126 <dd><cite><a href="http://www.khronos.org/registry/typedarray/specs/late
st/"> | |
3127 Typed Array Specification: Editor's Draft</a></cite>, | |
3128 V. Vukicevic, K. Russell, May 2010. | |
3129 </dd> | |
3130 <dt id="refsGLES20">[GLES20]</dt> | |
3131 <dd><cite><a href="http://www.khronos.org/registry/gles/specs/2.0/es_ful
l_spec_2.0.25.pdf"> | |
3132 OpenGL® ES Common Profile Specification Version 2.0.25</a></cite
>, | |
3133 A. Munshi, J. Leech, November 2010. | |
3134 </dd> | |
3135 <dt id="refsGLES20GLSL">[GLES20GLSL]</dt> | |
3136 <dd><cite><a href="http://www.khronos.org/registry/gles/specs/2.0/GLSL_E
S_Specification_1.0.17.pdf"> | |
3137 The OpenGL® ES Shading Language Version 1.00</a></cite>, | |
3138 R. Simpson, May 2009. | |
3139 </dd> | |
3140 <dt id="refsREGISTRY">[REGISTRY]</dt> | |
3141 <dd><cite><a href="http://www.khronos.org/registry/webgl/extensions/"> | |
3142 WebGL Extension Registry</a></cite> | |
3143 </dd> | |
3144 <dt id="refsRFC2119">[RFC2119]</dt> | |
3145 <dd><cite><a href="http://www.ietf.org/rfc/rfc2119.txt"> | |
3146 Key words for use in RFCs to Indicate Requirement Levels</a></cite>, | |
3147 S. Bradner. IETF, March 1997. | |
3148 </dd> | |
3149 <dt id="refsCORS">[CORS]</dt> | |
3150 <dd><cite><a href="http://www.w3.org/TR/cors/"> | |
3151 Cross-Origin Resource Sharing</a></cite>, | |
3152 A. van Kesteren, July 2010. | |
3153 </dd> | |
3154 <dt id="refsHTML">[HTML]</dt> | |
3155 <dd><cite><a href="http://www.whatwg.org/specs/web-apps/current-work/mul
tipage/"> | |
3156 HTML</a></cite>, | |
3157 I. Hickson, June 2011. | |
3158 </dd> | |
3159 <dt id="refsWEBIDL">[WEBIDL]</dt> | |
3160 <dd><cite><a href="http://dev.w3.org/2006/webapi/WebIDL/"> | |
3161 Web IDL: W3C Editor’s Draft</a></cite>, | |
3162 C. McCormack, September 2009. | |
3163 </dd> | |
3164 <dt id="refsASCII">[ASCII]</dt> | |
3165 <dd><cite>International Standard ISO/IEC 646:1991. Information technolog
y - | |
3166 ISO 7-bit coded character set for information interchange</cite> | |
3167 </dd> | |
3168 <dt id="refsDOMSTRING">[DOMSTRING]</dt> | |
3169 <dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#DOMSt
ring"> | |
3170 Document Object Model Core: The DOMString type</a></cite>, | |
3171 World Wide Web Consortium (W3C). | |
3172 </dd> | |
3173 </dl> | |
3174 | |
3175 <h3>Other references</h3> | |
3176 | |
3177 <!-- ===========================================================================
============================ --> | |
3178 | |
3179 <h2>Acknowledgments</h2> | |
3180 <p>This specification is produced by the Khronos WebGL Working Group.</p> | |
3181 | |
3182 <p> | |
3183 Special thanks to: Arun Ranganathan (Mozilla), Jon Leech, Kenneth Russell
(Google), | |
3184 Kenneth Waters (Google), Mark Callow (HI), Mark Steele (Mozilla), Oliver
Hunt (Apple), | |
3185 Tim Johansson (Opera), Vangelis Kokkevis (Google), Vladimir Vukicevic (Mo
zilla), | |
3186 Gregg Tavares (Google) | |
3187 </p> | |
3188 <p> | |
3189 Additional thanks to: Alan Hudson (Yumetech), Bill Licea Kane (AMD), Ced
ric Vivier (Zegami), | |
3190 Dan Gessel (Apple), David Ligon (Qualcomm), Glenn Maynard, Greg Roth (Nv
idia), Jacob Strom (Ericsson), Kari Pulli (Nokia), | |
3191 Leddie Stenvie (ST-Ericsson), Neil Trevett (Nvidia), Per Wennersten (Eri
csson), | |
3192 Per-Erik Brodin (Ericsson), Shiki Okasaka (Google), Tom Olson (ARM), Zhe
ngrong Yao (Ericsson), | |
3193 and the members of the Khronos WebGL Working Group. | |
3194 </p> | |
3195 | |
3196 </body> | |
3197 </html> | |
OLD | NEW |