Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / specs / 1.0.2 / index.html
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-Final.css" />
9     <script src="../../resources/jquery-1.3.2.min.js" type="text/javascript"></script>
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" width=156>
25             </a>
26         </p>
27     </div>
28     <!--end-logo-->
29     
30     <h1>WebGL Specification</h1>
31     <h2 class="no-toc">Version 1.0.2, 01 March 2013</h2>
32     <dl>
33         <dt>This version:
34             <dd>
35                 <a href="https://www.khronos.org/registry/webgl/specs/1.0.2/">
36                     https://www.khronos.org/registry/webgl/specs/1.0.2/
37                 </a>
38                 <br>
39                 <a href="https://www.khronos.org/registry/webgl/specs/1.0.2/webgl.idl">
40                     <b>WebIDL:</b> https://www.khronos.org/registry/webgl/specs/1.0.2/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/webgl.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.1/">
56                     https://www.khronos.org/registry/webgl/specs/1.0.1/
57                 </a>
58                 <br>
59                 <a href="https://www.khronos.org/registry/webgl/specs/1.0.1/webgl.idl">
60                     <b>WebIDL:</b> https://www.khronos.org/registry/webgl/specs/1.0.1/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 &copy; 2013 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="#refsCANVAS">[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         Public discussion of this specification 
90         is welcome on the (<a
91             href="https://www.khronos.org/webgl/public-mailing-list/archives/">archived</a>) 
92         WebGL mailing list <a href="mailto:public_webgl@khronos.org">public_webgl@khronos.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     </div>
129
130     <h3>Conventions</h3>
131
132     <p>
133      Many functions described in this document contain links to OpenGL ES
134      man pages. While every effort is made to make these pages match the
135      OpenGL ES 2.0 specification <a href="#refsGLES20">[GLES20]</a>, 
136      they may contain errors. In the case of a contradiction, the OpenGL 
137      ES 2.0 specification is the final authority.
138     </p>
139
140     <p>
141       The remaining sections of this document are intended to be read in conjunction
142       with the OpenGL ES 2.0 specification (2.0.25 at the time of this writing, available
143       from the <a href="http://www.khronos.org/registry/gles/">Khronos OpenGL ES API Registry</a>).
144       Unless otherwise specified, the behavior of each method is defined by the
145       OpenGL ES 2.0 specification.  This specification may diverge from OpenGL ES 2.0
146       in order to ensure interoperability or security, often defining areas that
147       OpenGL ES 2.0 leaves implementation-defined.  These differences are summarized in the
148       <a href="#webgl_gl_differences">Differences Between WebGL and OpenGL ES 2.0</a> section.
149     </p>
150
151 <!-- ======================================================================================================= -->
152
153     <h2>Context Creation and Drawing Buffer Presentation</h2>
154
155     <p>
156         Before using the WebGL API, the author must obtain a <code>WebGLRenderingContext</code>
157         object for a given HTMLCanvasElement <a href="#refsCANVAS">[CANVAS]</a> as described
158         below. This object is used to manage OpenGL state and render to the drawing buffer, which
159         must be created at the time of context creation.
160     </p>
161     
162 <!-- ======================================================================================================= -->
163
164     <h3>Context Creation</h3>
165
166     <p>
167         Each <code>WebGLRenderingContext</code> has an
168         associated <b><a name="context-canvas">canvas</a></b>, set upon creation, which is
169         a <em>canvas</em> <a href="#refsCANVAS">[CANVAS]</a>.
170     </p>
171     <p>
172         Each <code>WebGLRenderingContext</code> has <b><a name="context-creation-parameters">context
173         creation parameters</a></b>, set upon creation, in
174         a <a href="#WEBGLCONTEXTATTRIBUTES"><code>WebGLContextAttributes</code></a> object.
175     </p>
176     <p>
177         Each <code>WebGLRenderingContext</code> has <b><a name="actual-context-parameters">actual
178         context parameters</a></b>, set each time the drawing buffer is created, in
179         a <a href="#WEBGLCONTEXTATTRIBUTES"><code>WebGLContextAttributes</code></a> object.
180     </p>
181     <p>
182         Each <code>WebGLRenderingContext</code> has a <b><a name="webgl-context-lost-flag">webgl
183         context lost flag</a></b>, which is initially unset.
184     </p>
185     <p>
186         When the <code>getContext()</code> method of a <code>canvas</code> element is to return a
187         new object for
188         the <em>contextId</em> <code>webgl</code> <a href="#refsCANVASCONTEXTS">[CANVASCONTEXTS]</a>,
189         the user agent must perform the following steps:
190
191         <ol class="nestedlist">
192
193         <li> Create a new <code>WebGLRenderingContext</code> object, <em>context</em>.
194
195         <li> Let <em>context's</em> <a href="#context-canvas">canvas</a> be the canvas
196              the <code>getContext()</code> method is associated with.
197
198         <li> Create a new <code>WebGLContextAttributes</code> object, <em>contextAttributes</em>.
199
200         <li> If <code>getContext()</code> was invoked with a second argument, <em>options</em>, set
201              the attributes of <em>contextAttributes</em> from those specified in <em>options</em>.
202
203         <li> <a href="#create-a-drawing-buffer">Create a <em>drawing buffer</em></a> using the settings
204              specified in <em>contextAttributes</em>, and associate the <em>drawing buffer</em>
205              with <em>context</em>.
206
207         <li> If drawing buffer creation failed, perform the following steps:
208
209           <ol class="nestedlist">
210
211           <li> <a href="#fire-a-webgl-context-creation-error">Fire a WebGL context creation
212           error</a> at <em>canvas</em>.
213
214           <li> Return null and terminate these steps.
215
216           </ol>
217
218         <li> Set the attributes of <em>contextAttributes</em> based on the properties of the newly
219              created drawing buffer.
220
221         <li> Set <em>context's</em> <a href="#context-creation-parameters">context creation
222         parameters</a> to <em>contextAttributes</em>.
223
224         <li> Return <em>context</em>.
225
226         </ol>
227     </p>
228     
229 <!-- ======================================================================================================= -->
230
231     <h3><a name="THE_DRAWING_BUFFER">The Drawing Buffer</a></h3>
232
233     <p>
234         The drawing buffer into which the API calls are rendered shall be defined upon creation of
235         the WebGLRenderingContext object. The following description defines how
236         to <b><a name="create-a-drawing-buffer">create a drawing buffer</a></b>.
237     </p>
238     <p>
239         The table below shows all the buffers which make up the drawing buffer, along with their
240         minimum sizes and whether they are defined or not by default. The size of this drawing
241         buffer shall be determined by the <code>width</code> and <code>height</code> attributes of
242         the HTMLCanvasElement. The table below also shows the value to which these buffers shall be
243         cleared when first created, when the size is changed, or after presentation when
244         the <code>preserveDrawingBuffer</code> context creation attribute is <code>false</code>.
245     </p>
246     <table class="foo">
247         <tr><th>Buffer</th><th>Clear value</th><th>Minimum size</th><th>Defined by default?</th></tr>
248         <tr><td>Color</td><td>(0, 0, 0, 0)</td><td>8 bits per component</td><td>yes</td></tr>
249         <tr><td>Depth</td><td>1.0</td><td>16 bit integer</td><td>yes</td></tr>
250         <tr><td>Stencil</td><td>0</td><td>8 bits</td><td>no</td></tr>
251     </table>
252     <br>
253     <p>
254         If the requested width or height cannot be satisfied, either when the drawing buffer is first
255         created or when the <code>width</code> and <code>height</code> attributes of the 
256         <code>HTMLCanvasElement</code> are changed, a drawing buffer with smaller dimensions shall
257         be created. The dimensions actually used are implementation dependent and there is no 
258         guarantee that a buffer with the same aspect ratio will be created. The actual drawing 
259         buffer size can be obtained from the <code>drawingBufferWidth</code> and 
260         <code>drawingBufferHeight</code> attributes.
261     </p>
262     <p>
263         A WebGL implementation must not perform any automatic scaling of the size of the drawing
264         buffer on high-definition displays. The context's <code>drawingBufferWidth</code>
265         and <code>drawingBufferHeight</code> must match the canvas's <code>width</code>
266         and <code>height</code> attributes as closely as possible, modulo implementation-dependent
267         constraints.
268     </p>
269     <div class="note">
270         <p>
271             The constraint above does not change the amount of space the canvas element consumes on
272             the web page, even on a high-definition display. The
273             canvas's <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#attr-canvas-width">intrinsic
274             dimensions</a> <a href="#refsCANVAS">[CANVAS]</a> equal the size of its coordinate
275             space, with the numbers interpreted in CSS pixels, and CSS pixels
276             are <a href="http://www.w3.org/TR/CSS21/syndata.html#length-units">resolution-independent</a> <a href="#refsCSS">[CSS]</a>.
277         </p>
278         <p>
279             A WebGL application can achieve a 1:1 ratio between drawing buffer pixels and on-screen
280             pixels on high-definition displays by examining properties
281             like <code>window.devicePixelRatio</code>, scaling the canvas's <code>width</code>
282             and <code>height</code> by that factor, and setting its CSS width and height to the
283             original width and height. An application can simulate the effect of running on a
284             higher-resolution display simply by scaling up the canvas's <code>width</code>
285             and <code>height</code> properties.
286         </p>
287     </div>
288     <p>
289         The optional <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> object may be used
290         to change whether or not the buffers are defined. It can also be used to define whether the
291         color buffer will include an alpha channel. If defined, the alpha channel is used by the
292         HTML compositor to combine the color buffer with the rest of the page. The
293         WebGLContextAttributes object is only used on the first call to
294         <code>getContext</code>. No facility is provided to change the attributes of the drawing 
295         buffer after its creation.
296     </p>
297     <p>
298         The <code>depth</code>, <code>stencil</code> and <code>antialias</code> attributes, when set
299         to true, are requests, not requirements. The WebGL implementation should make a best effort
300         to honor them. When any of these attributes is set to false, however, the WebGL
301         implementation must not provide the associated functionality. Combinations of attributes not
302         supported by the WebGL implementation or graphics hardware shall not cause a failure to
303         create a WebGLRenderingContext. The <a href="#actual-context-parameters">actual context
304         parameters</a> are set to the attributes of the created drawing buffer. The
305         <code>alpha</code>, <code>premultipliedAlpha</code> and <code>preserveDrawingBuffer</code>
306         attributes must be obeyed by the WebGL implementation.
307     </p>
308     <p>
309         WebGL presents its drawing buffer to the HTML page compositor immediately before a
310         compositing operation, but only if <code>clear</code>, <code>drawArrays</code>
311         or <code>drawElements</code> have been called since the last compositing operation, while
312         the drawing buffer is the currently bound framebuffer. Before the drawing buffer is
313         presented for compositing the implementation shall ensure that all rendering operations have
314         been flushed to the drawing buffer. By default, after compositing the contents of the
315         drawing buffer shall be cleared to their default values, as shown in the table above.
316     </p>
317     <p>
318         This default behavior can be changed by setting the <code>preserveDrawingBuffer</code>
319         attribute of the <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> object. If
320         this flag is true, the contents of the drawing buffer shall be preserved until the author
321         either clears or overwrites them. If this flag is false, attempting to perform operations
322         using this context as a source image after the rendering function has returned can lead to
323         undefined behavior. This includes <code>readPixels</code> or <code>toDataURL</code> calls,
324         or using this context as the source image of another context's <code>texImage2D</code> or
325         <code>drawImage</code> call.
326     </p>
327     <div class="note">        
328         <p>
329             While it is sometimes desirable to preserve the drawing buffer, it can cause significant 
330             performance loss on some platforms. Whenever possible this flag should remain false 
331             and other techniques used. Techniques like synchronous drawing buffer access (e.g., 
332             calling <code>readPixels</code> or <code>toDataURL</code> in the same function that 
333             renders to the drawing buffer) can be used to get the contents of the drawing buffer. 
334             If the author needs to render to the same drawing buffer over a series of calls, a 
335             <a href="#WEBGL_FRAMEBUFFER">Framebuffer Object</a> can be used.
336         </p>
337         <p>
338             Implementations may optimize away the required implicit clear operation of the Drawing 
339             Buffer as long as a guarantee can be made that the author cannot gain access to buffer 
340             contents from another process. For instance, if the author performs an explicit 
341             clear then the implicit clear is not needed.
342         </p>
343     </div>
344     
345 <!-- ======================================================================================================= -->
346
347     <h3>The WebGL Viewport</h3>
348
349     <p>
350         OpenGL manages a rectangular viewport as part of its state which defines the placement of
351         the rendering results in the drawing buffer. Upon creation of WebGL
352         context <em>context</em>, the viewport is initialized to a rectangle with origin at (0, 0)
353         and width and height equal to (context.drawingBufferWidth, context.drawingBufferHeight).
354     </p>
355     <p>
356         A WebGL implementation <em>shall not</em> affect the state of the OpenGL viewport in response to
357         resizing of the canvas element.
358     </p>
359     <div class="example">
360         Note that if a WebGL program does not contain logic to set the viewport, it will not properly
361         handle the case where the canvas is resized. The following ECMAScript example illustrates how
362         a WebGL program might resize the canvas programmatically.
363
364         <pre>
365 var canvas = document.getElementById('canvas1');
366 var gl = canvas.getContext('webgl');
367 canvas.width = newWidth;
368 canvas.height = newHeight;
369 gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
370         </pre>
371     </div>
372     <p>
373         <em>Rationale</em>: automatically setting the viewport will interfere with applications that set
374         it manually. Applications are expected to use <code>onresize</code> handlers to respond to
375         changes in size of the canvas and set the OpenGL viewport in turn.
376     </p>
377
378 <!-- ======================================================================================================= -->
379
380     <h3><a name="PREMULTIPLIED_ALPHA">Premultiplied Alpha, Canvas APIs and texImage2D</a></h3>
381
382     <p>
383         The OpenGL API allows the application to modify the blending modes used during rendering,
384         and for this reason allows control over how alpha values in the drawing buffer are
385         interpreted; see the <code>premultipliedAlpha</code> parameter in
386         the <a href="#WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a> section.
387     </p>
388     <p>
389         The HTML Canvas APIs <code>toDataURL</code> and <code>drawImage</code> must respect
390         the <code>premultipliedAlpha</code> context creation parameter. When <code>toDataURL</code>
391         is called against a Canvas into which WebGL content is being rendered, then if the requested
392         image format does not specify premultiplied alpha and the WebGL context has
393         the <code>premultipliedAlpha</code> parameter set to true, then the pixel values must be
394         de-multiplied; i.e., the color channels are divided by the alpha channel. <b>Note</b> that
395         this operation is lossy.
396     </p>
397     <p>
398         Passing a WebGL-rendered Canvas to the <code>drawImage</code> method
399         of <code>CanvasRenderingContext2D</code> may or may not need to modify the the rendered
400         WebGL content during the drawing operation, depending on the premultiplication needs of the
401         <code>CanvasRenderingContext2D</code> implementation.
402     </p>
403     <p>
404         When passing a WebGL-rendered Canvas to the <code>texImage2D</code> API, then depending on
405         the setting of the <code>premultipliedAlpha</code> context creation parameter of the passed
406         canvas and the <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel store parameter of the
407         destination WebGL context, the pixel data may need to be changed to or from premultiplied
408         form.
409     </p>
410
411 <!-- ======================================================================================================= -->
412
413     <h2>WebGL Resources</h2>
414
415     <p> 
416         OpenGL manages several types of resources as part of its state. These are identified
417         by integer object names and are obtained from OpenGL by various creation calls.
418         In contrast WebGL represents these resources as DOM objects. Each object is derived 
419         from the WebGLObject interface. Currently supported resources are:
420         textures, buffers (i.e., VBOs), framebuffers, renderbuffers, shaders and
421         programs. The WebGLRenderingContext interface has a method to create a 
422         WebGLObject subclass for each type. Data from the underlying graphics library are
423         stored in these objects and are fully managed by them. The resources represented
424         by these objects are guaranteed to exist as long as the object exists.
425         Furthermore, the DOM object is guaranteed to exist as long as the author has an explicit
426         valid reference to it <b>or</b> as long as it is bound by the underlying graphics library.
427         When none of these conditions exist the user agent can, at any point, delete the object 
428         using the equivalent of a delete call (e.g., deleteTexture). If authors wish to control 
429         when the underlying resource is released then the delete call can be made explicitly.
430     </p>
431
432 <!-- ======================================================================================================= -->
433
434     <h2>Security</h2>
435
436     <p> 
437     </p>
438
439 <!-- ======================================================================================================= -->
440
441     <h3>Resource Restrictions</h3>
442
443     <p>
444         WebGL resources such as textures and vertex buffer objects (VBOs) must always 
445         contain initialized data, even if they were created without initial user 
446         data values.  Creating a resource without initial values is commonly used to 
447         reserve space for a texture or VBO, which is then modified using <code>texSubImage</code> or 
448         <code>bufferSubData</code> calls.  If initial data is not provided to these calls, the WebGL
449         implementation must initialize their contents to 0; depth renderbuffers must be cleared to
450         the default 1.0 clear depth.  This may require creating a zeroed temporary buffer the size
451         of a requested VBO, so that it can be initialized correctly.  All other forms of loading
452         data into a texture or VBO involve either ArrayBuffers or DOM objects such as images, and
453         are therefore already required to be initialized.
454     </p>
455
456     <p>
457         When WebGL resources are accessed by shaders through a call such as
458         <code>drawElements</code> or <code>drawArrays</code>, the WebGL implementation must ensure
459         that the shader cannot access either out of bounds or uninitialized data.
460         See <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes and Range Checking</a>
461         for restrictions which must be enforced by the WebGL implementation.
462     </p>
463
464 <!-- ======================================================================================================= -->
465
466     <h3><a name="ORIGIN_RESTRICTIONS">Origin Restrictions</a></h3>
467
468     <p>
469         In order to prevent information leakage, WebGL disallows uploading as textures:
470         <ul>
471         <li> Image or video elements whose origin is not the same as the origin of the Document that
472              contains the WebGLRenderingContext's canvas element
473         <li> Canvas elements whose <i>origin-clean</i> flag is set to false
474         </ul>
475     </p>
476     <p>
477         If the <code>texImage2D</code> or <code>texSubImage2D</code> method is called with otherwise
478         correct arguments and an <code>HTMLImageElement</code>, <code>HTMLVideoElement</code>,
479         or <code>HTMLCanvasElement</code> violating these restrictions, a <code>SECURITY_ERR</code>
480         exception must be thrown.
481     </p>
482     <div class="note">
483         <p>
484             WebGL necessarily imposes stronger restrictions on the use of cross-domain media than other
485             APIs such as the 2D canvas rendering context, because shaders can be used to indirectly
486             deduce the contents of textures which have been uploaded to the GPU.
487         </p>
488         <p>
489             WebGL applications may utilize images and videos that come from other domains, with the
490             cooperation of the server hosting the media,
491             using <a href="http://www.w3.org/TR/cors/">Cross-Origin Resource
492             Sharing</a> <a href="#refsCORS">[CORS]</a>. In order to use such media, the application
493             needs to explicitly request permission to do so, and the server needs to explicitly grant
494             permission. Successful CORS-enabled fetches of image and video elements from other
495             domains <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/origin-0.html#origin-0">cause
496             the origin of these elements</a> to be set to that of the containing
497             Document <a href="#refsHTML">[HTML]</a>.
498         </p>
499         <div class="example">
500             <p>
501                 The following ECMAScript example demonstrates how to issue a CORS request for an
502                 image coming from another domain. The image is fetched from the server without any
503                 credentials, i.e., cookies.
504             </p>
505 <pre>
506 var gl = ...;
507 var image = new Image();
508
509 // The onload handler should be set to a function which uploads the HTMLImageElement
510 // using texImage2D or texSubImage2D.
511 image.onload = ...;
512
513 image.crossOrigin = "anonymous";
514
515 image.src = "http://other-domain.com/image.jpg";
516 </pre>
517         </div>
518         <p>
519             Note that these rules imply that the <i>origin-clean</i> flag for a canvas rendered
520             using WebGL will never be set to false.
521         </p>
522         <p>
523             For more information on issuing CORS requests for image and video elements, consult:
524             <ul>
525             <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#cors-settings-attribute">CORS settings attributes</a> <a href="#refsHTML">[HTML]</a>
526             <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#the-img-element">The <code>img</code> element</a> <a href="#refsHTML">[HTML]</a>
527             <li> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#media-elements">Media elements</a> <a href="#refsHTML">[HTML]</a>
528             </ul>
529         </p>
530     </div>
531
532 <!-- ======================================================================================================= -->
533
534     <h3><a name="SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</a></h3>
535
536     <p>
537         A WebGL implementation must only accept shaders which conform to The OpenGL ES Shading
538         Language, Version 1.00 <a href="#refsGLES20GLSL">[GLES20GLSL]</a>, and which do not exceed
539         the minimum functionality mandated in Sections 4 and 5 of Appendix A.  In particular:
540
541         <ul>
542         <li> A shader referencing state variables or functions that are available in other versions
543              of GLSL, such as that found in versions of OpenGL for the desktop, must not be allowed
544              to load. </li>
545         <li> <code>for</code> loops must conform to the structural constraints in Appendix A. </li>
546         <li> <code>while</code> and <code>do-while</code> loops are disallowed, since they are
547              optional in Appendix A.</li>
548         <li> Appendix A mandates certain forms of indexing of arrays; for example, within fragment
549              shaders, indexing is only mandated with a <i>constant-index-expression</i>
550              (see <a href="#refsGLES20GLSL">[GLES20GLSL]</a> for the definition of this term). In
551              the WebGL API, only the forms of indexing mandated in Appendix A are supported. </li>
552         </ul>
553     </p>
554     <p>
555         In addition to the reserved identifiers in the aforementioned specification, identifiers
556         starting with "webgl_" and "_webgl_" are reserved for use by WebGL. A shader which declares
557         a function, variable, structure name, or structure field starting with these prefixes must
558         not be allowed to load.
559     </p>
560
561 <!-- ======================================================================================================= -->
562
563     <h3>Defense Against Denial of Service</h3>
564     <div class="note">        
565     <p>
566     It is possible to create, either intentionally or unintentionally, combinations of shaders and
567     geometry that take an undesirably long time to render. This issue is analogous to that of
568     long-running scripts, for which user agents already have safeguards. However, long-running draw
569     calls can cause loss of interactivity for the entire window system, not just the user agent.
570     </p>
571
572     <p>
573     In the general case it is not possible to impose limits on the structure of incoming shaders to
574     guard against this problem. Experimentation has shown that even very strict structural limits
575     are insufficient to prevent long rendering times, and such limits would prevent shader authors
576     from implementing common algorithms.
577     </p>
578
579     <p>
580     User agents should implement safeguards to prevent excessively long rendering times and
581     associated loss of interactivity. Suggested safeguards include:
582     </p>
583
584     <ul>
585
586     <li> Splitting up draw calls with large numbers of elements into smaller draw calls.
587
588     <li> Timing individual draw calls and forbidding further rendering from a page if a certain
589          timeout is exceeded.
590
591     <li> Using any watchdog facilities available at the user level, graphics API level, or operating
592          system level to limit the duration of draw calls.
593
594     <li> Separating the graphics rendering of the user agent into a distinct operating system
595          process which can be terminated and restarted without losing application state.
596
597     </ul>
598
599     <p>
600     The supporting infrastructure at the OS and graphics API layer is expected to improve over time,
601     which is why the exact nature of these safeguards is not specified.
602     </p>
603     </div>
604 <!-- ======================================================================================================= -->
605
606     <h3><a name="OUT_OF_RANGE_ARRAY_ACCESSES">Out-of-Range Array Accesses</a></h3>
607
608     <p>
609         Shaders must not be allowed to read or write array elements that lie outside the bounds of
610         the array. This includes any variable of array type, as well as vector or matrix types such
611         as <code>vec3</code> or <code>mat4</code> when accessed using array subscripting syntax. If
612         detected during compilation, such accesses must generate an error and prevent the shader
613         from compiling. Otherwise, at runtime they shall return zero or the value at any valid index
614         of the same array.
615     </p>
616     <div class="note">
617         <p>
618             See <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</a> for more information
619             on restrictions which simplify static analysis of the array indexing operations in shaders.
620         </p>
621     </div>
622 <!-- ======================================================================================================= -->
623
624     <h2>DOM Interfaces</h2>
625
626     <p>
627         This section describes the interfaces and functionality added to the
628         DOM to support runtime access to the functionality described above.
629     </p>
630
631 <!-- ======================================================================================================= -->
632
633     <h3>Types</h3>
634
635     <p>
636         The following types are used in all interfaces in the following section.
637     </p>
638     <pre class="idl">
639 typedef unsigned long  GLenum;
640 typedef boolean        GLboolean;
641 typedef unsigned long  GLbitfield;
642 typedef byte           GLbyte;         /* 'byte' should be a signed 8 bit type. */
643 typedef short          GLshort;
644 typedef long           GLint;
645 typedef long           GLsizei;
646 typedef long long      GLintptr;
647 typedef long long      GLsizeiptr;
648 // Ideally the typedef below would use 'unsigned byte', but that doesn't currently exist in Web IDL.
649 typedef octet          GLubyte;        /* 'octet' should be an unsigned 8 bit type. */
650 typedef unsigned short GLushort;
651 typedef unsigned long  GLuint;
652 typedef unrestricted float GLfloat;
653 typedef unrestricted float GLclampf;  
654 </pre>
655
656 <!-- ======================================================================================================= -->
657
658     <h3><a name="WEBGLCONTEXTATTRIBUTES">WebGLContextAttributes</a></h3>
659
660     <p>
661         The <code>WebGLContextAttributes</code> dictionary contains drawing surface attributes and
662         is passed as the second parameter to <code>getContext</code>.
663     </p>
664     <pre class="idl">dictionary <dfn id="WebGLContextAttributes">WebGLContextAttributes</dfn> {
665     GLboolean alpha = true;
666     GLboolean depth = true;
667     GLboolean stencil = false;
668     GLboolean antialias = true;
669     GLboolean premultipliedAlpha = true;
670     GLboolean preserveDrawingBuffer = false;
671 };</pre>
672
673     <h4>Context creation parameters</h4>
674
675     <p>
676         The following list describes each attribute in the WebGLContextAttributes object and its
677         use. For each attribute the default value is shown. The default value is used either if no
678         second parameter is passed to <code>getContext</code>, or if a user object is passed which
679         has no attribute of the given name.
680     </p>
681     <dl>
682         <dt><span class=prop-value>alpha</span></dt>
683             <dd>
684                 If the value is true, the drawing buffer has an alpha channel for the purposes of
685                 performing OpenGL destination alpha operations and compositing with the page. If the
686                 value is false, no alpha buffer is available.
687             </dd>
688         <dt> <span class=prop-value>depth</span>
689             <dd>
690                 If the value is true, the drawing buffer has a depth buffer of at least 16 bits. If
691                 the value is false, no depth buffer is available.
692            </dd>
693         <dt> <span class=prop-value>stencil</span>
694             <dd>
695                 If the value is true, the drawing buffer has a stencil buffer of at least 8 bits. If
696                 the value is false, no stencil buffer is available.
697             </dd>
698         <dt> <span class=prop-value>antialias</span>
699             <dd>
700                 If the value is true and the implementation supports antialiasing the drawing buffer
701                 will perform antialiasing using its choice of technique (multisample/supersample)
702                 and quality. If the value is false or the implementation does not support
703                 antialiasing, no antialiasing is performed.
704             </dd>
705         <dt> <span class=prop-value>premultipliedAlpha</span>
706             <dd>
707                 If the value is true the page compositor will assume the drawing buffer contains
708                 colors with premultiplied alpha. If the value is false the page compositor will
709                 assume that colors in the drawing buffer are not premultiplied. This flag is ignored
710                 if the <strong>alpha</strong> flag is
711                 false. See <a href="#PREMULTIPLIED_ALPHA">Premultiplied Alpha</a> for more
712                 information on the effects of the <code>premultipliedAlpha</code> flag.
713             </dd>
714         <dt> <span class=prop-value>preserveDrawingBuffer</span>
715             <dd>
716                 If false, once the drawing buffer is presented as described in
717                 the<a href="#THE_DRAWING_BUFFER">Drawing Buffer</a> section, the contents of the
718                 drawing buffer are cleared to their default values.  All elements of the drawing
719                 buffer (color, depth and stencil) are cleared.  If the value is true the buffers
720                 will not be cleared and will preserve their values until cleared or overwritten by
721                 the author.
722                 <blockquote>
723                 <em>
724                     On some hardware setting the <code>preserveDrawingBuffer</code> flag 
725                     to true can have significant performance implications.
726                 </em>
727                 </blockquote>
728             </dd>
729     </dl>
730     <div class="example">
731     Here is an ECMAScript example which passes a WebGLContextAttributes argument
732     to <code>getContext</code>.  It assumes the presence of a canvas element named "canvas1" on the
733     page.
734
735     <pre>
736 var canvas = document.getElementById('canvas1');
737 var context = canvas.getContext('webgl',
738                                 { antialias: false,
739                                   stencil: true });
740     </pre>
741     </div>
742
743 <!-- ======================================================================================================= -->
744
745     <h3>WebGLObject</h3>
746
747     <p>
748         The <code>WebGLObject</code> interface is the parent interface for all GL objects.
749     </p>
750     <p>
751         Each <code>WebGLObject</code> has
752         an <b><a name="webgl-object-invalidated-flag">invalidated</a></b> flag, which is initially unset.
753     </p>
754     <pre class="idl">interface <dfn id="WebGLObject">WebGLObject</dfn> {
755 };</pre>
756
757 <!-- ======================================================================================================= -->
758
759     <h3>WebGLBuffer</h3>
760
761     <p>
762         The <code>WebGLBuffer</code> interface represents an OpenGL Buffer Object. The
763         underlying object is created as if by calling glGenBuffers 
764         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenBuffers.xml">man page</a>)</span>
765         , bound as if by calling glBindBuffer
766         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindBuffer.xml">man page</a>)</span>
767         and destroyed as if by calling glDeleteBuffers
768         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteBuffers.xml">man page</a>)</span>
769         .
770     </p>
771     <pre class="idl">interface <dfn id="WebGLBuffer">WebGLBuffer</dfn> : WebGLObject {
772 };</pre>
773
774 <!-- ======================================================================================================= -->
775
776     <h3><a name="WEBGL_FRAMEBUFFER">WebGLFramebuffer</a></h3>
777
778     <p>
779         The <code>WebGLFramebuffer</code> interface represents an OpenGL Framebuffer Object. The
780         underlying object is created as if by calling glGenFramebuffers
781         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;4.4.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenFramebuffers.xml">man page</a>)</span>
782         , bound as if by calling glBindFramebuffer
783         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;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>
784         and destroyed as if by calling glDeleteFramebuffers
785         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;4.4.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteFramebuffers.xml">man page</a>)</span>
786         .
787     </p>
788     <pre class="idl">interface <dfn id="WebGLFramebuffer">WebGLFramebuffer</dfn> : WebGLObject {
789 };</pre>
790
791 <!-- ======================================================================================================= -->
792
793     <h3>WebGLProgram</h3>
794
795     <p>
796         The <code>WebGLProgram</code> interface represents an OpenGL Program Object. The
797         underlying object is created as if by calling glCreateProgram
798         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
799         , used as if by calling glUseProgram
800         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
801         and destroyed as if by calling glDeleteProgram
802         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
803         .
804     </p>
805     <pre class="idl">interface <dfn id="WebGLProgram">WebGLProgram</dfn> : WebGLObject {
806 };</pre>
807
808 <!-- ======================================================================================================= -->
809
810     <h3>WebGLRenderbuffer</h3>
811
812     <p>
813         The <code>WebGLRenderbuffer</code> interface represents an OpenGL Renderbuffer Object. The
814         underlying object is created as if by calling glGenRenderbuffers
815         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenRenderbuffers.xml">man page</a>)</span>
816         , bound as if by calling glBindRenderbuffer
817         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;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>
818         and destroyed as if by calling glDeleteRenderbuffers
819         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;4.4.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteRenderbuffers.xml">man page</a>)</span>
820         .
821     </p>
822     <pre class="idl">interface <dfn id="WebGLRenderbuffer">WebGLRenderbuffer</dfn> : WebGLObject {
823 };</pre>
824
825 <!-- ======================================================================================================= -->
826
827     <h3>WebGLShader</h3>
828
829     <p>
830         The <code>WebGLShader</code> interface represents an OpenGL Shader Object. The
831         underlying object is created as if by calling glCreateShader
832         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
833         , attached to a Program as if by calling glAttachShader
834         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
835         and destroyed as if by calling glDeleteShader
836         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
837         .
838     </p>
839     <pre class="idl">interface <dfn id="WebGLShader">WebGLShader</dfn> : WebGLObject {
840 };</pre>
841
842 <!-- ======================================================================================================= -->
843
844     <h3>WebGLTexture</h3>
845
846     <p>
847         The <code>WebGLTexture</code> interface represents an OpenGL Texture Object. The
848         underlying object is created as if by calling glGenTextures
849         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
850         , bound as if by calling glBindTexture
851         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
852         and destroyed as if by calling glDeleteTextures
853         <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
854         .
855     </p>
856     <pre class="idl">interface <dfn id="WebGLTexture">WebGLTexture</dfn> : WebGLObject {
857 };</pre>
858
859 <!-- ======================================================================================================= -->
860
861     <h3>WebGLUniformLocation</h3>
862
863     <p>
864         The <code>WebGLUniformLocation</code> interface represents the location of a uniform variable 
865         in a shader program.
866     </p>
867     <pre class="idl">interface <dfn id="WebGLUniformLocation">WebGLUniformLocation</dfn> {
868 };</pre>
869
870 <!-- ======================================================================================================= -->
871
872     <h3>WebGLActiveInfo</h3>
873
874     <p>
875         The <code>WebGLActiveInfo</code> interface represents the information returned 
876         from the getActiveAttrib and getActiveUniform calls.
877     </p>
878     <pre class="idl">interface <dfn id="WebGLActiveInfo">WebGLActiveInfo</dfn> {
879     readonly attribute GLint size;
880     readonly attribute GLenum type;
881     readonly attribute DOMString name;
882 };</pre>
883
884     <h4>Attributes</h4>
885
886     <p>
887         The following attributes are available:
888     </p>
889
890     <dl class="methods">
891         <dt>
892             <code class=attribute-name>
893                 <a id="DOM-WebGLActiveInfo-size">
894                     size
895                 </a>
896             </code> 
897             of type <code>GLint</code>
898         <dd>
899             The size of the requested variable.
900         <dt>
901             <code class=attribute-name>
902                 <a id="DOM-WebGLActiveInfo-type">
903                     type
904                 </a>
905             </code> 
906             of type <code>GLenum</code>
907         <dd>
908             The data type of the requested variable.
909         <dt>
910             <code class=attribute-name>
911                 <a id="DOM-WebGLActiveInfo-name">
912                     name
913                 </a>
914             </code> 
915             of type <code>DOMString</code>
916         <dd>
917             The name of the requested variable.
918     </dl>
919
920 <!-- ======================================================================================================= -->
921
922     <h3>WebGLShaderPrecisionFormat</h3>
923
924     <p>
925         The <code>WebGLShaderPrecisionFormat</code> interface represents the information returned 
926         from the getShaderPrecisionFormat call.
927     </p>
928     <pre class="idl">interface <dfn id="WebGLShaderPrecisionFormat">WebGLShaderPrecisionFormat</dfn> {
929     readonly attribute GLint rangeMin;
930     readonly attribute GLint rangeMax;
931     readonly attribute GLint precision;
932 };</pre>
933
934     <h4>Attributes</h4>
935
936     <p>
937         The following attributes are available:
938     </p>
939
940     <dl class="methods">
941         <dt>
942             <code class=attribute-name>
943                 <a id="DOM-WebGLShaderPrecisionFormat-rangeMin">
944                     rangeMin
945                 </a>
946             </code> 
947             of type <code>GLint</code>
948         <dd>
949             The base 2 log of the absolute value of the minimum value that can be represented.
950         <dt>
951             <code class=attribute-name>
952                 <a id="DOM-WebGLShaderPrecisionFormat-rangeMax">
953                     rangeMax
954                 </a>
955             </code> 
956             of type <code>GLint</code>
957         <dd>
958             The base 2 log of the absolute value of the maximum value that can be represented.
959         <dt>
960             <code class=attribute-name>
961                 <a id="DOM-WebGLShaderPrecisionFormat-precision">
962                     precision
963                 </a>
964             </code> 
965             of type <code>GLint</code>
966         <dd>
967             The number of bits of precision that can be represented. For integer formats this value
968             is always 0.
969     </dl>
970
971 <!-- ======================================================================================================= -->
972
973     <h3><a name="ARRAYBUFFER">ArrayBuffer</a> and <a name="TYPEDARRAY">Typed Arrays</a></h3>
974
975     <p>
976         Vertex, index, texture, and other data is transferred to the WebGL implementation using
977         the <a href="../../../typedarray/specs/latest/#ARRAYBUFFER">ArrayBuffer</a>
978         and <a href="../../../typedarray/specs/latest/#TYPEDARRAYS">views</a> defined in
979         the <a href="../../../typedarray/specs/latest/">Typed Array</a>
980         specification <a href="#refsTYPEDARRAYS">[TYPEDARRAYS]</a>.
981     </p>
982     <p>
983         Typed Arrays support the creation of interleaved, heterogeneous vertex data; uploading of
984         distinct blocks of data into a large vertex buffer object; and most other use cases required
985         by OpenGL programs.
986     </p>
987
988     <div class="example">
989     Here is an ECMAScript example showing access to the same ArrayBuffer using different types of
990     typed arrays. In this case the buffer contains a floating point vertex position (x, y, z)
991     followed by a color as 4 unsigned bytes (r, g, b, a).
992
993     <pre>
994 var numVertices = 100; // for example
995
996 // Compute the size needed for the buffer, in bytes and floats
997 var vertexSize = 3 * Float32Array.BYTES_PER_ELEMENT +
998      4 * Uint8Array.BYTES_PER_ELEMENT;
999 var vertexSizeInFloats = vertexSize / Float32Array.BYTES_PER_ELEMENT;
1000
1001 // Allocate the buffer
1002 var buf = new ArrayBuffer(numVertices * vertexSize);
1003
1004 // Map this buffer to a Float32Array to access the positions
1005 var positionArray = new Float32Array(buf);
1006
1007 // Map the same buffer to a Uint8Array to access the color
1008 var colorArray = new Uint8Array(buf);
1009
1010 // Set up the initial offset of the vertices and colors within the buffer
1011 var positionIdx = 0;
1012 var colorIdx = 3 * Float32Array.BYTES_PER_ELEMENT;
1013
1014 // Initialize the buffer
1015 for (var i = 0; i < numVertices; i++) {
1016     positionArray[positionIdx] = ...;
1017     positionArray[positionIdx + 1] = ...;
1018     positionArray[positionIdx + 2] = ...;
1019     colorArray[colorIdx] = ...;
1020     colorArray[colorIdx + 1] = ...;
1021     colorArray[colorIdx + 2] = ...;
1022     colorArray[colorIdx + 3] = ...;
1023     positionIdx += vertexSizeInFloats;
1024     colorIdx += vertexSize;
1025 }
1026     </pre>
1027     </div>
1028
1029 <!-- ======================================================================================================= -->
1030
1031     <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
1032
1033     <p>
1034         The <code>WebGLRenderingContext</code> represents the API allowing
1035         OpenGL ES 2.0 style rendering into the canvas element.
1036     </p>
1037     <p>
1038         Before performing the implementation of any method of the <code>WebGLRenderingContext</code>
1039         interface or any method of an interface returned by the <code>getExtension</code> method,
1040         the following steps must be performed:
1041
1042         <ol class="nestedlist">
1043
1044         <li> If the <code>[WebGLHandlesContextLoss]</code> extended attribute appears on the called
1045         method, perform the implementation of the called method, return its result and terminate
1046         these steps. </li>
1047
1048         <li> Let <em>use default return value</em> be false. </li>
1049
1050         <li> If the <a href="#webgl-context-lost-flag">webgl context lost flag</a> is set,
1051         let <em>use default return value</em> be true. </li>
1052
1053         <li> If any argument to the method is a <code>WebGLObject</code> with
1054         its <a href="#webgl-object-invalidated-flag">invalidated flag</a> set, generate
1055         an <code>INVALID_OPERATION</code> error and let <em>use default return value</em> be
1056         true. </li>
1057
1058         <li> If <em>use default return value</em> is true, perform the following steps:
1059
1060             <ol class="nestedlist">
1061
1062             <li> If the return type of the called method is <code>any</code> or any nullable type,
1063             return null. </li>
1064
1065             <li> Terminate this algorithm without calling the method implementation. </li>
1066
1067             </ol>
1068
1069         <li> Otherwise, perform the implementation of the called method and return its result. </li>
1070
1071         </ol>
1072     </p>
1073     <p>
1074     See <a href="#CONTEXT_LOST">the context lost event</a> for further details.
1075     </p>
1076     <pre class="idl">interface <dfn id="WebGLRenderingContext">WebGLRenderingContext</dfn> {
1077
1078     /* ClearBufferMask */
1079     const GLenum DEPTH_BUFFER_BIT               = 0x00000100;
1080     const GLenum STENCIL_BUFFER_BIT             = 0x00000400;
1081     const GLenum COLOR_BUFFER_BIT               = 0x00004000;
1082     
1083     /* BeginMode */
1084     const GLenum POINTS                         = 0x0000;
1085     const GLenum LINES                          = 0x0001;
1086     const GLenum LINE_LOOP                      = 0x0002;
1087     const GLenum LINE_STRIP                     = 0x0003;
1088     const GLenum TRIANGLES                      = 0x0004;
1089     const GLenum TRIANGLE_STRIP                 = 0x0005;
1090     const GLenum TRIANGLE_FAN                   = 0x0006;
1091     
1092     /* AlphaFunction (not supported in ES20) */
1093     /*      NEVER */
1094     /*      LESS */
1095     /*      EQUAL */
1096     /*      LEQUAL */
1097     /*      GREATER */
1098     /*      NOTEQUAL */
1099     /*      GEQUAL */
1100     /*      ALWAYS */
1101     
1102     /* BlendingFactorDest */
1103     const GLenum ZERO                           = 0;
1104     const GLenum ONE                            = 1;
1105     const GLenum SRC_COLOR                      = 0x0300;
1106     const GLenum ONE_MINUS_SRC_COLOR            = 0x0301;
1107     const GLenum SRC_ALPHA                      = 0x0302;
1108     const GLenum ONE_MINUS_SRC_ALPHA            = 0x0303;
1109     const GLenum DST_ALPHA                      = 0x0304;
1110     const GLenum ONE_MINUS_DST_ALPHA            = 0x0305;
1111     
1112     /* BlendingFactorSrc */
1113     /*      ZERO */
1114     /*      ONE */
1115     const GLenum DST_COLOR                      = 0x0306;
1116     const GLenum ONE_MINUS_DST_COLOR            = 0x0307;
1117     const GLenum SRC_ALPHA_SATURATE             = 0x0308;
1118     /*      SRC_ALPHA */
1119     /*      ONE_MINUS_SRC_ALPHA */
1120     /*      DST_ALPHA */
1121     /*      ONE_MINUS_DST_ALPHA */
1122     
1123     /* BlendEquationSeparate */
1124     const GLenum FUNC_ADD                       = 0x8006;
1125     const GLenum BLEND_EQUATION                 = 0x8009;
1126     const GLenum BLEND_EQUATION_RGB             = 0x8009;   /* same as BLEND_EQUATION */
1127     const GLenum BLEND_EQUATION_ALPHA           = 0x883D;
1128     
1129     /* BlendSubtract */
1130     const GLenum FUNC_SUBTRACT                  = 0x800A;
1131     const GLenum FUNC_REVERSE_SUBTRACT          = 0x800B;
1132     
1133     /* Separate Blend Functions */
1134     const GLenum BLEND_DST_RGB                  = 0x80C8;
1135     const GLenum BLEND_SRC_RGB                  = 0x80C9;
1136     const GLenum BLEND_DST_ALPHA                = 0x80CA;
1137     const GLenum BLEND_SRC_ALPHA                = 0x80CB;
1138     const GLenum CONSTANT_COLOR                 = 0x8001;
1139     const GLenum ONE_MINUS_CONSTANT_COLOR       = 0x8002;
1140     const GLenum CONSTANT_ALPHA                 = 0x8003;
1141     const GLenum ONE_MINUS_CONSTANT_ALPHA       = 0x8004;
1142     const GLenum BLEND_COLOR                    = 0x8005;
1143     
1144     /* Buffer Objects */
1145     const GLenum ARRAY_BUFFER                   = 0x8892;
1146     const GLenum ELEMENT_ARRAY_BUFFER           = 0x8893;
1147     const GLenum ARRAY_BUFFER_BINDING           = 0x8894;
1148     const GLenum ELEMENT_ARRAY_BUFFER_BINDING   = 0x8895;
1149     
1150     const GLenum STREAM_DRAW                    = 0x88E0;
1151     const GLenum STATIC_DRAW                    = 0x88E4;
1152     const GLenum DYNAMIC_DRAW                   = 0x88E8;
1153     
1154     const GLenum BUFFER_SIZE                    = 0x8764;
1155     const GLenum BUFFER_USAGE                   = 0x8765;
1156     
1157     const GLenum CURRENT_VERTEX_ATTRIB          = 0x8626;
1158     
1159     /* CullFaceMode */
1160     const GLenum FRONT                          = 0x0404;
1161     const GLenum BACK                           = 0x0405;
1162     const GLenum FRONT_AND_BACK                 = 0x0408;
1163     
1164     /* DepthFunction */
1165     /*      NEVER */
1166     /*      LESS */
1167     /*      EQUAL */
1168     /*      LEQUAL */
1169     /*      GREATER */
1170     /*      NOTEQUAL */
1171     /*      GEQUAL */
1172     /*      ALWAYS */
1173     
1174     /* EnableCap */
1175     /* TEXTURE_2D */
1176     const GLenum CULL_FACE                      = 0x0B44;
1177     const GLenum BLEND                          = 0x0BE2;
1178     const GLenum DITHER                         = 0x0BD0;
1179     const GLenum STENCIL_TEST                   = 0x0B90;
1180     const GLenum DEPTH_TEST                     = 0x0B71;
1181     const GLenum SCISSOR_TEST                   = 0x0C11;
1182     const GLenum POLYGON_OFFSET_FILL            = 0x8037;
1183     const GLenum SAMPLE_ALPHA_TO_COVERAGE       = 0x809E;
1184     const GLenum SAMPLE_COVERAGE                = 0x80A0;
1185     
1186     /* ErrorCode */
1187     const GLenum NO_ERROR                       = 0;
1188     const GLenum INVALID_ENUM                   = 0x0500;
1189     const GLenum INVALID_VALUE                  = 0x0501;
1190     const GLenum INVALID_OPERATION              = 0x0502;
1191     const GLenum OUT_OF_MEMORY                  = 0x0505;
1192     
1193     /* FrontFaceDirection */
1194     const GLenum CW                             = 0x0900;
1195     const GLenum CCW                            = 0x0901;
1196     
1197     /* GetPName */
1198     const GLenum LINE_WIDTH                     = 0x0B21;
1199     const GLenum ALIASED_POINT_SIZE_RANGE       = 0x846D;
1200     const GLenum ALIASED_LINE_WIDTH_RANGE       = 0x846E;
1201     const GLenum CULL_FACE_MODE                 = 0x0B45;
1202     const GLenum FRONT_FACE                     = 0x0B46;
1203     const GLenum DEPTH_RANGE                    = 0x0B70;
1204     const GLenum DEPTH_WRITEMASK                = 0x0B72;
1205     const GLenum DEPTH_CLEAR_VALUE              = 0x0B73;
1206     const GLenum DEPTH_FUNC                     = 0x0B74;
1207     const GLenum STENCIL_CLEAR_VALUE            = 0x0B91;
1208     const GLenum STENCIL_FUNC                   = 0x0B92;
1209     const GLenum STENCIL_FAIL                   = 0x0B94;
1210     const GLenum STENCIL_PASS_DEPTH_FAIL        = 0x0B95;
1211     const GLenum STENCIL_PASS_DEPTH_PASS        = 0x0B96;
1212     const GLenum STENCIL_REF                    = 0x0B97;
1213     const GLenum STENCIL_VALUE_MASK             = 0x0B93;
1214     const GLenum STENCIL_WRITEMASK              = 0x0B98;
1215     const GLenum STENCIL_BACK_FUNC              = 0x8800;
1216     const GLenum STENCIL_BACK_FAIL              = 0x8801;
1217     const GLenum STENCIL_BACK_PASS_DEPTH_FAIL   = 0x8802;
1218     const GLenum STENCIL_BACK_PASS_DEPTH_PASS   = 0x8803;
1219     const GLenum STENCIL_BACK_REF               = 0x8CA3;
1220     const GLenum STENCIL_BACK_VALUE_MASK        = 0x8CA4;
1221     const GLenum STENCIL_BACK_WRITEMASK         = 0x8CA5;
1222     const GLenum VIEWPORT                       = 0x0BA2;
1223     const GLenum SCISSOR_BOX                    = 0x0C10;
1224     /*      SCISSOR_TEST */
1225     const GLenum COLOR_CLEAR_VALUE              = 0x0C22;
1226     const GLenum COLOR_WRITEMASK                = 0x0C23;
1227     const GLenum UNPACK_ALIGNMENT               = 0x0CF5;
1228     const GLenum PACK_ALIGNMENT                 = 0x0D05;
1229     const GLenum MAX_TEXTURE_SIZE               = 0x0D33;
1230     const GLenum MAX_VIEWPORT_DIMS              = 0x0D3A;
1231     const GLenum SUBPIXEL_BITS                  = 0x0D50;
1232     const GLenum RED_BITS                       = 0x0D52;
1233     const GLenum GREEN_BITS                     = 0x0D53;
1234     const GLenum BLUE_BITS                      = 0x0D54;
1235     const GLenum ALPHA_BITS                     = 0x0D55;
1236     const GLenum DEPTH_BITS                     = 0x0D56;
1237     const GLenum STENCIL_BITS                   = 0x0D57;
1238     const GLenum POLYGON_OFFSET_UNITS           = 0x2A00;
1239     /*      POLYGON_OFFSET_FILL */
1240     const GLenum POLYGON_OFFSET_FACTOR          = 0x8038;
1241     const GLenum TEXTURE_BINDING_2D             = 0x8069;
1242     const GLenum SAMPLE_BUFFERS                 = 0x80A8;
1243     const GLenum SAMPLES                        = 0x80A9;
1244     const GLenum SAMPLE_COVERAGE_VALUE          = 0x80AA;
1245     const GLenum SAMPLE_COVERAGE_INVERT         = 0x80AB;
1246     
1247     /* GetTextureParameter */
1248     /*      TEXTURE_MAG_FILTER */
1249     /*      TEXTURE_MIN_FILTER */
1250     /*      TEXTURE_WRAP_S */
1251     /*      TEXTURE_WRAP_T */
1252     
1253     const GLenum COMPRESSED_TEXTURE_FORMATS     = 0x86A3;
1254     
1255     /* HintMode */
1256     const GLenum DONT_CARE                      = 0x1100;
1257     const GLenum FASTEST                        = 0x1101;
1258     const GLenum NICEST                         = 0x1102;
1259     
1260     /* HintTarget */
1261     const GLenum GENERATE_MIPMAP_HINT            = 0x8192;
1262     
1263     /* DataType */
1264     const GLenum BYTE                           = 0x1400;
1265     const GLenum UNSIGNED_BYTE                  = 0x1401;
1266     const GLenum SHORT                          = 0x1402;
1267     const GLenum UNSIGNED_SHORT                 = 0x1403;
1268     const GLenum INT                            = 0x1404;
1269     const GLenum UNSIGNED_INT                   = 0x1405;
1270     const GLenum FLOAT                          = 0x1406;
1271     
1272     /* PixelFormat */
1273     const GLenum DEPTH_COMPONENT                = 0x1902;
1274     const GLenum ALPHA                          = 0x1906;
1275     const GLenum RGB                            = 0x1907;
1276     const GLenum RGBA                           = 0x1908;
1277     const GLenum LUMINANCE                      = 0x1909;
1278     const GLenum LUMINANCE_ALPHA                = 0x190A;
1279     
1280     /* PixelType */
1281     /*      UNSIGNED_BYTE */
1282     const GLenum UNSIGNED_SHORT_4_4_4_4         = 0x8033;
1283     const GLenum UNSIGNED_SHORT_5_5_5_1         = 0x8034;
1284     const GLenum UNSIGNED_SHORT_5_6_5           = 0x8363;
1285     
1286     /* Shaders */
1287     const GLenum FRAGMENT_SHADER                  = 0x8B30;
1288     const GLenum VERTEX_SHADER                    = 0x8B31;
1289     const GLenum MAX_VERTEX_ATTRIBS               = 0x8869;
1290     const GLenum MAX_VERTEX_UNIFORM_VECTORS       = 0x8DFB;
1291     const GLenum MAX_VARYING_VECTORS              = 0x8DFC;
1292     const GLenum MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
1293     const GLenum MAX_VERTEX_TEXTURE_IMAGE_UNITS   = 0x8B4C;
1294     const GLenum MAX_TEXTURE_IMAGE_UNITS          = 0x8872;
1295     const GLenum MAX_FRAGMENT_UNIFORM_VECTORS     = 0x8DFD;
1296     const GLenum SHADER_TYPE                      = 0x8B4F;
1297     const GLenum DELETE_STATUS                    = 0x8B80;
1298     const GLenum LINK_STATUS                      = 0x8B82;
1299     const GLenum VALIDATE_STATUS                  = 0x8B83;
1300     const GLenum ATTACHED_SHADERS                 = 0x8B85;
1301     const GLenum ACTIVE_UNIFORMS                  = 0x8B86;
1302     const GLenum ACTIVE_ATTRIBUTES                = 0x8B89;
1303     const GLenum SHADING_LANGUAGE_VERSION         = 0x8B8C;
1304     const GLenum CURRENT_PROGRAM                  = 0x8B8D;
1305     
1306     /* StencilFunction */
1307     const GLenum NEVER                          = 0x0200;
1308     const GLenum LESS                           = 0x0201;
1309     const GLenum EQUAL                          = 0x0202;
1310     const GLenum LEQUAL                         = 0x0203;
1311     const GLenum GREATER                        = 0x0204;
1312     const GLenum NOTEQUAL                       = 0x0205;
1313     const GLenum GEQUAL                         = 0x0206;
1314     const GLenum ALWAYS                         = 0x0207;
1315     
1316     /* StencilOp */
1317     /*      ZERO */
1318     const GLenum KEEP                           = 0x1E00;
1319     const GLenum REPLACE                        = 0x1E01;
1320     const GLenum INCR                           = 0x1E02;
1321     const GLenum DECR                           = 0x1E03;
1322     const GLenum INVERT                         = 0x150A;
1323     const GLenum INCR_WRAP                      = 0x8507;
1324     const GLenum DECR_WRAP                      = 0x8508;
1325     
1326     /* StringName */
1327     const GLenum VENDOR                         = 0x1F00;
1328     const GLenum RENDERER                       = 0x1F01;
1329     const GLenum VERSION                        = 0x1F02;
1330     
1331     /* TextureMagFilter */
1332     const GLenum NEAREST                        = 0x2600;
1333     const GLenum LINEAR                         = 0x2601;
1334     
1335     /* TextureMinFilter */
1336     /*      NEAREST */
1337     /*      LINEAR */
1338     const GLenum NEAREST_MIPMAP_NEAREST         = 0x2700;
1339     const GLenum LINEAR_MIPMAP_NEAREST          = 0x2701;
1340     const GLenum NEAREST_MIPMAP_LINEAR          = 0x2702;
1341     const GLenum LINEAR_MIPMAP_LINEAR           = 0x2703;
1342     
1343     /* TextureParameterName */
1344     const GLenum TEXTURE_MAG_FILTER             = 0x2800;
1345     const GLenum TEXTURE_MIN_FILTER             = 0x2801;
1346     const GLenum TEXTURE_WRAP_S                 = 0x2802;
1347     const GLenum TEXTURE_WRAP_T                 = 0x2803;
1348     
1349     /* TextureTarget */
1350     const GLenum TEXTURE_2D                     = 0x0DE1;
1351     const GLenum TEXTURE                        = 0x1702;
1352     
1353     const GLenum TEXTURE_CUBE_MAP               = 0x8513;
1354     const GLenum TEXTURE_BINDING_CUBE_MAP       = 0x8514;
1355     const GLenum TEXTURE_CUBE_MAP_POSITIVE_X    = 0x8515;
1356     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_X    = 0x8516;
1357     const GLenum TEXTURE_CUBE_MAP_POSITIVE_Y    = 0x8517;
1358     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Y    = 0x8518;
1359     const GLenum TEXTURE_CUBE_MAP_POSITIVE_Z    = 0x8519;
1360     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Z    = 0x851A;
1361     const GLenum MAX_CUBE_MAP_TEXTURE_SIZE      = 0x851C;
1362     
1363     /* TextureUnit */
1364     const GLenum TEXTURE0                       = 0x84C0;
1365     const GLenum TEXTURE1                       = 0x84C1;
1366     const GLenum TEXTURE2                       = 0x84C2;
1367     const GLenum TEXTURE3                       = 0x84C3;
1368     const GLenum TEXTURE4                       = 0x84C4;
1369     const GLenum TEXTURE5                       = 0x84C5;
1370     const GLenum TEXTURE6                       = 0x84C6;
1371     const GLenum TEXTURE7                       = 0x84C7;
1372     const GLenum TEXTURE8                       = 0x84C8;
1373     const GLenum TEXTURE9                       = 0x84C9;
1374     const GLenum TEXTURE10                      = 0x84CA;
1375     const GLenum TEXTURE11                      = 0x84CB;
1376     const GLenum TEXTURE12                      = 0x84CC;
1377     const GLenum TEXTURE13                      = 0x84CD;
1378     const GLenum TEXTURE14                      = 0x84CE;
1379     const GLenum TEXTURE15                      = 0x84CF;
1380     const GLenum TEXTURE16                      = 0x84D0;
1381     const GLenum TEXTURE17                      = 0x84D1;
1382     const GLenum TEXTURE18                      = 0x84D2;
1383     const GLenum TEXTURE19                      = 0x84D3;
1384     const GLenum TEXTURE20                      = 0x84D4;
1385     const GLenum TEXTURE21                      = 0x84D5;
1386     const GLenum TEXTURE22                      = 0x84D6;
1387     const GLenum TEXTURE23                      = 0x84D7;
1388     const GLenum TEXTURE24                      = 0x84D8;
1389     const GLenum TEXTURE25                      = 0x84D9;
1390     const GLenum TEXTURE26                      = 0x84DA;
1391     const GLenum TEXTURE27                      = 0x84DB;
1392     const GLenum TEXTURE28                      = 0x84DC;
1393     const GLenum TEXTURE29                      = 0x84DD;
1394     const GLenum TEXTURE30                      = 0x84DE;
1395     const GLenum TEXTURE31                      = 0x84DF;
1396     const GLenum ACTIVE_TEXTURE                 = 0x84E0;
1397     
1398     /* TextureWrapMode */
1399     const GLenum REPEAT                         = 0x2901;
1400     const GLenum CLAMP_TO_EDGE                  = 0x812F;
1401     const GLenum MIRRORED_REPEAT                = 0x8370;
1402     
1403     /* Uniform Types */
1404     const GLenum FLOAT_VEC2                     = 0x8B50;
1405     const GLenum FLOAT_VEC3                     = 0x8B51;
1406     const GLenum FLOAT_VEC4                     = 0x8B52;
1407     const GLenum INT_VEC2                       = 0x8B53;
1408     const GLenum INT_VEC3                       = 0x8B54;
1409     const GLenum INT_VEC4                       = 0x8B55;
1410     const GLenum BOOL                           = 0x8B56;
1411     const GLenum BOOL_VEC2                      = 0x8B57;
1412     const GLenum BOOL_VEC3                      = 0x8B58;
1413     const GLenum BOOL_VEC4                      = 0x8B59;
1414     const GLenum FLOAT_MAT2                     = 0x8B5A;
1415     const GLenum FLOAT_MAT3                     = 0x8B5B;
1416     const GLenum FLOAT_MAT4                     = 0x8B5C;
1417     const GLenum SAMPLER_2D                     = 0x8B5E;
1418     const GLenum SAMPLER_CUBE                   = 0x8B60;
1419     
1420     /* Vertex Arrays */
1421     const GLenum VERTEX_ATTRIB_ARRAY_ENABLED        = 0x8622;
1422     const GLenum VERTEX_ATTRIB_ARRAY_SIZE           = 0x8623;
1423     const GLenum VERTEX_ATTRIB_ARRAY_STRIDE         = 0x8624;
1424     const GLenum VERTEX_ATTRIB_ARRAY_TYPE           = 0x8625;
1425     const GLenum VERTEX_ATTRIB_ARRAY_NORMALIZED     = 0x886A;
1426     const GLenum VERTEX_ATTRIB_ARRAY_POINTER        = 0x8645;
1427     const GLenum VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
1428     
1429     /* Shader Source */
1430     const GLenum COMPILE_STATUS                 = 0x8B81;
1431     
1432     /* Shader Precision-Specified Types */
1433     const GLenum LOW_FLOAT                      = 0x8DF0;
1434     const GLenum MEDIUM_FLOAT                   = 0x8DF1;
1435     const GLenum HIGH_FLOAT                     = 0x8DF2;
1436     const GLenum LOW_INT                        = 0x8DF3;
1437     const GLenum MEDIUM_INT                     = 0x8DF4;
1438     const GLenum HIGH_INT                       = 0x8DF5;
1439     
1440     /* Framebuffer Object. */
1441     const GLenum FRAMEBUFFER                    = 0x8D40;
1442     const GLenum RENDERBUFFER                   = 0x8D41;
1443     
1444     const GLenum RGBA4                          = 0x8056;
1445     const GLenum RGB5_A1                        = 0x8057;
1446     const GLenum RGB565                         = 0x8D62;
1447     const GLenum DEPTH_COMPONENT16              = 0x81A5;
1448     const GLenum STENCIL_INDEX                  = 0x1901;
1449     const GLenum STENCIL_INDEX8                 = 0x8D48;
1450     const GLenum DEPTH_STENCIL                  = 0x84F9;
1451     
1452     const GLenum RENDERBUFFER_WIDTH             = 0x8D42;
1453     const GLenum RENDERBUFFER_HEIGHT            = 0x8D43;
1454     const GLenum RENDERBUFFER_INTERNAL_FORMAT   = 0x8D44;
1455     const GLenum RENDERBUFFER_RED_SIZE          = 0x8D50;
1456     const GLenum RENDERBUFFER_GREEN_SIZE        = 0x8D51;
1457     const GLenum RENDERBUFFER_BLUE_SIZE         = 0x8D52;
1458     const GLenum RENDERBUFFER_ALPHA_SIZE        = 0x8D53;
1459     const GLenum RENDERBUFFER_DEPTH_SIZE        = 0x8D54;
1460     const GLenum RENDERBUFFER_STENCIL_SIZE      = 0x8D55;
1461     
1462     const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           = 0x8CD0;
1463     const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           = 0x8CD1;
1464     const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         = 0x8CD2;
1465     const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
1466     
1467     const GLenum COLOR_ATTACHMENT0              = 0x8CE0;
1468     const GLenum DEPTH_ATTACHMENT               = 0x8D00;
1469     const GLenum STENCIL_ATTACHMENT             = 0x8D20;
1470     const GLenum DEPTH_STENCIL_ATTACHMENT       = 0x821A;
1471     
1472     const GLenum NONE                           = 0;
1473     
1474     const GLenum FRAMEBUFFER_COMPLETE                      = 0x8CD5;
1475     const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = 0x8CD6;
1476     const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
1477     const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = 0x8CD9;
1478     const GLenum FRAMEBUFFER_UNSUPPORTED                   = 0x8CDD;
1479     
1480     const GLenum FRAMEBUFFER_BINDING            = 0x8CA6;
1481     const GLenum RENDERBUFFER_BINDING           = 0x8CA7;
1482     const GLenum MAX_RENDERBUFFER_SIZE          = 0x84E8;
1483     
1484     const GLenum INVALID_FRAMEBUFFER_OPERATION  = 0x0506;
1485     
1486     /* WebGL-specific enums */
1487     const GLenum UNPACK_FLIP_Y_WEBGL            = 0x9240;
1488     const GLenum UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
1489     const GLenum CONTEXT_LOST_WEBGL             = 0x9242;
1490     const GLenum UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
1491     const GLenum BROWSER_DEFAULT_WEBGL          = 0x9244;
1492
1493     readonly attribute HTMLCanvasElement canvas;
1494     readonly attribute GLsizei drawingBufferWidth;
1495     readonly attribute GLsizei drawingBufferHeight;
1496
1497     [WebGLHandlesContextLoss] WebGLContextAttributes? getContextAttributes();
1498     [WebGLHandlesContextLoss] boolean isContextLost();
1499     
1500     sequence&lt;DOMString&gt;? getSupportedExtensions();
1501     object? getExtension(DOMString name);
1502
1503     void activeTexture(GLenum texture);
1504     void attachShader(WebGLProgram? program, WebGLShader? shader);
1505     void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name);
1506     void bindBuffer(GLenum target, WebGLBuffer? buffer);
1507     void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer);
1508     void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer);
1509     void bindTexture(GLenum target, WebGLTexture? texture);
1510     void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
1511     void blendEquation(GLenum mode);
1512     void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
1513     void blendFunc(GLenum sfactor, GLenum dfactor);
1514     void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, 
1515                            GLenum srcAlpha, GLenum dstAlpha);
1516
1517     void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
1518     void bufferData(GLenum target, ArrayBufferView data, GLenum usage);
1519     void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
1520     void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data);
1521     void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer? data);
1522
1523     [WebGLHandlesContextLoss] GLenum checkFramebufferStatus(GLenum target);
1524     void clear(GLbitfield mask);
1525     void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
1526     void clearDepth(GLclampf depth);
1527     void clearStencil(GLint s);
1528     void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
1529     void compileShader(WebGLShader? shader);
1530
1531     void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
1532                               GLsizei width, GLsizei height, GLint border,
1533                               ArrayBufferView data);
1534     void compressedTexSubImage2D(GLenum target, GLint level,
1535                                  GLint xoffset, GLint yoffset,
1536                                  GLsizei width, GLsizei height, GLenum format,
1537                                  ArrayBufferView data);
1538
1539     void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, 
1540                         GLint x, GLint y, GLsizei width, GLsizei height, 
1541                         GLint border);
1542     void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1543                            GLint x, GLint y, GLsizei width, GLsizei height);
1544
1545     WebGLBuffer? createBuffer();
1546     WebGLFramebuffer? createFramebuffer();
1547     WebGLProgram? createProgram();
1548     WebGLRenderbuffer? createRenderbuffer();
1549     WebGLShader? createShader(GLenum type);
1550     WebGLTexture? createTexture();
1551
1552     void cullFace(GLenum mode);
1553
1554     void deleteBuffer(WebGLBuffer? buffer);
1555     void deleteFramebuffer(WebGLFramebuffer? framebuffer);
1556     void deleteProgram(WebGLProgram? program);
1557     void deleteRenderbuffer(WebGLRenderbuffer? renderbuffer);
1558     void deleteShader(WebGLShader? shader);
1559     void deleteTexture(WebGLTexture? texture);
1560
1561     void depthFunc(GLenum func);
1562     void depthMask(GLboolean flag);
1563     void depthRange(GLclampf zNear, GLclampf zFar);
1564     void detachShader(WebGLProgram? program, WebGLShader? shader);
1565     void disable(GLenum cap);
1566     void disableVertexAttribArray(GLuint index);
1567     void drawArrays(GLenum mode, GLint first, GLsizei count);
1568     void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset);
1569
1570     void enable(GLenum cap);
1571     void enableVertexAttribArray(GLuint index);
1572     void finish();
1573     void flush();
1574     void framebufferRenderbuffer(GLenum target, GLenum attachment, 
1575                                  GLenum renderbuffertarget, 
1576                                  WebGLRenderbuffer? renderbuffer);
1577     void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, 
1578                               WebGLTexture? texture, GLint level);
1579     void frontFace(GLenum mode);
1580
1581     void generateMipmap(GLenum target);
1582
1583     WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index);
1584     WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index);
1585     sequence&lt;WebGLShader&gt;? getAttachedShaders(WebGLProgram? program);
1586
1587     [WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram? program, DOMString name);
1588
1589     any getBufferParameter(GLenum target, GLenum pname);
1590     any getParameter(GLenum pname);
1591
1592     [WebGLHandlesContextLoss] GLenum getError();
1593
1594     any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, 
1595                                           GLenum pname);
1596     any getProgramParameter(WebGLProgram? program, GLenum pname);
1597     DOMString? getProgramInfoLog(WebGLProgram? program);
1598     any getRenderbufferParameter(GLenum target, GLenum pname);
1599     any getShaderParameter(WebGLShader? shader, GLenum pname);
1600     WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
1601     DOMString? getShaderInfoLog(WebGLShader? shader);
1602
1603     DOMString? getShaderSource(WebGLShader? shader);
1604
1605     any getTexParameter(GLenum target, GLenum pname);
1606
1607     any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
1608
1609     WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name);
1610
1611     any getVertexAttrib(GLuint index, GLenum pname);
1612
1613     [WebGLHandlesContextLoss] GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname);
1614
1615     void hint(GLenum target, GLenum mode);
1616     [WebGLHandlesContextLoss] GLboolean isBuffer(WebGLBuffer? buffer);
1617     [WebGLHandlesContextLoss] GLboolean isEnabled(GLenum cap);
1618     [WebGLHandlesContextLoss] GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
1619     [WebGLHandlesContextLoss] GLboolean isProgram(WebGLProgram? program);
1620     [WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
1621     [WebGLHandlesContextLoss] GLboolean isShader(WebGLShader? shader);
1622     [WebGLHandlesContextLoss] GLboolean isTexture(WebGLTexture? texture);
1623     void lineWidth(GLfloat width);
1624     void linkProgram(WebGLProgram? program);
1625     void pixelStorei(GLenum pname, GLint param);
1626     void polygonOffset(GLfloat factor, GLfloat units);
1627
1628     void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, 
1629                     GLenum format, GLenum type, ArrayBufferView? pixels);
1630
1631     void renderbufferStorage(GLenum target, GLenum internalformat, 
1632                              GLsizei width, GLsizei height);
1633     void sampleCoverage(GLclampf value, GLboolean invert);
1634     void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
1635
1636     void shaderSource(WebGLShader? shader, DOMString source);
1637
1638     void stencilFunc(GLenum func, GLint ref, GLuint mask);
1639     void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
1640     void stencilMask(GLuint mask);
1641     void stencilMaskSeparate(GLenum face, GLuint mask);
1642     void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
1643     void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
1644
1645     void texImage2D(GLenum target, GLint level, GLenum internalformat, 
1646                     GLsizei width, GLsizei height, GLint border, GLenum format, 
1647                     GLenum type, ArrayBufferView? pixels);
1648     void texImage2D(GLenum target, GLint level, GLenum internalformat,
1649                     GLenum format, GLenum type, ImageData? pixels);
1650     void texImage2D(GLenum target, GLint level, GLenum internalformat,
1651                     GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
1652     void texImage2D(GLenum target, GLint level, GLenum internalformat,
1653                     GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
1654     void texImage2D(GLenum target, GLint level, GLenum internalformat,
1655                     GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
1656
1657     void texParameterf(GLenum target, GLenum pname, GLfloat param);
1658     void texParameteri(GLenum target, GLenum pname, GLint param);
1659
1660     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1661                        GLsizei width, GLsizei height, 
1662                        GLenum format, GLenum type, ArrayBufferView? pixels);
1663     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1664                        GLenum format, GLenum type, ImageData? pixels);
1665     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1666                        GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
1667     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1668                        GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
1669     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
1670                        GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
1671
1672     void uniform1f(WebGLUniformLocation? location, GLfloat x);
1673     void uniform1fv(WebGLUniformLocation? location, Float32Array v);
1674     void uniform1fv(WebGLUniformLocation? location, sequence&lt;GLfloat&gt; v);
1675     void uniform1i(WebGLUniformLocation? location, GLint x);
1676     void uniform1iv(WebGLUniformLocation? location, Int32Array v);
1677     void uniform1iv(WebGLUniformLocation? location, sequence&lt;long&gt; v);
1678     void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
1679     void uniform2fv(WebGLUniformLocation? location, Float32Array v);
1680     void uniform2fv(WebGLUniformLocation? location, sequence&lt;GLfloat&gt; v);
1681     void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
1682     void uniform2iv(WebGLUniformLocation? location, Int32Array v);
1683     void uniform2iv(WebGLUniformLocation? location, sequence&lt;long&gt; v);
1684     void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
1685     void uniform3fv(WebGLUniformLocation? location, Float32Array v);
1686     void uniform3fv(WebGLUniformLocation? location, sequence&lt;GLfloat&gt; v);
1687     void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
1688     void uniform3iv(WebGLUniformLocation? location, Int32Array v);
1689     void uniform3iv(WebGLUniformLocation? location, sequence&lt;long&gt; v);
1690     void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1691     void uniform4fv(WebGLUniformLocation? location, Float32Array v);
1692     void uniform4fv(WebGLUniformLocation? location, sequence&lt;GLfloat&gt; v);
1693     void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
1694     void uniform4iv(WebGLUniformLocation? location, Int32Array v);
1695     void uniform4iv(WebGLUniformLocation? location, sequence&lt;long&gt; v);
1696
1697     void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, 
1698                           Float32Array value);
1699     void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, 
1700                           sequence&lt;GLfloat&gt; value);
1701     void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, 
1702                           Float32Array value);
1703     void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, 
1704                           sequence&lt;GLfloat&gt; value);
1705     void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, 
1706                           Float32Array value);
1707     void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, 
1708                           sequence&lt;GLfloat&gt; value);
1709
1710     void useProgram(WebGLProgram? program);
1711     void validateProgram(WebGLProgram? program);
1712
1713     void vertexAttrib1f(GLuint indx, GLfloat x);
1714     void vertexAttrib1fv(GLuint indx, Float32Array values);
1715     void vertexAttrib1fv(GLuint indx, sequence&lt;GLfloat&gt; values);
1716     void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
1717     void vertexAttrib2fv(GLuint indx, Float32Array values);
1718     void vertexAttrib2fv(GLuint indx, sequence&lt;GLfloat&gt; values);
1719     void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
1720     void vertexAttrib3fv(GLuint indx, Float32Array values);
1721     void vertexAttrib3fv(GLuint indx, sequence&lt;GLfloat&gt; values);
1722     void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1723     void vertexAttrib4fv(GLuint indx, Float32Array values);
1724     void vertexAttrib4fv(GLuint indx, sequence&lt;GLfloat&gt; values);
1725     void vertexAttribPointer(GLuint indx, GLint size, GLenum type, 
1726                              GLboolean normalized, GLsizei stride, GLintptr offset);
1727
1728     void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
1729 };</pre>
1730
1731 <!-- ======================================================================================================= -->
1732
1733     <h4>Attributes</h4>
1734
1735     <p>
1736         The following attributes are available:
1737     </p>
1738
1739     <dl class="methods">
1740         <dt>
1741             <code class=attribute-name>
1742                 <a id="DOM-WebGLRenderingContext-canvas">
1743                     canvas
1744                 </a>
1745             </code> 
1746             of type <code>HTMLCanvasElement</code>
1747         <dd>
1748             A reference to the canvas element which created this context.
1749
1750         <dt>
1751             <code class=attribute-name>
1752                 <a id="DOM-WebGLRenderingContext-drawingBufferWidth">
1753                     drawingBufferWidth
1754                 </a>
1755             </code> 
1756             of type <code>GLsizei</code>
1757         <dd>
1758             The actual width of the drawing buffer. May be different from the 
1759             <code>width</code> attribute of the <code>HTMLCanvasElement</code> if 
1760             the implementation is unable to satisfy the requested widthor height.
1761             
1762         <dt>
1763             <code class=attribute-name>
1764                 <a id="DOM-WebGLRenderingContext-drawingBufferHeight">
1765                     drawingBufferHeight
1766                 </a>
1767             </code> 
1768             of type <code>GLsizei</code>
1769         <dd>
1770             The actual height of the drawing buffer. May be different from the 
1771             <code>height</code> attribute of the <code>HTMLCanvasElement</code> if 
1772             the implementation is unable to satisfy the requested width or height.
1773     </dl>
1774
1775 <!-- ======================================================================================================= -->
1776
1777     <h4>Getting information about the context</h4>
1778
1779     <dl class="methods">
1780         <dt class="idl-code">[WebGLHandlesContextLoss] WebGLContextAttributes? getContextAttributes()
1781         <dd>
1782             If the <a href="#webgl-context-lost-flag">webgl context lost flag</a> is set, returns
1783             null. Otherwise, returns a copy of the <a href="#actual-context-parameters">actual
1784             context parameters</a>.
1785     </dl>
1786      
1787 <!-- ======================================================================================================= -->
1788
1789     <h4>Setting and getting state</h4>
1790
1791     <p>
1792         OpenGL ES 2.0 maintains state values for use in rendering. All the calls in this
1793         group behave identically to their OpenGL counterparts unless otherwise noted.
1794     </p>
1795     
1796     <dl class="methods">
1797         <dt class="idl-code">void activeTexture(GLenum texture)
1798             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7">OpenGL ES 2.0 &sect;3.7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glActiveTexture.xml">man page</a>)</span>
1799         <dt class="idl-code">void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1800             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 &sect;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>
1801         <dt class="idl-code">void blendEquation(GLenum mode)
1802             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 &sect;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>
1803         <dt class="idl-code">void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
1804             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 &sect;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>
1805         <dt class="idl-code">void blendFunc(GLenum sfactor, GLenum dfactor)
1806             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 &sect;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>
1807             <dd>
1808                 See <a href="#CONSTANT_COLOR_BLEND">Blending With Constant Color</a> for limitations imposed
1809                 by WebGL.
1810         <dt class="idl-code">void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
1811             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.6">OpenGL ES 2.0 &sect;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>
1812             <dd>
1813                 See <a href="#CONSTANT_COLOR_BLEND">Blending With Constant Color</a> for limitations imposed
1814                 by WebGL.
1815         <dt class="idl-code">void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1816             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 &sect;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>
1817         <dt class="idl-code">void clearDepth(GLclampf depth)
1818             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 &sect;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>
1819             <dd>
1820                 <code>depth</code> value is clamped to the range 0 to 1.
1821         <dt class="idl-code">void clearStencil(GLint s)
1822             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 &sect;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>
1823         <dt class="idl-code">void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
1824             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 &sect;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>
1825         <dt class="idl-code">void cullFace(GLenum mode)
1826             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.5.1">OpenGL ES 2.0 &sect;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>
1827         <dt class="idl-code">void depthFunc(GLenum func)
1828             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.5">OpenGL ES 2.0 &sect;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>
1829         <dt class="idl-code">void depthMask(GLboolean flag)
1830             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 &sect;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>
1831         <dt class="idl-code">void depthRange(GLclampf zNear, GLclampf zFar)
1832             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.12.1">OpenGL ES 2.0 &sect;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>
1833             <dd>
1834                 <code>zNear</code> and <code>zFar</code> values are clamped to the range 0 to 1 and
1835                 <code>zNear</code> must be less than or equal to <code>zFar</code>; see
1836                 <a href="#VIEWPORT_DEPTH_RANGE">Viewport Depth Range</a>.
1837         <dt class="idl-code">void disable(GLenum cap)
1838             <span class="gl-spec">(<a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDisable.xml">man page</a>)</span>
1839         <dt class="idl-code">void enable(GLenum cap)
1840             <span class="gl-spec">(<a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glEnable.xml">man page</a>)</span>
1841         <dt class="idl-code">void frontFace(GLenum mode)
1842             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.5.1">OpenGL ES 2.0 &sect;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>
1843         <dt class="idl-code"><a name="GETPARAMETER">any getParameter</a>(GLenum pname)
1844             <a class="gl-spec" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGet.xml">
1845                 (glGet OpenGL ES 2.0 man page)
1846             </a>
1847             <a class="gl-spec" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetString.xml">
1848                 (glGetString OpenGL ES 2.0 man page)
1849             </a>
1850         <dd>
1851             Return the value for the passed pname. The type returned is the natural type for the
1852             requested pname, as given in the following table:
1853             <table class="foo">
1854                 <tr><th>pname</th><th>returned type</th></tr>
1855                 <tr><td>ACTIVE_TEXTURE</td><td>GLenum</td></tr>
1856                 <tr><td>ALIASED_LINE_WIDTH_RANGE</td><td>Float32Array (with 2 elements)</td></tr>
1857                 <tr><td>ALIASED_POINT_SIZE_RANGE</td><td>Float32Array (with 2 elements)</td></tr>
1858                 <tr><td>ALPHA_BITS</td><td>GLint</td></tr>
1859                 <tr><td>ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</td></tr>
1860                 <tr><td>BLEND</td><td>GLboolean</td></tr>
1861                 <tr><td>BLEND_COLOR</td><td>Float32Array (with 4 values)</td></tr>
1862                 <tr><td>BLEND_DST_ALPHA</td><td>GLenum</td></tr>
1863                 <tr><td>BLEND_DST_RGB</td><td>GLenum</td></tr>
1864                 <tr><td>BLEND_EQUATION_ALPHA</td><td>GLenum</td></tr>
1865                 <tr><td>BLEND_EQUATION_RGB</td><td>GLenum</td></tr>
1866                 <tr><td>BLEND_SRC_ALPHA</td><td>GLenum</td></tr>
1867                 <tr><td>BLEND_SRC_RGB</td><td>GLenum</td></tr>
1868                 <tr><td>BLUE_BITS</td><td>GLint</td></tr>
1869                 <tr><td>COLOR_CLEAR_VALUE</td><td>Float32Array (with 4 values)</td></tr>
1870                 <tr><td>COLOR_WRITEMASK</td><td>sequence&lt;GLboolean&gt; (with 4 values)</td></tr>
1871                 <tr><td>COMPRESSED_TEXTURE_FORMATS</td><td>Uint32Array</td></tr>
1872                 <tr><td>CULL_FACE</td><td>GLboolean</td></tr>
1873                 <tr><td>CULL_FACE_MODE</td><td>GLenum</td></tr>
1874                 <tr><td>CURRENT_PROGRAM</td><td>WebGLProgram</td></tr>
1875                 <tr><td>DEPTH_BITS</td><td>GLint</td></tr>
1876                 <tr><td>DEPTH_CLEAR_VALUE</td><td>GLfloat</td></tr>
1877                 <tr><td>DEPTH_FUNC</td><td>GLenum</td></tr>
1878                 <tr><td>DEPTH_RANGE</td><td>Float32Array (with 2 elements)</td></tr>
1879                 <tr><td>DEPTH_TEST</td><td>GLboolean</td></tr>
1880                 <tr><td>DEPTH_WRITEMASK</td><td>GLboolean</td></tr>
1881                 <tr><td>DITHER</td><td>GLboolean</td></tr>
1882                 <tr><td>ELEMENT_ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</td></tr>
1883                 <tr><td>FRAMEBUFFER_BINDING</td><td>WebGLFramebuffer</td></tr>
1884                 <tr><td>FRONT_FACE</td><td>GLenum</td></tr>
1885                 <tr><td>GENERATE_MIPMAP_HINT</td><td>GLenum</td></tr>
1886                 <tr><td>GREEN_BITS</td><td>GLint</td></tr>
1887                 <tr><td>LINE_WIDTH</td><td>GLfloat</td></tr>
1888                 <tr><td>MAX_COMBINED_TEXTURE_IMAGE_UNITS</td><td>GLint</td></tr>
1889                 <tr><td>MAX_CUBE_MAP_TEXTURE_SIZE</td><td>GLint</td></tr>
1890                 <tr><td>MAX_FRAGMENT_UNIFORM_VECTORS</td><td>GLint</td></tr>
1891                 <tr><td>MAX_RENDERBUFFER_SIZE</td><td>GLint</td></tr>
1892                 <tr><td>MAX_TEXTURE_IMAGE_UNITS</td><td>GLint</td></tr>
1893                 <tr><td>MAX_TEXTURE_SIZE</td><td>GLint</td></tr>
1894                 <tr><td>MAX_VARYING_VECTORS</td><td>GLint</td></tr>
1895                 <tr><td>MAX_VERTEX_ATTRIBS</td><td>GLint</td></tr>
1896                 <tr><td>MAX_VERTEX_TEXTURE_IMAGE_UNITS</td><td>GLint</td></tr>
1897                 <tr><td>MAX_VERTEX_UNIFORM_VECTORS</td><td>GLint</td></tr>
1898                 <tr><td>MAX_VIEWPORT_DIMS</td><td>Int32Array (with 2 elements)</td></tr>
1899                 <tr><td>PACK_ALIGNMENT</td><td>GLint</td></tr>
1900                 <tr><td>POLYGON_OFFSET_FACTOR</td><td>GLfloat</td></tr>
1901                 <tr><td>POLYGON_OFFSET_FILL</td><td>GLboolean</td></tr>
1902                 <tr><td>POLYGON_OFFSET_UNITS</td><td>GLfloat</td></tr>
1903                 <tr><td>RED_BITS</td><td>GLint</td></tr>
1904                 <tr><td>RENDERBUFFER_BINDING</td><td>WebGLRenderbuffer</td></tr>
1905                 <tr><td>RENDERER</td><td>DOMString</td></tr>
1906                 <tr><td>SAMPLE_BUFFERS</td><td>GLint</td></tr>
1907                 <tr><td>SAMPLE_COVERAGE_INVERT</td><td>GLboolean</td></tr>
1908                 <tr><td>SAMPLE_COVERAGE_VALUE</td><td>GLfloat</td></tr>
1909                 <tr><td>SAMPLES</td><td>GLint</td></tr>
1910                 <tr><td>SCISSOR_BOX</td><td>Int32Array (with 4 elements)</td></tr>
1911                 <tr><td>SCISSOR_TEST</td><td>GLboolean</td></tr>
1912                 <tr><td>SHADING_LANGUAGE_VERSION</td><td>DOMString</td></tr>
1913                 <tr><td>STENCIL_BACK_FAIL</td><td>GLenum</td></tr>
1914                 <tr><td>STENCIL_BACK_FUNC</td><td>GLenum</td></tr>
1915                 <tr><td>STENCIL_BACK_PASS_DEPTH_FAIL</td><td>GLenum</td></tr>
1916                 <tr><td>STENCIL_BACK_PASS_DEPTH_PASS</td><td>GLenum</td></tr>
1917                 <tr><td>STENCIL_BACK_REF</td><td>GLint</td></tr>
1918                 <tr><td>STENCIL_BACK_VALUE_MASK</td><td>GLuint</td></tr>
1919                 <tr><td>STENCIL_BACK_WRITEMASK</td><td>GLuint</td></tr>
1920                 <tr><td>STENCIL_BITS</td><td>GLint</td></tr>
1921                 <tr><td>STENCIL_CLEAR_VALUE</td><td>GLint</td></tr>
1922                 <tr><td>STENCIL_FAIL</td><td>GLenum</td></tr>
1923                 <tr><td>STENCIL_FUNC</td><td>GLenum</td></tr>
1924                 <tr><td>STENCIL_PASS_DEPTH_FAIL</td><td>GLenum</td></tr>
1925                 <tr><td>STENCIL_PASS_DEPTH_PASS</td><td>GLenum</td></tr>
1926                 <tr><td>STENCIL_REF</td><td>GLint</td></tr>
1927                 <tr><td>STENCIL_TEST</td><td>GLboolean</td></tr>
1928                 <tr><td>STENCIL_VALUE_MASK</td><td>GLuint</td></tr>
1929                 <tr><td>STENCIL_WRITEMASK</td><td>GLuint</td></tr>
1930                 <tr><td>SUBPIXEL_BITS</td><td>GLint</td></tr>
1931                 <tr><td>TEXTURE_BINDING_2D</td><td>WebGLTexture</td></tr>
1932                 <tr><td>TEXTURE_BINDING_CUBE_MAP</td><td>WebGLTexture</td></tr>
1933                 <tr><td>UNPACK_ALIGNMENT</td><td>GLint</td></tr>
1934                 <tr><td>UNPACK_COLORSPACE_CONVERSION_WEBGL</td><td>GLenum</td></tr>
1935                 <tr><td>UNPACK_FLIP_Y_WEBGL</td><td>GLboolean</td></tr>
1936                 <tr><td>UNPACK_PREMULTIPLY_ALPHA_WEBGL</td><td>GLboolean</td></tr>
1937                 <tr><td>VENDOR</td><td>DOMString</td></tr>
1938                 <tr><td>VERSION</td><td>DOMString</td></tr>
1939                 <tr><td>VIEWPORT</td><td>Int32Array (with 4 elements)</td></tr>
1940             </table><br>
1941             <p>All queries returning sequences or typed arrays return a new object each time.</p>
1942             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error and returns null.</p>
1943             <p>The following <em>pname</em> arguments return a string describing some aspect of the current WebGL implementation:</p>
1944             <table>
1945               <tr><td>VERSION</td>
1946                   <td>Returns a version or release number of the form <code>WebGL&lt;space&gt;1.0&lt;space&gt;&lt;vendor-specific information&gt;</code>.</td></tr>
1947               <tr><td>SHADING_LANGUAGE_VERSION</td>
1948                   <td>Returns a version or release number of the form <code>WebGL&lt;space&gt;GLSL&lt;space&gt;ES&lt;space&gt;1.0&lt;space&gt;&lt;vendor-specific information&gt;</code>.</td></tr>
1949               <tr><td>VENDOR</td>
1950                   <td>Returns the company responsible for this WebGL implementation. This name does not change from release to release.</td></tr>
1951               <tr><td>RENDERER</td>
1952                   <td>Returns the name of the renderer. This name is typically specific to a particular configuration of a hardware platform. It does not change from release to release.</td></tr>
1953             </table><br>
1954             <p>See <a href="#EXTENSION_QUERIES">Extension Queries</a> for information on querying the
1955             available extensions in the current WebGL implementation.</p>
1956         <dt class="idl-code">[WebGLHandlesContextLoss] GLenum getError()
1957             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.5">OpenGL ES 2.0 &sect;2.5</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetError.xml">man page</a>)</span>
1958             <dd>
1959                 If the context's <a href="#webgl-context-lost-flag">webgl context lost flag</a> is set,
1960                 returns <code class="enum">CONTEXT_LOST_WEBGL</code> the first time this method is
1961                 called. Afterward, returns <code class="enum">NO_ERROR</code> until the context has
1962                 been restored.
1963         <dt class="idl-code">void hint(GLenum target, GLenum mode)
1964             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-5.2">OpenGL ES 2.0 &sect;5.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glHint.xml">man page</a>)</span>
1965         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isEnabled(GLenum cap)
1966             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.1">OpenGL ES 2.0 &sect;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>
1967         <dd>
1968             Returns false if the context's <a href="#webgl-context-lost-flag">webgl context lost
1969             flag</a> is set.
1970         <dt class="idl-code">void lineWidth(GLfloat width)
1971             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.4">OpenGL ES 2.0 &sect;3.4</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glLineWidth.xml">man page</a>)</span>
1972         <dt class="idl-code">void pixelStorei(GLenum pname, GLint param)
1973             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.6.1">OpenGL ES 2.0 &sect;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>
1974             <dd>
1975                 In addition to the parameters in the OpenGL ES 2.0 specification, the WebGL
1976                 specification accepts the parameters <code>UNPACK_FLIP_Y_WEBGL</code>,
1977                 <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code>
1978                 and <code>UNPACK_COLORSPACE_CONVERSION_WEBGL</code>. See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel
1979                 Storage Parameters</a> for documentation of these parameters.
1980         <dt class="idl-code">void polygonOffset(GLfloat factor, GLfloat units)
1981             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.5.2">OpenGL ES 2.0 &sect;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>
1982         <dt class="idl-code">void sampleCoverage(GLclampf value, GLboolean invert)
1983             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.3">OpenGL ES 2.0 &sect;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>
1984         <dt class="idl-code">void stencilFunc(GLenum func, GLint ref, GLuint mask)
1985             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 &sect;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>
1986         <dt class="idl-code">void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
1987             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 &sect;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>
1988             <dd>
1989                 See <a href="#STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and Reference Value</a> for information
1990                 on WebGL specific limitations to the allowable argument values.
1991         <dt class="idl-code">void stencilMask(GLuint mask)
1992             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 &sect;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>
1993             <dd>
1994                 See <a href="#STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and Reference Value</a> for information
1995                 on WebGL specific limitations to the allowable mask values.
1996         <dt class="idl-code">void stencilMaskSeparate(GLenum face, GLuint mask)
1997             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.2">OpenGL ES 2.0 &sect;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>
1998         <dt class="idl-code">void stencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1999             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 &sect;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>
2000         <dt class="idl-code">void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
2001             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.4">OpenGL ES 2.0 &sect;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>
2002     </dl>
2003      
2004 <!-- ======================================================================================================= -->
2005
2006     <h4>Viewing and clipping</h4>
2007
2008     <p>
2009         The viewport specifies the affine transformation of x and y from normalized device 
2010         coordinates to window coordinates. The size of the drawing buffer is determined by 
2011         the HTMLCanvasElement. The scissor box defines a rectangle which constrains drawing.
2012         When the scissor test is enabled only pixels that lie within  the scissor box can 
2013         be modified by drawing commands. When enabled drawing can only occur inside the 
2014         intersection of the viewport, canvas area and the scissor box. When the scissor test
2015         is not enabled drawing can only occur inside the intersection of the viewport and 
2016         canvas area.
2017     </p>
2018
2019     <dl class="methods">
2020         <dt class="idl-code">void scissor(GLint x, GLint y, GLsizei width, GLsizei height)
2021             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.1.2">OpenGL ES 2.0 &sect;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>
2022             
2023         <dt class="idl-code">void viewport(GLint x, GLint y, GLsizei width, GLsizei height)
2024             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.12.1">OpenGL ES 2.0 &sect;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>
2025     </dl>
2026      
2027 <!-- ======================================================================================================= -->
2028
2029     <h4>Buffer objects</h4>
2030
2031     <p>
2032         Buffer objects (sometimes referred to as VBOs) hold vertex attribute data for the GLSL
2033         shaders.
2034     </p>
2035      
2036     <dl class="methods">
2037         <dt class="idl-code">void bindBuffer(GLenum target, WebGLBuffer? buffer)
2038             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindBuffer.xml">man page</a>)</span>
2039         <dd>
2040             Binds the given WebGLBuffer object to the given binding point (target), either
2041             ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER. If the buffer is null then any buffer currently
2042             bound to this target is unbound. A given WebGLBuffer object may only be bound to one of
2043             the ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target in its lifetime. An attempt to bind a
2044             buffer object to the other target will generate an <code>INVALID_OPERATION</code> error, and the
2045             current binding will remain untouched.
2046         
2047         <dt class="idl-code">void bufferData(GLenum target, GLsizeiptr size, GLenum usage)
2048             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">man page</a>)</span>
2049         <dd>
2050             Set the size of the currently bound WebGLBuffer object for the passed target. The
2051             buffer is initialized to 0.
2052             
2053         <dt><p class="idl-code">void bufferData(GLenum target, ArrayBufferView data, GLenum usage)</p>
2054             <p class="idl-code">void bufferData(GLenum target, ArrayBuffer? data, GLenum usage)
2055             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">man page</a>)</span></p>
2056         <dd>
2057             Set the size of the currently bound WebGLBuffer object for the passed target to the 
2058             size of the passed data, then write the contents of data to the buffer object.
2059             <br><br>
2060             If the passed data is null then an <code>INVALID_VALUE</code> error is generated.
2061         <dt><p class="idl-code">void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data)</p>
2062             <p class="idl-code">void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer? data)
2063             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;2.9</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferSubData.xml">man page</a>)</span></p>
2064         <dd>
2065             For the WebGLBuffer object bound to the passed target write the passed data starting at
2066             the passed offset. If the data would be written past the end of the buffer object
2067             an <code>INVALID_VALUE</code> error is generated. If <code>data</code> is null then
2068             an <code>INVALID_VALUE</code> error is generated.
2069             
2070         <dt class="idl-code">WebGLBuffer? createBuffer()
2071             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;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>
2072         <dd>
2073             Create a WebGLBuffer object and initialize it with a buffer object name as if by
2074             calling glGenBuffers.
2075             
2076         <dt class="idl-code">void deleteBuffer(WebGLBuffer? buffer)
2077             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.9">OpenGL ES 2.0 &sect;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>
2078         <dd>
2079             Delete the buffer object contained in the passed WebGLBuffer as if by calling
2080             glDeleteBuffers. If the buffer has already been deleted the call has no effect.
2081             Note that the buffer object will be deleted when the WebGLBuffer object is destroyed.
2082             This method merely gives the author greater control over when the buffer object is
2083             destroyed.
2084
2085         <dt class="idl-code">any getBufferParameter(GLenum target, GLenum pname)
2086             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 &sect;6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetBufferParameteriv.xml">glGetBufferParameteriv</a>)</span>
2087         <dd>
2088             Return the value for the passed pname. The type returned is the natural type for the
2089             requested pname, as given in the following table:
2090             <table class="foo">
2091                 <tr><th>pname</th><th>returned type</th></tr>
2092                 <tr><td>BUFFER_SIZE</td><td>GLint</td></tr>
2093                 <tr><td>BUFFER_USAGE</td><td>GLenum</td></tr>
2094             </table>
2095             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2096             <p>If an OpenGL error is generated, returns null.</p>
2097         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isBuffer(WebGLBuffer? buffer)
2098             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.6">OpenGL ES 2.0 &sect;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>
2099         <dd>
2100             Return true if the passed WebGLBuffer is valid and false otherwise. <br><br>
2101
2102             Returns false if the buffer's <a href="#webgl-object-invalidated-flag">invalidated
2103             flag</a> is set.
2104     </dl>
2105
2106 <!-- ======================================================================================================= -->
2107
2108     <h4>Framebuffer objects</h4>
2109
2110     <p>
2111         Framebuffer objects provide an alternative rendering target to the drawing buffer. They
2112         are a collection of color, alpha, depth and stencil buffers and are often used to 
2113         render an image that will later be used as a texture.
2114     </p>
2115      
2116     <dl class="methods">
2117         <dt class="idl-code">void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer)
2118             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;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>
2119         <dd>
2120             Bind the given <code class="interface">WebGLFramebuffer</code> object to the given binding point
2121             (<code class="param">target</code>), which must be <code class="enum">FRAMEBUFFER</code>.
2122             If <code class="param">framebuffer</code> is null, the default framebuffer provided by the context
2123             is bound and attempts to modify or query state on <code class="param">target</code> <code class="enum">FRAMEBUFFER</code>
2124             will generate an <code class="error">INVALID_OPERATION</code> error.
2125
2126         <dt class="idl-code">[WebGLHandlesContextLoss] GLenum checkFramebufferStatus(GLenum target)
2127             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.5">OpenGL ES 2.0 &sect;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>
2128         <dd>
2129             Returns <code class="enum">FRAMEBUFFER_UNSUPPORTED</code> if the
2130             context's <a href="#webgl-context-lost-flag">webgl context lost flag</a> is set.
2131
2132         <dt class="idl-code">WebGLFramebuffer? createFramebuffer()
2133             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;4.4.1</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenFramebuffers.xml">glGenFramebuffers</a>)</span>
2134         <dd>
2135             Create a WebGLFramebuffer object and initialize it with a framebuffer object name as if by
2136             calling glGenFramebuffers.
2137             
2138         <dt class="idl-code">void deleteFramebuffer(WebGLFramebuffer? buffer)
2139             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.1">OpenGL ES 2.0 &sect;4.4.1</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteFramebuffers.xml">glDeleteFramebuffers</a>)</span>
2140         <dd>
2141             Delete the framebuffer object contained in the passed WebGLFramebuffer as if by calling
2142             glDeleteFramebuffers. If the framebuffer has already been deleted the call has no effect.
2143             Note that the framebuffer object will be deleted when the WebGLFramebuffer object is destroyed.
2144             This method merely gives the author greater control over when the framebuffer object is
2145             destroyed.
2146
2147         <dt class="idl-code">void framebufferRenderbuffer(GLenum target, GLenum attachment, 
2148                                  GLenum renderbuffertarget, 
2149                                  WebGLRenderbuffer? renderbuffer)
2150             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;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>
2151         <dt class="idl-code">void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, 
2152                               WebGLTexture? texture, GLint level)
2153             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;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>
2154         <dt class="idl-code">any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, 
2155                                           GLenum pname)
2156             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 &sect;6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetFramebufferAttachmentParameteriv.xml">glGetFramebufferAttachmentParameteriv</a>)</span>
2157         <dd>
2158             Return the value for the passed pname given the passed target and attachment. The type 
2159             returned is the natural type for the requested pname, as given in the following table:
2160             <table class="foo">
2161                 <tr><th>pname</th><th>returned type</th></tr>
2162                 <tr><td>FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE</td><td>GLenum</td></tr>
2163                 <tr><td>FRAMEBUFFER_ATTACHMENT_OBJECT_NAME</td><td>WebGLRenderbuffer or WebGLTexture</td></tr>
2164                 <tr><td>FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL</td><td>GLint</td></tr>
2165                 <tr><td>FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE</td><td>GLint</td></tr>
2166             </table>
2167             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2168             <p>If an OpenGL error is generated, returns null.</p>
2169         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isFramebuffer(WebGLFramebuffer? framebuffer)
2170             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.7">OpenGL ES 2.0 &sect;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>
2171         <dd>
2172             Return true if the passed WebGLFramebuffer is valid and false otherwise. <br><br>
2173
2174             Returns false if the framebuffer's <a href="#webgl-object-invalidated-flag">invalidated
2175             flag</a> is set.
2176     </dl>
2177      
2178 <!-- ======================================================================================================= -->
2179
2180     <h4>Renderbuffer objects</h4>
2181
2182     <p>
2183         Renderbuffer objects are used to provide storage for the individual buffers used in a
2184         framebuffer object.
2185     </p>
2186      
2187     <dl class="methods">
2188         <dt class="idl-code">void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer)
2189             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;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>
2190         <dd>
2191             Bind the given <code class="interface">WebGLRenderbuffer</code> object to the given binding point
2192             (<code class="param">target</code>), which must be <code class="enum">RENDERBUFFER</code>.
2193             If <code class="param">renderbuffer</code> is null the renderbuffer object currently bound to
2194             this <code class="param">target</code> is unbound.
2195
2196         <dt class="idl-code">WebGLRenderbuffer? createRenderbuffer()
2197             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;4.4.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenRenderbuffers.xml">glGenRenderbuffers</a>)</span>
2198         <dd>
2199             Create a WebGLRenderbuffer object and initialize it with a renderbuffer object name as if by
2200             calling glGenRenderbuffers.
2201             
2202         <dt class="idl-code">void deleteRenderbuffer(WebGLRenderbuffer? renderbuffer)
2203             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;4.4.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteRenderbuffers.xml">glDeleteRenderbuffers</a>)</span>
2204         <dd>
2205             Delete the renderbuffer object contained in the passed WebGLRenderbuffer as if by calling
2206             glDeleteRenderbuffers. If the renderbuffer has already been deleted the call has no effect.
2207             Note that the renderbuffer object will be deleted when the WebGLRenderbuffer object is destroyed.
2208             This method merely gives the author greater control over when the renderbuffer object is
2209             destroyed.
2210         <dt class="idl-code">any getRenderbufferParameter(GLenum target, GLenum pname)
2211             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 &sect;6.1.3</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetRenderbufferParameteriv.xml">glGetRenderbufferParameteriv</a>)</span>
2212         <dd>
2213             Return the value for the passed pname given the passed target. The type returned is the natural 
2214             type for the requested pname, as given in the following table:
2215             <table class="foo">
2216                 <tr><th>pname</th><th>returned type</th></tr>
2217                 <tr><td>RENDERBUFFER_WIDTH</td><td>GLint</td></tr>
2218                 <tr><td>RENDERBUFFER_HEIGHT</td><td>GLint</td></tr>
2219                 <tr><td>RENDERBUFFER_INTERNAL_FORMAT</td><td>GLenum</td></tr>
2220                 <tr><td>RENDERBUFFER_RED_SIZE</td><td>GLint</td></tr>
2221                 <tr><td>RENDERBUFFER_GREEN_SIZE</td><td>GLint</td></tr>
2222                 <tr><td>RENDERBUFFER_BLUE_SIZE</td><td>GLint</td></tr>
2223                 <tr><td>RENDERBUFFER_ALPHA_SIZE</td><td>GLint</td></tr>
2224                 <tr><td>RENDERBUFFER_DEPTH_SIZE</td><td>GLint</td></tr>
2225                 <tr><td>RENDERBUFFER_STENCIL_SIZE</td><td>GLint</td></tr>
2226             </table>
2227             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2228             <p>If an OpenGL error is generated, returns null.</p>
2229         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer)
2230             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.7">OpenGL ES 2.0 &sect;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>
2231         <dd>
2232             Return true if the passed WebGLRenderbuffer is valid and false otherwise. <br><br>
2233
2234             Returns false if the renderbuffer's <a href="#webgl-object-invalidated-flag">invalidated
2235             flag</a> is set.
2236         <dt class="idl-code">void renderbufferStorage(GLenum target, GLenum internalformat, 
2237                              GLsizei width, GLsizei height)
2238             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.4.3">OpenGL ES 2.0 &sect;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>
2239     </dl>
2240
2241 <!-- ======================================================================================================= -->
2242
2243     <h4>Texture objects</h4>
2244
2245     <p>
2246         Texture objects provide storage and state for texturing operations. If no WebGLTexture is bound
2247         (e.g., passing null or 0 to bindTexture) then attempts to modify or query the texture object shall
2248         generate an <code>INVALID_OPERATION</code> error. This is indicated in the functions below.
2249     </p>
2250      
2251     <dl class="methods">
2252         <dt class="idl-code">void bindTexture(GLenum target, WebGLTexture? texture)
2253             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
2254
2255         <dt><p class="idl-code"><a name="COMPRESSEDTEXIMAGE2D">void compressedTexImage2D</a>(GLenum target, GLint level, GLenum internalformat, 
2256                     GLsizei width, GLsizei height, GLint border, ArrayBufferView pixels)
2257                 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.3">OpenGL ES 2.0 &sect;3.7.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCompressedTexImage2D.xml">man page</a>)</span></p>
2258             <p class="idl-code"><a name="COMPRESSEDTEXSUBIMAGE2D">void compressedTexSubImage2D</a>(GLenum target, GLint level,
2259                     GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView pixels)
2260                 <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.3">OpenGL ES 2.0 &sect;3.7.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCompressedTexSubImage2D.xml">man page</a>)</span></p>
2261         <dd>
2262             If an attempt is made to call these functions with no WebGLTexture bound (see above), an
2263             <code>INVALID_OPERATION</code> error is generated. <br><br>
2264
2265             The core WebGL specification does not define any supported compressed texture formats.
2266             By default, these methods generate an <code>INVALID_ENUM</code> error and return
2267             immediately. See <a href="#COMPRESSED_TEXTURE_SUPPORT">Compressed Texture Support</a>.
2268
2269         <dt class="idl-code">void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, 
2270                         GLint x, GLint y, GLsizei width, GLsizei height, 
2271                         GLint border)
2272             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;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>
2273         <dd>
2274             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2275             <code>INVALID_OPERATION</code> error is generated. <br><br>
2276
2277             For any pixel lying outside the frame buffer, all channels of the associated texel are
2278             initialized to 0; see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the
2279             Framebuffer</a>.
2280         <dt class="idl-code">void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2281                            GLint x, GLint y, GLsizei width, GLsizei height)
2282             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;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>
2283         <dd>
2284             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2285             <code>INVALID_OPERATION</code> error is generated. <br><br>
2286
2287             For any pixel lying outside the frame buffer, all channels of the associated texel are
2288             initialized to 0; see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the
2289             Framebuffer</a>.
2290         <dt class="idl-code">WebGLTexture? createTexture()
2291             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
2292         <dd>
2293             Create a WebGLTexture object and initialize it with a texture object name as if by
2294             calling glGenTextures.
2295             
2296         <dt class="idl-code">void deleteTexture(WebGLTexture? texture)
2297             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.13">OpenGL ES 2.0 &sect;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>
2298         <dd>
2299             Delete the texture object contained in the passed WebGLTexture as if by calling
2300             glDeleteTextures. If the texture has already been deleted the call has no effect.
2301             Note that the texture object will be deleted when the WebGLTexture object is destroyed.
2302             This method merely gives the author greater control over when the texture object is
2303             destroyed.
2304         <dt class="idl-code">void generateMipmap(GLenum target)
2305             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.11">OpenGL ES 2.0 &sect;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>
2306         <dd>
2307             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2308             <code>INVALID_OPERATION</code> error is generated.
2309         <dt class="idl-code">any getTexParameter(GLenum target, GLenum pname)
2310             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.3">OpenGL ES 2.0 &sect;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>
2311         <dd>
2312             Return the value for the passed pname given the passed target. The type returned is the natural type for the
2313             requested pname, as given in the following table:
2314             <table class="foo">
2315                 <tr><th>pname</th><th>returned type</th></tr>
2316                 <tr><td>TEXTURE_MAG_FILTER</td><td>GLenum</td></tr>
2317                 <tr><td>TEXTURE_MIN_FILTER</td><td>GLenum</td></tr>
2318                 <tr><td>TEXTURE_WRAP_S</td><td>GLenum</td></tr>
2319                 <tr><td>TEXTURE_WRAP_T</td><td>GLenum</td></tr>
2320             </table>
2321             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2322             <p>If an attempt is made to call this function with no WebGLTexture bound (see above), generates an
2323             <code>INVALID_OPERATION</code> error.</p>
2324             <p>If an OpenGL error is generated, returns null.</p>
2325         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isTexture(WebGLTexture? texture)
2326             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.4">OpenGL ES 2.0 &sect;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>
2327         <dd>
2328             Return true if the passed WebGLTexture is valid and false otherwise. <br><br>
2329
2330             Returns false if the texture's <a href="#webgl-object-invalidated-flag">invalidated
2331             flag</a> is set.
2332         <dt class="idl-code"><a name="TEXIMAGE2D">void texImage2D</a>(GLenum target, GLint level, GLenum internalformat, 
2333                     GLsizei width, GLsizei height, GLint border, GLenum format, 
2334                     GLenum type, ArrayBufferView? pixels)
2335             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.1">OpenGL ES 2.0 &sect;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>
2336         <dd>
2337             If <code>pixels</code> is null, a buffer of sufficient size initialized to 0 is
2338             passed. <br><br>
2339
2340             If <code>pixels</code> is non-null, the type of <code>pixels</code> must match the type
2341             of the data to be read. If it is UNSIGNED_BYTE, a Uint8Array must be supplied; if it is
2342             UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_SHORT_5_5_5_1, a Uint16Array
2343             must be supplied. If the types do not match, an INVALID_OPERATION error is generated.
2344             <br><br>
2345
2346             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2347             <code>INVALID_OPERATION</code> error is generated. <br><br>
2348
2349             See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a> for WebGL-specific
2350             pixel storage parameters that affect the behavior of this function.
2351         <dt><p class="idl-code"><a name="TEXIMAGE2D_HTML">void texImage2D</a>(GLenum target, GLint level, GLenum internalformat,
2352                     GLenum format, GLenum type, ImageData? pixels)</p>
2353             <p class="idl-code">void texImage2D(GLenum target, GLint level, GLenum internalformat,
2354                     GLenum format, GLenum type, HTMLImageElement image) /* May throw DOMException */</p>
2355             <p class="idl-code">void texImage2D(GLenum target, GLint level, GLenum internalformat,
2356                     GLenum format, GLenum type, HTMLCanvasElement canvas) /* May throw DOMException */</p>
2357             <p class="idl-code">void texImage2D(GLenum target, GLint level, GLenum internalformat,
2358                     GLenum format, GLenum type, HTMLVideoElement video) /* May throw DOMException */
2359             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.1">OpenGL ES 2.0 &sect;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>
2360         <dd>
2361             Uploads the given element or image data to the currently bound WebGLTexture. <br><br>
2362
2363             The source image data is conceptually first converted to the data type and format
2364             specified by the <em>format</em> and <em>type</em> arguments, and then transferred to
2365             the WebGL implementation. If a packed pixel format is specified which would imply loss
2366             of bits of precision from the image data, this loss of precision must occur. <br><br>
2367
2368             The first pixel transferred from the source to the WebGL implementation corresponds to
2369             the upper left corner of the source. This behavior is modified by the
2370             the <code>UNPACK_FLIP_Y_WEBGL</code> <a href="#PIXEL_STORAGE_PARAMETERS">pixel storage
2371             parameter</a>. <br><br>
2372
2373             If the source image is an RGB or RGBA lossless image with 8 bits per channel, the
2374             browser guarantees that the full precision of all channels is preserved. <br><br>
2375
2376             If the original image contains an alpha channel and the
2377             <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel storage parameter is false, then the
2378             RGB values are guaranteed to never have been premultiplied by the alpha channel, whether
2379             those values are derived directly from the original file format or converted from some
2380             other color format. <br><br>
2381
2382             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2383             <code>INVALID_OPERATION</code> error is generated. <br><br>
2384
2385             If this function is called with an <code>HTMLImageElement</code>
2386             or <code>HTMLVideoElement</code> whose origin differs from the origin of the containing
2387             Document, or with an <code>HTMLCanvasElement</code> whose <i>origin-clean</i> flag is
2388             set to false, a <code>SECURITY_ERR</code> exception must be
2389             thrown. See <a href="#ORIGIN_RESTRICTIONS">Origin Restrictions</a>.<br><br>
2390
2391             If <code>pixels</code> is null then an <code>INVALID_VALUE</code> error is
2392             generated. <br><br>
2393
2394             See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a> for WebGL-specific
2395             pixel storage parameters that affect the behavior of this function.
2396         <dt class="idl-code">void texParameterf(GLenum target, GLenum pname, GLfloat param)
2397             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.4">OpenGL ES 2.0 &sect;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>
2398         <dd>
2399             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2400             <code>INVALID_OPERATION</code> error is generated.
2401         <dt class="idl-code">void texParameteri(GLenum target, GLenum pname, GLint param)
2402             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.4">OpenGL ES 2.0 &sect;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>
2403         <dd>
2404             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2405             <code>INVALID_OPERATION</code> error is generated.
2406         <dt class="idl-code">void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2407                        GLsizei width, GLsizei height, 
2408                        GLenum format, GLenum type, ArrayBufferView? pixels)
2409             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;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>
2410         <dd>
2411             See <a href="#TEXIMAGE2D">texImage2D</a> for restrictions on the <em>format</em>
2412             and <em>pixels</em> arguments. <br><br>
2413
2414             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2415             <code>INVALID_OPERATION</code> error is generated. <br><br>
2416
2417             If <em>type</em> does not match the type originally used to define the texture, an
2418             <code>INVALID_OPERATION</code> error is generated. <br><br>
2419
2420             If <code>pixels</code> is null then an <code>INVALID_VALUE</code> error is
2421             generated. <br><br>
2422
2423             See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a> for WebGL-specific
2424             pixel storage parameters that affect the behavior of this function.
2425         <dt><p class="idl-code">void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2426                        GLenum format, GLenum type, ImageData? pixels)</p>
2427             <p class="idl-code">void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2428                        GLenum format, GLenum type, HTMLImageElement image) /* May throw DOMException */</p>
2429             <p class="idl-code">void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2430                        GLenum format, GLenum type, HTMLCanvasElement canvas) /* May throw DOMException */</p>
2431             <p class="idl-code">void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 
2432                        GLenum format, GLenum type, HTMLVideoElement video) /* May throw DOMException */
2433             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;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>
2434         <dd>
2435             Updates a sub-rectangle of the currently bound WebGLTexture with the contents of the
2436             given element or image data. <br><br>
2437
2438             See <a href="#TEXIMAGE2D_HTML">texImage2D</a> for the interpretation of
2439             the <em>format</em> and <em>type</em> arguments. <br><br>
2440
2441             The first pixel transferred from the source to the WebGL implementation corresponds to
2442             the upper left corner of the source. This behavior is modified by the
2443             the <code>UNPACK_FLIP_Y_WEBGL</code> <a href="#PIXEL_STORAGE_PARAMETERS">pixel storage
2444             parameter</a>. <br><br>
2445
2446             If an attempt is made to call this function with no WebGLTexture bound (see above), an
2447             <code>INVALID_OPERATION</code> error is generated. <br><br>
2448
2449             If <em>type</em> does not match the type originally used to define the texture, an
2450             <code>INVALID_OPERATION</code> error is generated. <br><br>
2451
2452             If this function is called with an <code>HTMLImageElement</code>
2453             or <code>HTMLVideoElement</code> whose origin differs from the origin of the containing
2454             Document, or with an <code>HTMLCanvasElement</code> whose <i>origin-clean</i> flag is
2455             set to false, a <code>SECURITY_ERR</code> exception must be
2456             thrown. See <a href="#ORIGIN_RESTRICTIONS">Origin Restrictions</a>.<br><br>
2457
2458             If <code>pixels</code> is null then an <code>INVALID_VALUE</code> error is
2459             generated. <br><br>
2460
2461             See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a> for WebGL-specific
2462             pixel storage parameters that affect the behavior of this function.
2463     </dl>
2464      
2465 <!-- ======================================================================================================= -->
2466
2467     <h4>Programs and Shaders</h4>
2468
2469     <p>
2470         Rendering with OpenGL ES 2.0 requires the use of <i>shaders</i>, written in OpenGL ES's shading language, GLSL ES.
2471         Shaders must be loaded with a source string (shaderSource), compiled
2472         (compileShader) and attached to a <i>program</i> (attachShader) which must be linked
2473         (linkProgram) and then used (useProgram).
2474     </p>
2475
2476     <dl class="methods">
2477         <dt class="idl-code">void attachShader(WebGLProgram? program, WebGLShader? shader)
2478             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2479         <dt class="idl-code">void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name)
2480             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2481         <dd>
2482             If the passed name is longer than the restriction defined
2483             in <a href="#MAX_LOCATION_LENGTHS">Maximum Uniform and Attribute Location Lengths</a>,
2484             generates an <code>INVALID_VALUE</code> error. <br><br>
2485
2486             If <code>name</code> starts with one of the reserved WebGL prefixes
2487             per <a href="#GLSL_CONSTRUCTS">GLSL Constructs</a>, generates
2488             an <code>INVALID_OPERATION</code> error. <br><br>
2489
2490             See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source Character
2491             Set</a> for additional validation performed by WebGL implementations.
2492         <dt class="idl-code">void compileShader(WebGLShader? shader)
2493             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
2494         <dd>
2495             See <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL
2496             Constructs</a>, <a href="#MAX_GLSL_TOKEN_SIZE">Maximum GLSL Token
2497             Size</a>, <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source
2498             Character Set</a>, <a href="#MAX_STRUCT_NESTING">Maximum Nesting of Structures in GLSL
2499             Shaders</a>, and <a href="#PACKING_RESTRICTIONS">Packing Restrictions for Uniforms and
2500             Varyings</a> for additional constraints enforced in, additional constructs supported by,
2501             and additional validation performed by WebGL implementations.
2502         <dt class="idl-code">WebGLProgram? createProgram()
2503             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2504         <dd>
2505             Create a WebGLProgram object and initialize it with a program object name as if by
2506             calling glCreateProgram.
2507             
2508         <dt class="idl-code">WebGLShader? createShader(type)
2509             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
2510         <dd>
2511             Create a WebGLShader object and initialize it with a shader object name as if by
2512             calling glCreateShader.
2513             
2514         <dt class="idl-code">void deleteProgram(WebGLProgram? program)
2515             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2516         <dd>
2517             Delete the program object contained in the passed WebGLProgram as if by calling
2518             glDeleteProgram. If the program has already been deleted the call has no effect.
2519             Note that the program object will be deleted when the WebGLProgram object is destroyed.
2520             This method merely gives the author greater control over when the program object is
2521             destroyed.
2522         <dt class="idl-code">void deleteShader(WebGLShader? shader)
2523             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
2524         <dd>
2525             Delete the shader object contained in the passed WebGLShader as if by calling
2526             glDeleteShader. If the shader has already been deleted the call has no effect.
2527             Note that the shader object will be deleted when the WebGLShader object is destroyed.
2528             This method merely gives the author greater control over when the shader object is
2529             destroyed.
2530         <dt class="idl-code">void detachShader(WebGLProgram? program, WebGLShader? shader)
2531             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2532         <dt class="idl-code">sequence&lt;WebGLShader&gt;? getAttachedShaders(WebGLProgram? program)
2533             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2534         <dd>
2535             <p>Returns a new object representing the list of shaders attached to the passed program.</p>
2536
2537             <p>Returns null if any OpenGL errors are generated during the execution of this
2538             function.</p>
2539         <dt class="idl-code">any getProgramParameter(WebGLProgram? program, GLenum pname)
2540             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetProgramiv.xml">man page</a>)</span>
2541         <dd>
2542             Return the value for the passed pname given the passed program. The type returned is the natural 
2543             type for the requested pname, as given in the following table:
2544             <table class="foo">
2545                 <tr><th>pname</th><th>returned type</th></tr>
2546                 <tr><td>DELETE_STATUS</td><td>GLboolean</td></tr>
2547                 <tr><td>LINK_STATUS</td><td>GLboolean</td></tr>
2548                 <tr><td>VALIDATE_STATUS</td><td>GLboolean</td></tr>
2549                 <tr><td>ATTACHED_SHADERS</td><td>GLint</td></tr>
2550                 <tr><td>ACTIVE_ATTRIBUTES</td><td>GLint</td></tr>
2551                 <tr><td>ACTIVE_UNIFORMS</td><td>GLint</td></tr>
2552             </table>
2553             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error and returns null.</p>
2554             <p>Returns null if any OpenGL errors are generated during the execution of this
2555             function.</p>
2556         <dt class="idl-code">DOMString? getProgramInfoLog(WebGLProgram? program)
2557             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2558         <dd>
2559             <p>Returns null if any OpenGL errors are generated during the execution of this
2560             function.</p>
2561         <dt class="idl-code">any getShaderParameter(WebGLShader? shader, GLenum pname)
2562             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetShaderiv.xml">man page</a>)</span>
2563         <dd>
2564             Return the value for the passed pname given the passed shader. The type returned is the natural 
2565             type for the requested pname, as given in the following table:
2566             <table class="foo">
2567                 <tr><th>pname</th><th>returned type</th></tr>
2568                 <tr><td>SHADER_TYPE</td><td>GLenum</td></tr>
2569                 <tr><td>DELETE_STATUS</td><td>GLboolean</td></tr>
2570                 <tr><td>COMPILE_STATUS</td><td>GLboolean</td></tr>
2571             </table>
2572             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error and returns null.</p>
2573             <p>Returns null if any OpenGL errors are generated during the execution of this
2574             function.</p>
2575         <dt class="idl-code">WebGLShaderPrecisionFormat getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype)
2576             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetShaderPrecisionFormat.xml">man page</a>)</span>
2577         <dd>
2578             Return a new <code>WebGLShaderPrecisionFormat</code> describing the range and precision
2579             for the specified shader numeric format. The shadertype value can be FRAGMENT_SHADER or
2580             VERTEX_SHADER. The precisiontype value can be LOW_FLOAT, MEDIUM_FLOAT, HIGH_FLOAT,
2581             LOW_INT, MEDIUM_INT or HIGH_INT.
2582         <dt class="idl-code">DOMString? getShaderInfoLog(WebGLShader? shader)
2583             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2584         <dd>
2585             <p>Returns null if any OpenGL errors are generated during the execution of this
2586             function.</p>
2587         <dt class="idl-code">DOMString? getShaderSource(WebGLShader? shader)
2588             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2589         <dd>
2590             <p>Returns null if any OpenGL errors are generated during the execution of this
2591             function.</p>
2592         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isProgram(WebGLProgram? program)
2593             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2594         <dd>
2595             Return true if the passed WebGLProgram is valid and false otherwise. <br><br>
2596
2597             Returns false if the program's <a href="#webgl-object-invalidated-flag">invalidated
2598             flag</a> is set.
2599         <dt class="idl-code">[WebGLHandlesContextLoss] GLboolean isShader(WebGLShader? shader)
2600             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2601         <dd>
2602             Return true if the passed WebGLShader is valid and false otherwise. <br><br>
2603
2604             Returns false if the shader's <a href="#webgl-object-invalidated-flag">invalidated
2605             flag</a> is set.
2606         <dt class="idl-code">void linkProgram(WebGLProgram? program)
2607             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2608         <dd>
2609             See <a href="#PACKING_RESTRICTIONS">Packing Restrictions for Uniforms and Varyings</a>
2610             for additional constraints enforced in, and additional validation performed by, WebGL
2611             implementations.
2612         <dt class="idl-code">void shaderSource(WebGLShader? shader, DOMString source)
2613             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.1">OpenGL ES 2.0 &sect;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>
2614         <dd>
2615             See <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL
2616             Constructs</a>, <a href="#MAX_GLSL_TOKEN_SIZE">Maximum GLSL Token
2617             Size</a>, <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source
2618             Character Set</a>, <a href="#MAX_STRUCT_NESTING">Maximum Nesting of Structures in GLSL
2619             Shaders</a>, and <a href="#PACKING_RESTRICTIONS">Packing Restrictions for Uniforms and
2620             Varyings</a> for additional constraints enforced in, additional constructs supported by,
2621             and additional validation performed by WebGL implementations.
2622         <dt class="idl-code">void useProgram(WebGLProgram? program)
2623             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.3">OpenGL ES 2.0 &sect;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>
2624         <dt class="idl-code">void validateProgram(WebGLProgram? program)
2625             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.5">OpenGL ES 2.0 &sect;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>
2626     </dl>
2627     
2628 <!-- ======================================================================================================= -->
2629
2630     <h4>Uniforms and attributes</h4>
2631
2632     <p>
2633         Values used by the shaders are passed in as uniforms or vertex attributes.
2634     </p>
2635      
2636     <dl class="methods">
2637         <dt class="idl-code">void disableVertexAttribArray(GLuint index)
2638             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDisableVertexAttribArray.xml">man page</a>)</span>
2639         <dt class="idl-code">void enableVertexAttribArray(GLuint index)
2640             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glEnableVertexAttribArray.xml">man page</a>)</span>
2641         <dd>
2642             Enable the vertex attribute at <code>index</code> as an array. WebGL imposes additional
2643             rules beyond OpenGL ES 2.0 regarding enabled vertex attributes;
2644             see <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes and Range
2645             Checking</a>.
2646         <dt class="idl-code">WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index)
2647             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2648         <dd>
2649             Returns a new <code>WebGLActiveInfo</code> object describing the size, type and name of
2650             the vertex attribute at the passed index of the passed program object. If the passed
2651             index is out of range, generates an <code>INVALID_VALUE</code> error and returns null.
2652             <p>Returns null if any OpenGL errors are generated during the execution of this
2653             function.</p>
2654         <dt class="idl-code">WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index)
2655             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2656         <dd>
2657             Returns a new <code>WebGLActiveInfo</code> object describing the size, type and name of
2658             the uniform at the passed index of the passed program object. If the passed index is out
2659             of range, generates an <code>INVALID_VALUE</code> error and returns null.
2660             <p>Returns null if any OpenGL errors are generated during the execution of this
2661             function.</p>
2662         <dt class="idl-code">[WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram? program, DOMString name)
2663             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2664         <dd>
2665             If the passed name is longer than the restriction defined
2666             in <a href="#MAX_LOCATION_LENGTHS">Maximum Uniform and Attribute Location Lengths</a>,
2667             generates an <code>INVALID_VALUE</code> error and returns -1. <br><br>
2668
2669             Returns -1 if <code>name</code> starts with one of the reserved WebGL prefixes
2670             per <a href="#GLSL_CONSTRUCTS">GLSL Constructs</a>. <br><br>
2671
2672             Returns -1 if the context's <a href="#webgl-context-lost-flag">webgl context lost
2673             flag</a> is set. <br><br>
2674
2675             If the <a href="#webgl-object-invalidated-flag">invalidated flag</a> of the passed
2676             program is set, generates an <code>INVALID_OPERATION</code> error and returns
2677             -1. <br><br>
2678
2679             See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source Character
2680             Set</a> for additional validation performed by WebGL implementations.
2681         <dt class="idl-code">any getUniform(WebGLProgram? program, WebGLUniformLocation? location)
2682             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2683         <dd>
2684             Return the uniform value at the passed location in the passed program. The type returned is 
2685             dependent on the uniform type, as shown in the following table:
2686             <table class="foo">
2687                 <tr><th>uniform type</th><th>returned type</th></tr>
2688                 <tr><td>boolean</td><td>GLboolean</td></tr>
2689                 <tr><td>int</td><td>GLint</td></tr>
2690                 <tr><td>float</td><td>GLfloat</td></tr>
2691                 <tr><td>vec2</td><td>Float32Array (with 2 elements)</td></tr>
2692                 <tr><td>ivec2</td><td>Int32Array (with 2 elements)</td></tr>
2693                 <tr><td>bvec2</td><td>sequence&lt;GLboolean&gt; (with 2 elements)</td></tr>
2694                 <tr><td>vec3</td><td>Float32Array (with 3 elements)</td></tr>
2695                 <tr><td>ivec3</td><td>Int32Array (with 3 elements)</td></tr>
2696                 <tr><td>bvec3</td><td>sequence&lt;GLboolean&gt; (with 3 elements)</td></tr>
2697                 <tr><td>vec4</td><td>Float32Array (with 4 elements)</td></tr>
2698                 <tr><td>ivec4</td><td>Int32Array (with 4 elements)</td></tr>
2699                 <tr><td>bvec4</td><td>sequence&lt;GLboolean&gt; (with 4 elements)</td></tr>
2700                 <tr><td>mat2</td><td>Float32Array (with 4 elements)</td></tr>
2701                 <tr><td>mat3</td><td>Float32Array (with 9 elements)</td></tr>
2702                 <tr><td>mat4</td><td>Float32Array (with 16 elements)</td></tr>
2703                 <tr><td>sampler2D</td><td>GLint</td></tr>
2704                 <tr><td>samplerCube</td><td>GLint</td></tr>
2705             </table>
2706             <p>All queries returning sequences or typed arrays return a new object each time.</p>
2707             <p>Returns null if any OpenGL errors are generated during the execution of this
2708             function.</p>
2709         <dt class="idl-code">WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name)
2710             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2711         <dd>
2712             <p>Return a new <code>WebGLUniformLocation</code> that represents the location of a
2713             specific uniform variable within a program object. The return value is null if name does
2714             not correspond to an active uniform variable in the passed program.</p>
2715
2716             <p>If the passed name is longer than the restriction defined
2717             in <a href="#MAX_LOCATION_LENGTHS">Maximum Uniform and Attribute Location Lengths</a>,
2718             generates an <code>INVALID_VALUE</code> error and returns null.</p>
2719
2720             <p>Returns null if <code>name</code> starts with one of the reserved WebGL prefixes
2721             per <a href="#GLSL_CONSTRUCTS">GLSL Constructs</a>.</p>
2722
2723             <p>See <a href="#CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source
2724             Character Set</a> for additional validation performed by WebGL implementations.</p>
2725
2726             <p>Returns null if any OpenGL errors are generated during the execution of this
2727             function.</p>
2728         <dt class="idl-code">any getVertexAttrib(GLuint index, GLenum pname)
2729             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;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>
2730         <dd>
2731             Return the information requested in pname about the vertex attribute at the passed index. The 
2732             type returned is dependent on the information requested, as shown in the following table:
2733             <table class="foo">
2734                 <tr><th>pname</th><th>returned type</th></tr>
2735                 <tr><td>VERTEX_ATTRIB_ARRAY_BUFFER_BINDING</td><td>WebGLBuffer</td></tr>
2736                 <tr><td>VERTEX_ATTRIB_ARRAY_ENABLED</td><td>GLboolean</td></tr>
2737                 <tr><td>VERTEX_ATTRIB_ARRAY_SIZE</td><td>GLint</td></tr>
2738                 <tr><td>VERTEX_ATTRIB_ARRAY_STRIDE</td><td>GLint</td></tr>
2739                 <tr><td>VERTEX_ATTRIB_ARRAY_TYPE</td><td>GLenum</td></tr>
2740                 <tr><td>VERTEX_ATTRIB_ARRAY_NORMALIZED</td><td>GLboolean</td></tr>
2741                 <tr><td>CURRENT_VERTEX_ATTRIB</td><td>Float32Array (with 4 elements)</td></tr>
2742             </table>
2743             <p>All queries returning sequences or typed arrays return a new object each time.</p>
2744             <p>If <em>pname</em> is not in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2745             <p>If an OpenGL error is generated, returns null.</p>
2746         <dt class="idl-code">[WebGLHandlesContextLoss] GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname)
2747             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-6.1.8">OpenGL ES 2.0 &sect;6.1.8</a>, similar to <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetVertexAttribPointerv.xml">man page</a>)</span>
2748         <dd>
2749             Returns 0 if the context's <a href="#webgl-context-lost-flag">webgl context lost
2750             flag</a> is set.
2751         <dt><p class="idl-code">void uniform[1234][fi](WebGLUniformLocation? location, ...)</p>
2752             <p class="idl-code">void uniform[1234][fi]v(WebGLUniformLocation? location, ...)
2753             <p class="idl-code">void uniformMatrix[234]fv(WebGLUniformLocation? location, GLboolean transpose, ...)
2754             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.10.4">OpenGL ES 2.0 &sect;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>
2755        <dd>
2756             Each of the uniform* functions above sets the specified uniform or uniforms to the
2757             values provided. If the passed <code>location</code> is not null and was not obtained
2758             from the currently used program via an earlier call to <code>getUniformLocation</code>,
2759             an <code>INVALID_OPERATION</code> error will be generated. If the passed
2760             <code>location</code> is null, the data passed in will be silently ignored and
2761             no uniform variables will be changed.
2762             <br><br>
2763             If the array passed to any of the vector forms (those ending in <code>v</code>) has an 
2764             invalid length, an <code>INVALID_VALUE</code> error will be generated. The length is 
2765             invalid if it is too short for or is not an integer multiple of the assigned type.
2766         <dt><p class="idl-code">void vertexAttrib[1234]f(GLuint indx, ...)</p>
2767             <p class="idl-code">void vertexAttrib[1234]fv(GLuint indx, ...)
2768             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.7">OpenGL ES 2.0 &sect;2.7</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">man page</a>)</span></p>
2769        <dd>
2770            Sets the vertex attribute at the passed index to the given constant value. Values set via the
2771            <code>vertexAttrib</code> are guaranteed to be returned from the <code>getVertexAttrib</code> function
2772            with the <code>CURRENT_VERTEX_ATTRIB</code> param, even if there have been intervening calls to 
2773            <code>drawArrays</code> or <code>drawElements</code>.
2774        <dt class="idl-code">void vertexAttribPointer(GLuint indx, GLint size, GLenum type, 
2775                             GLboolean normalized, GLsizei stride, GLintptr offset)
2776             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttribPointer.xml">man page</a>)</span>
2777         <dd>
2778             Assign the WebGLBuffer object currently bound to the ARRAY_BUFFER target to the vertex
2779             attribute at the passed index. Size is number of components per attribute. Stride and
2780             offset are in units of bytes. Passed stride and offset must be appropriate for the
2781             passed type and size or an <code>INVALID_OPERATION</code> error will be generated;
2782             see <a href="#BUFFER_OFFSET_AND_STRIDE">Buffer Offset and Stride Requirements</a>. If
2783             offset is negative, an <code>INVALID_VALUE</code> error will be generated. If no
2784             WebGLBuffer is bound to the ARRAY_BUFFER target, an <code>INVALID_OPERATION</code> error
2785             will be generated. In WebGL, the maximum supported stride is 255;
2786             see <a href="#VERTEX_STRIDE"> Vertex Attribute Data Stride</a>.
2787     </dl>
2788     
2789 <!-- ======================================================================================================= -->
2790
2791     <h4>Writing to the drawing buffer</h4>
2792
2793     <p>
2794         OpenGL ES 2.0 has 3 calls which can render to the drawing buffer: <code>clear</code>, 
2795         <code>drawArrays</code> and <code>drawElements</code>. Furthermore rendering can
2796         be directed to the drawing buffer or to a Framebuffer object. When rendering is
2797         directed to the drawing buffer, making any of the 3 rendering calls shall 
2798         cause the drawing buffer to be presented to the HTML page compositor at the start
2799         of the next compositing operation.
2800     </p>
2801      
2802     <dl class="methods">
2803         <dt class="idl-code">void clear(GLbitfield mask)
2804             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 &sect;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>
2805         <dt class="idl-code">void drawArrays(GLenum mode, GLint first, GLsizei count)
2806             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawArrays.xml">man page</a>)</span>
2807             <dd>
2808             If <em>first</em> is negative, an <code>INVALID_VALUE</code> error will be generated.
2809         <dt class="idl-code">void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset)
2810             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawElements.xml">man page</a>)</span>
2811         <dd>
2812             Draw using the currently bound element array buffer.  The given offset is in bytes, and
2813             must be a valid multiple of the size of the given type or an <code>INVALID_OPERATION</code>
2814             error will be generated; see <a href="#BUFFER_OFFSET_AND_STRIDE">Buffer Offset and Stride
2815             Requirements</a>. If <code>count</code> is greater than zero, then a non-null
2816             <code>WebGLBuffer</code> must be bound to the <code>ELEMENT_ARRAY_BUFFER</code> binding
2817             point or an <code>INVALID_OPERATION</code> error will be generated.<br><br>
2818
2819             WebGL performs additional error checking beyond that specified in OpenGL ES 2.0 during
2820             calls to <code>drawArrays</code>
2821             and <code>drawElements</code>. See <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex
2822             Attributes and Range Checking</a>.
2823         <dt class="idl-code">void finish()
2824             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-5.1">OpenGL ES 2.0 &sect;5.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFinish.xml">man page</a>)</span>
2825         <dt class="idl-code">void flush()
2826             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-5.1">OpenGL ES 2.0 &sect;5.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFlush.xml">man page</a>)</span>
2827     </dl>
2828
2829 <!-- ======================================================================================================= -->
2830
2831     <h4><a name="readpixels">Reading back pixels</a></h4>
2832
2833     <p>
2834         Pixels in the current framebuffer can be read back into an ArrayBufferView object.
2835     </p>
2836
2837     <dl class="methods">
2838         <dt class="idl-code">void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, 
2839                            GLenum format, GLenum type, ArrayBufferView? pixels)
2840             <span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.3.1">OpenGL ES 2.0 &sect;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>
2841         <dd>
2842             Fills <code>pixels</code> with the pixel data in the specified rectangle of the frame
2843             buffer. The data returned from readPixels must be up-to-date as of the most recently
2844             sent drawing command.
2845             <br><br>
2846
2847             The type of <code>pixels</code> must match the type of the data to be read. For example,
2848             if it is UNSIGNED_BYTE, a Uint8Array must be supplied; if it is UNSIGNED_SHORT_5_6_5,
2849             UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_SHORT_5_5_5_1, a Uint16Array must be supplied. If
2850             the types do not match, an INVALID_OPERATION error is generated.
2851             <br><br>
2852
2853             The following are the allowed format and type combinations:
2854
2855             <table class="foo">
2856               <tr><th>format</th><th>type</th></tr>
2857               <tr><td>RGBA</td><td>UNSIGNED_BYTE</td></tr>
2858             </table>
2859
2860             If <code>pixels</code> is null, an INVALID_VALUE error is generated. If
2861             <code>pixels</code> is non-null, but is not large enough to retrieve all of the pixels
2862             in the specified rectangle taking into account pixel store modes, an INVALID_OPERATION
2863             error is generated.
2864             <br><br>
2865
2866             For any pixel lying outside the frame buffer, the value read contains 0 in all channels;
2867             see <a href="#READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the Framebuffer</a>.
2868             <br><br>
2869
2870     </dl>
2871     
2872 <!-- ======================================================================================================= -->
2873
2874     <h4>Detecting context lost events</h4>
2875
2876     <p>
2877         Occurrences such as power events on mobile devices may cause the WebGL rendering context to
2878         be lost at any time and require the application to rebuild it;
2879         see <a href="#WEBGLCONTEXTEVENT">WebGLContextEvent</a> for more details. The
2880         following method assists in detecting context lost events.
2881     </p>
2882
2883     <dl class="methods">
2884         <dt class="idl-code">[WebGLHandlesContextLoss] boolean isContextLost()
2885         <dd>
2886             Return true if the <a href="#webgl-context-lost-flag">webgl context lost flag</a> is
2887             set, otherwise return false.
2888     </dl>
2889     
2890 <!-- ======================================================================================================= -->
2891
2892     <h4>Detecting and enabling extensions</h4>
2893
2894     <p>
2895         An implementation of WebGL must not support any additional parameters, constants or functions
2896         without first enabling that functionality through the extension mechanism. The 
2897         <code>getSupportedExtensions</code> function returns an array of the extension strings
2898         supported by this implementation. An extension is enabled by passing one of those strings to
2899         the <code>getExtension</code> function. This call returns an object which contains any
2900         constants or functions defined by that extension. The definition of that object is specific
2901         to the extension and must be defined by the extension specification.
2902     </p>
2903     <p>
2904         Once an extension is enabled, no mechanism is provided to disable it. Multiple calls to
2905         <code>getExtension</code> with the same extension string, taking into account
2906         case-insensitive comparison, shall return the same object. An attempt to use any features of
2907         an extension without first calling getExtension to enable it must generate an appropriate GL
2908         error and must not make use of the feature.
2909     </p>
2910     <p>
2911         This specification does not define any extensions. A separate <a href="#refsREGISTRY">WebGL
2912         extension registry</a> defines extensions that may be supported by a particular WebGL
2913         implementation.
2914     </p>
2915
2916     <dl class="methods">
2917         <dt class="idl-code">sequence&lt;DOMString&gt;? getSupportedExtensions()
2918         <dd>
2919             Returns a list of all the supported extension strings.
2920             
2921         <dt class="idl-code">object? getExtension(DOMString name)
2922         <dd>
2923             Returns an object if, and only if, <em>name</em> is
2924             an <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#ascii-case-insensitive">ASCII
2925             case-insensitive match</a> <a href="#refsHTML">[HTML]</a> for one of the names returned
2926             from <code>getSupportedExtensions</code>; otherwise, returns <code>null</code>. The
2927             object returned from <code>getExtension</code> contains any constants or functions
2928             provided by the extension. A returned object may have no constants or functions if the
2929             extension does not define any, but a unique object must still be returned. That object
2930             is used to indicate that the extension has been enabled.
2931     </dl>
2932
2933 <!-- ======================================================================================================= -->
2934
2935     <h3><a name="WEBGLCONTEXTEVENT">WebGLContextEvent</a></h3>
2936
2937     <p>
2938         WebGL generates a <code>WebGLContextEvent</code> event in response to a status change to the
2939         WebGL rendering context associated with the HTMLCanvasElement which has a listener for this
2940         event. Events are sent using the DOM Event
2941         System <a href="#refsDOM3EVENTS">[DOM3EVENTS]</a>. Event types can include the loss or
2942         restoration of state, or the inability to create a context.
2943         <a href="http://www.w3.org/TR/domcore/#eventinit">EventInit</a> is defined in the DOM4
2944         specification <a href="#refsDOM4">[DOM4]</a>.
2945     </p>
2946         To <b><a name="fire-a-webgl-context-event">fire a WebGL context event named e</a></b> means that
2947         an <a href="http://www.w3.org/TR/domcore/#concept-event">event</a>
2948         using the <code>WebGLContextEvent</code> interface, with
2949         its <a href="http://www.w3.org/TR/domcore/#dom-event-type"><code>type</code></a>
2950         attribute <a href="#refsDOM4">[DOM4]</a> initialized to <em>e</em>, and
2951         its <a href="http://www.w3.org/TR/domcore/#dom-event-istrusted"><code>isTrusted</code></a>
2952         attribute <a href="#refsDOM4">[DOM4]</a> initialized to true, is to
2953         be <a href="http://www.w3.org/TR/domcore/#concept-event-dispatch">dispatched</a>
2954         at the given object.
2955     <p>
2956     </p>
2957     <pre class="idl">
2958 [Constructor(DOMString type, optional WebGLContextEventInit eventInit)]
2959 interface <dfn id="WebGLContextLostEvent">WebGLContextEvent</dfn> : <a href="http://www.w3.org/TR/domcore/#event">Event</a> {
2960     readonly attribute DOMString statusMessage;
2961 };
2962
2963 // EventInit is defined in the DOM4 specification.
2964 dictionary WebGLContextEventInit : <a href="http://www.w3.org/TR/domcore/#eventinit">EventInit</a> {
2965     DOMString statusMessage;
2966 };</pre>
2967
2968     <p>
2969     The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#task-source">task
2970     source</a> for
2971     all <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task">tasks</a> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#queue-a-task">queued</a> <a href="#refsHTML">[HTML]</a>
2972     in this section is the <b>WebGL task source</b>.
2973     </p>
2974
2975     <h4>Attributes</h4>
2976
2977     <p>
2978         The following attributes are available:
2979     </p>
2980
2981     <dl class="methods">
2982         <dt><span class="prop-name"><code>statusMessage</code></span> of type <code>DOMString</code>
2983         <dd>
2984             A string containing additional information, or the empty string if no additional information
2985             is available.
2986     </dl>
2987
2988     <h4><a name="CONTEXT_LOST">The Context Lost Event</a></h4>
2989
2990     <p>
2991         When the user agent detects that the <em>drawing buffer</em> associated with
2992         a <code>WebGLRenderingContext</code> <em>context</em> has been lost, it must run the
2993         following steps:
2994
2995         <ol class="nestedlist">
2996
2997         <li> Let <em>canvas</em> be the <em>context's</em>
2998         <a href="#context-canvas">canvas</a>. </li>
2999
3000         <li> If </em>context's</em> <a href="#webgl-context-lost-flag">webgl context lost</a> flag
3001         is set, abort these steps. </li>
3002
3003         <li> Set <em>context's</em> <a href="#webgl-context-lost-flag">webgl context lost</a>
3004         flag. </li>
3005
3006         <li> Set the <a href="#webgl-object-invalidated-flag">invalidated flag</a> of
3007         each <code>WebGLObject</code> instance created by this context. </li>
3008
3009         <li> <a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to
3010         perform the following steps:
3011
3012             <ol class="nestedlist">
3013
3014             <li> <a href="#fire-a-webgl-context-event">Fire a WebGL context event</a> named
3015             "webglcontextlost" at <em>canvas</em>, with its <code>statusMessage</code> attribute set
3016             to "". </li>
3017
3018             <li> If the
3019             event's <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#canceled-flag">canceled
3020             flag</a> is not set, abort these steps. </li>
3021
3022             <li> Perform the following steps asynchronously. </li>
3023
3024             <li> Await a restorable <em>drawing buffer</em>. </li>
3025
3026             <li> Queue a task to <a href="#restore-the-drawing-buffer">restore the drawing
3027             buffer</a> for <em>context</em>. </li>
3028
3029             </ol>
3030
3031         </li>
3032         </ol>
3033     </p>
3034     <div class="example">
3035         The following code prevents the default behavior of the <code>webglcontextlost</code>
3036         event and enables the <code>webglcontextrestored</code> event to be delivered:
3037     <pre>canvas.addEventListener("webglcontextlost", function(e) { e.preventDefault(); }, false); </pre>
3038     </div>
3039
3040     <h4>The Context Restored Event</h4>
3041
3042     <p>
3043
3044         When the user agent is to <b><a name="restore-the-drawing-buffer">restore the drawing
3045         buffer</a></b> for a <code>WebGLRenderingContext</code> <em>context</em>, it must run the
3046         following steps:
3047
3048         <ol class="nestedlist">
3049
3050         <li> Let <em>canvas</em> be the canvas object associated with <em>context</em>.
3051
3052         <li> If <em>context's</em> <a href="#webgl-context-lost-flag">webgl context lost flag</a> is
3053         not set, abort these steps.
3054
3055         <li> <a href="#create-a-drawing-buffer">Create a <em>drawing buffer</em></a> using the
3056         settings specified in <em>context's</em> <a href="#context-creation-parameters">context
3057         creation parameters</a>, and associate the <em>drawing buffer</em> with <em>context</em>,
3058         discarding any previous <em>drawing buffer</em>.
3059
3060         <li> Clear <em>context's</em> <a href="#webgl-context-lost-flag">webgl context lost
3061         flag</a>.
3062
3063         <li> Reset <em>context's</em> OpenGL error state.
3064
3065         <li> <a href="#fire-a-webgl-context-event">Fire a WebGL context event</a> named
3066         "webglcontextrestored" at <em>canvas</em>, with its <code>statusMessage</code> attribute set
3067         to "".
3068
3069         </ol>
3070
3071     </p>
3072
3073     <div class="note"> 
3074         Once the context is restored, WebGL resources such as textures and buffers that were created
3075         before the context was lost are no longer valid. The application needs to reinitialize the
3076         context's state and recreate all such resources.
3077     </div>
3078
3079     <div class="example">
3080         The following code illustrates how an application can handle context loss and restoration:
3081 <pre>function initializeGame() {
3082   initializeWorld();
3083   initializeResources();
3084 }
3085
3086 function initializeResources() {
3087   initializeShaders();
3088   initializeBuffers();
3089   initializeTextures();
3090
3091   // ready to draw, start the main loop
3092   renderFrame();
3093 }
3094
3095 function renderFrame() {
3096   updateWorld();
3097   drawSkyBox();
3098   drawWalls();
3099   drawMonsters();
3100
3101   requestId = window.requestAnimationFrame(
3102       renderFrame, canvas);
3103 }
3104
3105 canvas.addEventListener(
3106     "webglcontextlost", function (event) {
3107
3108   // inform WebGL that we handle context restoration
3109   event.preventDefault();
3110
3111   // Stop rendering
3112   window.cancelAnimationFrame(requestId);
3113 }, false);
3114
3115 canvas.addEventListener(
3116     "webglcontextrestored", function (event) {
3117
3118   initializeResources();
3119 }, false);
3120
3121 initializeGame();</pre>
3122     </div>
3123
3124     <h4>The Context Creation Error Event</h4>
3125
3126     <p>
3127         When the user agent is to <b><a name="fire-a-webgl-context-creation-error">fire a WebGL
3128         context creation error</a></b> at a <em>canvas</em>, it must perform the following steps:
3129
3130         <ol class="nestedlist">
3131
3132         <li> <a href="#fire-a-webgl-context-event">Fire a WebGL context event</a> named
3133         "webglcontextcreationerror" at <em>canvas</em>, optionally with its <code>statusMessage</code>
3134         attribute set to a platform dependent string about the nature of the failure. </li>
3135
3136         </ol>
3137
3138     </p>
3139
3140     <div class="example">
3141
3142         The following code illustrates how an application can retrieve information about context creation failure:
3143
3144 <pre>var errorInfo = "";
3145 function onContextCreationError(event) {
3146
3147   canvas.removeEventListener(
3148      "webglcontextcreationerror",
3149      onContextCreationError, false);
3150
3151   errorInfo = e.statusMessage || "Unknown";
3152 }
3153
3154 canvas.addEventListener(
3155     "webglcontextcreationerror",
3156     onContextCreationError, false);
3157
3158 var gl = canvas.getContext("experimental-webgl");
3159 if(!gl) {
3160   alert("A WebGL context could not be created.\nReason: " +
3161         errorInfo);
3162 }</pre>
3163     </div>
3164
3165 <!-- ======================================================================================================= -->
3166
3167     <h2><a name="webgl_gl_differences">Differences Between WebGL and OpenGL ES 2.0</a></h2>
3168     
3169 <p>
3170
3171 This section describes changes made to the WebGL API relative to the OpenGL ES 2.0 API to improve
3172 portability across various operating systems and devices.
3173
3174 </p>
3175
3176     <h3><a name="BUFFER_OBJECT_BINDING">Buffer Object Binding</a></h3>
3177
3178 <p>
3179
3180 In the WebGL API, a given buffer object may only be bound to one of the <code>ARRAY_BUFFER</code> or
3181 <code>ELEMENT_ARRAY_BUFFER</code> binding points in its lifetime. This restriction implies that a
3182 given buffer object may contain either vertices or indices, but not both.
3183
3184 </p>
3185 <p>
3186
3187 The type of a WebGLBuffer is initialized the first time it is passed as an argument
3188 to <code>bindBuffer</code>. A subsequent call to <code>bindBuffer</code> which attempts to bind the
3189 same WebGLBuffer to the other binding point will generate an <code>INVALID_OPERATION</code> error, and
3190 the state of the binding point will remain untouched.
3191
3192 </p>
3193
3194     <h3>No Client Side Arrays</h3>
3195
3196 <p>
3197
3198 The WebGL API does not support client-side arrays. If <code>vertexAttribPointer</code> is called
3199 without a <code>WebGLBuffer</code> bound to the <code>ARRAY_BUFFER</code> binding point,
3200 an <code>INVALID_OPERATION</code> error is generated. If <code>drawElements</code> is called with
3201 a <code>count</code> greater than zero, and no <code>WebGLBuffer</code> is bound to
3202 the <code>ELEMENT_ARRAY_BUFFER</code> binding point, an <code>INVALID_OPERATION</code> error is
3203 generated.
3204
3205 </p>
3206
3207     <h3>No Default Textures</h3>
3208
3209 <p>
3210
3211 The WebGL API does not support default textures. A non-null <code>WebGLTexture</code> object must be
3212 bound in order for texture-related operations and queries to succeed.
3213
3214 </p>
3215
3216     <h3><a name="BUFFER_OFFSET_AND_STRIDE">Buffer Offset and Stride Requirements</a></h3>
3217
3218 <p>
3219
3220 The <code>offset</code> arguments to <code>drawElements</code> and <code>vertexAttribPointer</code>,
3221 and the <code>stride</code> argument to <code>vertexAttribPointer</code>, must be a multiple of the
3222 size of the data type passed to the call, or an <code>INVALID_OPERATION</code> error is generated.
3223
3224 </p>
3225
3226
3227     <h3><a name="ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex Attributes and Range Checking</a></h3>
3228
3229 <p>
3230
3231 If a vertex attribute is enabled as an array via <code>enableVertexAttribArray</code> but no buffer
3232 is bound to that attribute via <code>bindBuffer</code> and <code>vertexAttribPointer</code>, then
3233 calls to <code>drawArrays</code> or <code>drawElements</code> will generate an
3234 <code>INVALID_OPERATION</code> error.
3235
3236 </p>
3237 <p>
3238
3239 If a vertex attribute is enabled as an array, a buffer is bound to that attribute, and the attribute
3240 is consumed by the current program, then calls to <code>drawArrays</code>
3241 and <code>drawElements</code> will verify that each referenced vertex lies within the storage of the
3242 bound buffer. If the range specified in <code>drawArrays</code> or any referenced index
3243 in <code>drawElements</code> lies outside the storage of the bound buffer, an INVALID_OPERATION
3244 error is generated and no geometry is drawn.
3245
3246 </p>
3247 <p>
3248
3249 If a vertex attribute is enabled as an array, a buffer is bound to that attribute, but the attribute
3250 is not consumed by the current program, then regardless of the size of the bound buffer, it will not
3251 cause any error to be generated during a call to <code>drawArrays</code>
3252 or <code>drawElements</code>.
3253
3254 </p>
3255
3256     <h3><a name="FBO_ATTACHMENTS">Framebuffer Object Attachments</a></h3>
3257
3258 <p>
3259
3260 WebGL adds the <code>DEPTH_STENCIL_ATTACHMENT</code> framebuffer object attachment point and
3261 the <code>DEPTH_STENCIL</code> renderbuffer internal format. To attach both depth and stencil
3262 buffers to a framebuffer object, call <code>renderbufferStorage</code> with
3263 the <code>DEPTH_STENCIL</code> internal format, and then call <code>framebufferRenderbuffer</code>
3264 with the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point.
3265
3266 </p>
3267 <p>
3268
3269 A renderbuffer attached to the <code>DEPTH_ATTACHMENT</code> attachment point must be allocated with
3270 the <code>DEPTH_COMPONENT16</code> internal format. A renderbuffer attached to
3271 the <code>STENCIL_ATTACHMENT</code> attachment point must be allocated with
3272 the <code>STENCIL_INDEX8</code> internal format. A renderbuffer attached to
3273 the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point must be allocated with
3274 the <code>DEPTH_STENCIL</code> internal format.
3275
3276 </p>
3277 <p>
3278
3279 In the WebGL API, it is an error to concurrently attach renderbuffers to the following combinations
3280 of attachment points:
3281
3282 <ul>
3283 <li> <code>DEPTH_ATTACHMENT + DEPTH_STENCIL_ATTACHMENT</code>
3284 <li> <code>STENCIL_ATTACHMENT + DEPTH_STENCIL_ATTACHMENT</code>
3285 <li> <code>DEPTH_ATTACHMENT + STENCIL_ATTACHMENT</code>
3286 </ul>
3287
3288 If any of the constraints above are violated, then:
3289
3290 <ul>
3291 <li> <code>checkFramebufferStatus</code> must return <code>FRAMEBUFFER_UNSUPPORTED</code>.
3292 <li> The following calls, which either modify or read the framebuffer, must generate
3293      an <code>INVALID_FRAMEBUFFER_OPERATION</code> error and return early, leaving the contents of
3294      the framebuffer, destination texture or destination memory untouched.
3295   <ul>
3296   <li> clear
3297   <li> copyTexImage2D
3298   <li> copyTexSubImage2D
3299   <li> drawArrays
3300   <li> drawElements
3301   <li> readPixels
3302   </ul>
3303 </ul>
3304
3305 The following combinations of framebuffer object attachments, when all of the attachments are
3306 framebuffer attachment complete, non-zero, and have the same width and height, must result in the
3307 framebuffer being framebuffer complete:
3308
3309 <ul>
3310 <li> <code>COLOR_ATTACHMENT0</code> = <code>RGBA/UNSIGNED_BYTE</code> texture
3311 <li> <code>COLOR_ATTACHMENT0</code> = <code>RGBA/UNSIGNED_BYTE</code> texture + <code>DEPTH_ATTACHMENT</code> = <code>DEPTH_COMPONENT16</code> renderbuffer
3312 <li> <code>COLOR_ATTACHMENT0</code> = <code>RGBA/UNSIGNED_BYTE</code> texture + <code>DEPTH_STENCIL_ATTACHMENT</code> = <code>DEPTH_STENCIL</code> renderbuffer
3313 </ul>
3314
3315 <h3><a name="PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a></h3>
3316
3317 <p>
3318 The WebGL API supports the following additional parameters to <code>pixelStorei</code>.
3319
3320 <dl>
3321 <dt><code>UNPACK_FLIP_Y_WEBGL</code> of type <code>boolean</code>
3322 <dd>If set, then during any subsequent calls to <code>texImage2D</code> or
3323 <code>texSubImage2D</code>, the source data is flipped along the vertical axis, so that conceptually
3324 the last row is the first one transferred. The initial value is <code>false</code>. Any non-zero
3325 value is interpreted as <code>true</code>.
3326
3327 <dt><code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> of type <code>boolean</code>
3328 <dd>If set, then during any subsequent calls to <code>texImage2D</code>
3329 or <code>texSubImage2D</code>, the alpha channel of the source data, if present, is multiplied into
3330 the color channels during the data transfer. The initial value is <code>false</code>. Any non-zero
3331 value is interpreted as <code>true</code>.
3332
3333 <dt><code>UNPACK_COLORSPACE_CONVERSION_WEBGL</code> of type <code>unsigned long</code>
3334 <dd>If set to <code>BROWSER_DEFAULT_WEBGL</code>, then the browser's default colorspace conversion
3335 is applied during subsequent <code>texImage2D</code> and <code>texSubImage2D</code> calls
3336 taking <code>HTMLImageElement</code>. The precise conversions may be specific to both the browser
3337 and file type. If set to <code>NONE</code>, no colorspace conversion is applied. The initial value
3338 is <code>BROWSER_DEFAULT_WEBGL</code>.
3339
3340 </dl>
3341
3342 <h3><a name="READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the Framebuffer</a></h3>
3343
3344 <p>
3345 In the WebGL API, functions which read the framebuffer
3346 (<code>copyTexImage2D</code>, <code>copyTexSubImage2D</code>, and <code>readPixels</code>) are
3347 defined to generate the RGBA value (0, 0, 0, 0) for any pixel which is outside of the bound
3348 framebuffer.
3349 </p>
3350
3351 <h3><a name="STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and Reference Value</a></h3>
3352
3353 <p>
3354 In the WebGL API it is illegal to specify a different mask or reference value for front facing and
3355 back facing triangles in stencil operations. A call to <code>drawArrays</code>
3356 or <code>drawElements</code> will generate an <code>INVALID_OPERATION</code> error if:
3357
3358 <ul>
3359 <li> <code>STENCIL_WRITEMASK</code> != <code>STENCIL_BACK_WRITEMASK</code> (as specified by <code>stencilMaskSeparate</code> for the <code>mask</code> parameter associated with the FRONT and BACK values of <code>face</code>, respectively)
3360 <li> <code>STENCIL_VALUE_MASK</code> != <code>STENCIL_BACK_VALUE_MASK</code> (as specified by <code>stencilFuncSeparate</code> for the <code>mask</code> parameter associated with the FRONT and BACK values of <code>face</code>, respectively)
3361 <li> <code>STENCIL_REF</code> != <code>STENCIL_BACK_REF</code> (as specified by <code>stencilFuncSeparate</code> for the <code>ref</code> parameter associated with the FRONT and BACK values of <code>face</code>, respectively)
3362 </ul>
3363
3364 </p>
3365
3366     <h3><a name="VERTEX_STRIDE">Vertex Attribute Data Stride</a></h3>
3367
3368 <p>
3369 The WebGL API supports vertex attribute data strides up to 255 bytes. A call to
3370 <code>vertexAttribPointer</code> will generate an <code>INVALID_VALUE</code> error if the value for
3371 the stride parameter exceeds 255.
3372 </p>
3373
3374     <h3><a name="VIEWPORT_DEPTH_RANGE">Viewport Depth Range</a></h3>
3375
3376 <p>
3377 The WebGL API does not support depth ranges with where the near plane is mapped to a value greater
3378 than that of the far plane. A call to <code>depthRange</code> will generate an
3379 <code>INVALID_OPERATION</code> error if <code>zNear</code> is greater than <code>zFar</code>.
3380 </p>
3381
3382     <h3><a name="CONSTANT_COLOR_BLEND">Blending With Constant Color</a></h3>
3383
3384 <p>
3385 In the WebGL API, constant color and constant alpha cannot be used together as source and
3386 destination factors in the blend function. A call to <code>blendFunc</code> will generate an
3387 <code>INVALID_OPERATION</code> error if one of the two factors is set to <code>CONSTANT_COLOR</code>
3388 or <code>ONE_MINUS_CONSTANT_COLOR</code> and the other to <code>CONSTANT_ALPHA</code> or
3389 <code>ONE_MINUS_CONSTANT_ALPHA</code>. A call to <code>blendFuncSeparate</code> will generate an
3390 <code>INVALID_OPERATION</code> error if <code>srcRGB</code> is set to <code>CONSTANT_COLOR</code>
3391 or <code>ONE_MINUS_CONSTANT_COLOR</code> and <code>dstRGB</code> is set to <code>CONSTANT_ALPHA</code> or
3392 <code>ONE_MINUS_CONSTANT_ALPHA</code> or vice versa.
3393 </p>
3394
3395     <h3>Fixed point support</h3>
3396
3397 The WebGL API does not support the <code>GL_FIXED</code> data type.
3398
3399     <h3><a name="GLSL_CONSTRUCTS">GLSL Constructs</a></h3>
3400
3401 <p>
3402 Per <a href="#SUPPORTED_GLSL_CONSTRUCTS">Supported GLSL Constructs</a>, identifiers starting with
3403 "webgl_" and "_webgl_" are reserved for use by WebGL.
3404 </p>
3405
3406     <h3><a name="EXTENSION_QUERIES">Extension Queries</a></h3>
3407
3408 <p>
3409
3410 In the OpenGL ES 2.0 API, the available extensions are determined by calling
3411 <code>glGetString(GL_EXTENSIONS)</code>, which returns a space-separated list of extension strings.
3412 In the WebGL API, the <code>EXTENSIONS</code> enumerant has been removed.
3413 Instead, <code>getSupportedExtensions</code> must be called to determine the set of available
3414 extensions.
3415
3416 </p>
3417
3418     <h3><a name="IMPLEMENTATION_READ_FORMAT">Implementation Color Read Format and Type</a></h3>
3419
3420 <p>
3421
3422     In the OpenGL ES 2.0 API, the
3423     <code>IMPLEMENTATION_COLOR_READ_FORMAT</code> and
3424     <code>IMPLEMENTATION_COLOR_READ_TYPE</code> parameters are used to inform applications of an
3425     additional format and type combination that may be passed to <code>ReadPixels</code>, in
3426     addition to the required <ncode>RGBA</code>/<code>UNSIGNED_BYTE</code> pair.  In WebGL 1.0,
3427     the supported format and type combinations to <code>ReadPixels</code> are documented in the
3428     <a href="#readpixels">Reading back pixels</a> section.  The <code>IMPLEMENTATION_COLOR_READ_FORMAT</code>
3429     and <code>IMPLEMENTATION_COLOR_READ_TYPE</code> enumerants have been removed.
3430 </p>
3431
3432     <h3><a name="COMPRESSED_TEXTURE_SUPPORT">Compressed Texture Support</a></h3>
3433
3434 <p>
3435     The core WebGL specification does not define any supported compressed texture formats.
3436     Therefore, in the absence of any other extensions being enabled:
3437
3438     <ul>
3439
3440       <li> The <a href="#COMPRESSEDTEXIMAGE2D"><code>compressedTexImage2D</code></a>
3441            and <a href="#COMPRESSEDTEXSUBIMAGE2D"><code>compressedTexSubImage2D</code></a> methods
3442            generate an <code>INVALID_ENUM</code> error. </li>
3443
3444       <li> Calling <a href="#GETPARAMETER"><code>getParameter</code></a> with the
3445            argument <code>COMPRESSED_TEXTURE_FORMATS</code> returns a zero-length array (of
3446            type <code>Uint32Array</code>). </li>
3447
3448     </ul>
3449 </p>
3450
3451     <h3><a name="MAX_GLSL_TOKEN_SIZE">Maximum GLSL Token Size</a></h3>
3452
3453 <p>
3454     The GLSL ES spec <a href="#refsGLES20GLSL">[GLES20GLSL]</a> does not define a limit to the
3455     length of tokens. WebGL requires support of tokens up to 256 characters in length. Shaders
3456     containing tokens longer than 256 characters must fail to compile.
3457 </p>
3458
3459     <h3><a name="CHARACTERS_OUTSIDE_VALID_SET">Characters Outside the GLSL Source Character Set</a></h3>
3460
3461 <p>
3462     The GLSL ES spec <a href="#refsGLES20GLSL">[GLES20GLSL]</a> defines the source character set for
3463     the OpenGL ES shading language to be ISO/IEC 646:1991, commonly called ASCII <a href="#refsASCII">[ASCII]</a>. 
3464     If a string containing a character not in this set is passed to any of the shader-related entry
3465     points <code>bindAttribLocation</code>, <code>getAttribLocation</code>, <code>getUniformLocation</code>,
3466     or <code>shaderSource</code>, an <code>INVALID_VALUE</code> error will be generated. The exception is
3467     that any character allowed in an HTML DOMString <a href="#refsDOMSTRING">[DOMSTRING]</a> may be used
3468     in GLSL comments. Such use must not generate an error.
3469 </p>
3470
3471 <div class="note">        
3472     <p>
3473         Some GLSL implementations disallow characters outside the ASCII range, even in comments. The
3474         WebGL implementation needs to prevent errors in such cases. The recommended technique is to
3475         preprocess the GLSL string, removing all comments, but maintaining the line numbering for
3476         debugging purposes by inserting newline characters as needed. 
3477     </p>
3478 </div>
3479     
3480     <h3><a name="MAX_STRUCT_NESTING">Maximum Nesting of Structures in GLSL Shaders</a></h3>
3481
3482 <p>
3483     WebGL imposes a limit on the nesting of structures in GLSL shaders. Nesting occurs when a field
3484     in a struct refers to another struct type; the GLSL ES
3485     spec <a href="#refsGLES20GLSL">[GLES20GLSL]</a> forbids embedded structure definitions. The
3486     fields in a top-level struct definition have a nesting level of 1.
3487 </p>
3488 <p>
3489     WebGL requires support of a structure nesting level of 4. Shaders containing structures nested
3490     more than 4 levels deep must fail to compile.
3491 </p>
3492
3493     <h3><a name="MAX_LOCATION_LENGTHS">Maximum Uniform and Attribute Location Lengths</a></h3>
3494
3495 <p>
3496     WebGL imposes a limit of 256 characters on the lengths of uniform and attribute locations.
3497 </p>
3498
3499     <h3>String Length Queries</h3>
3500
3501 <p>
3502     In the WebGL API, the enumerants <code>INFO_LOG_LENGTH</code>, <code>SHADER_SOURCE_LENGTH</code>,
3503     <code>ACTIVE_UNIFORM_MAX_LENGTH</code>, and <code>ACTIVE_ATTRIB_MAX_LENGTH</code> have been removed. In
3504     the OpenGL ES 2.0 API, these enumerants are needed to determine the size of buffers passed to calls
3505     like <code>glGetActiveAttrib</code>. In the WebGL API, the analogous calls (<code>getActiveAttrib</code>,
3506     <code>getActiveUniform</code>, <code>getProgramInfoLog</code>, <code>getShaderInfoLog</code>, and
3507     <code>getShaderSource</code>) all return <code>DOMString</code>.
3508 </p>
3509
3510 <h3>Texture Type in TexSubImage2D Calls</h3>
3511
3512 <p>
3513     In the WebGL API, the <em>type</em> argument passed to <code>texSubImage2D</code> must match the
3514     type used to originally define the texture object (i.e., using <code>texImage2D</code>).
3515 </p>
3516
3517     <h3><a name="PACKING_RESTRICTIONS">Packing Restrictions for Uniforms and Varyings</a></h3>
3518
3519 <p>
3520     The OpenGL ES Shading Language, Version 1.00 <a href="#refsGLES20GLSL">[GLES20GLSL]</a>,
3521     Appendix A, Section 7 "Counting of Varyings and Uniforms" defines a conservative algorithm for
3522     computing the storage required for all of the uniform and varying variables in a shader. The
3523     GLSL ES specification requires that if the packing algorithm defined in Appendix A succeeds,
3524     then the shader must succeed compilation on the target platform. The WebGL API further requires
3525     that this packing algorithm succeed for all shaders and programs submitted to the API.
3526 </p>
3527 <p>
3528     Instead of using a fixed size grid of registers, the number of rows in the target architecture
3529     is determined in the following ways:
3530
3531     <ul>
3532     <li> when counting uniform variables in a vertex shader: <code>getParameter(MAX_VERTEX_UNIFORM_VECTORS)</code>
3533     <li> when counting uniform variables in a fragment shader: <code>getParameter(MAX_FRAGMENT_UNIFORM_VECTORS)</code>
3534     <li> when counting varying variables: <code>getParameter(MAX_VARYING_VECTORS)</code>
3535     </ul>
3536 </p>
3537 <p>
3538     If the packing algorithm fails either for the uniform variables of a shader or for the varying
3539     variables of a program, compilation or linking must fail.
3540 </p>
3541
3542
3543 <!-- ======================================================================================================= -->
3544
3545     <h2>References</h2>
3546     
3547     <h3>Normative references</h3>
3548     <dl>
3549     
3550         <dt id="refsCANVAS">[CANVAS]</dt>
3551         <dd><cite><a href="http://www.w3.org/TR/html5/the-canvas-element.html">
3552             HTML5: The Canvas Element</a></cite>,
3553             World Wide Web Consortium (W3C).
3554         </dd>
3555
3556         <dt id="refsCANVASCONTEXTS">[CANVASCONTEXTS]</dt>
3557         <dd><cite><a href="http://wiki.whatwg.org/wiki/CanvasContexts">
3558             Canvas Context Registry</a></cite>,
3559             WHATWG.
3560         </dd>
3561         <dt id="refsTYPEDARRAYS">[TYPEDARRAYS]</dt>
3562         <dd><cite><a href="http://www.khronos.org/registry/typedarray/specs/latest/">
3563             Typed Array Specification: Editor's Draft</a></cite>,
3564             V. Vukicevic, K. Russell, May 2010.
3565         </dd>
3566         <dt id="refsGLES20">[GLES20]</dt>
3567         <dd><cite><a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf">
3568             OpenGL&reg; ES Common Profile Specification Version 2.0.25</a></cite>, 
3569             A. Munshi, J. Leech, November 2010.
3570         </dd>
3571         <dt id="refsGLES20GLSL">[GLES20GLSL]</dt>
3572         <dd><cite><a href="http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf">
3573             The OpenGL&reg; ES Shading Language Version 1.00</a></cite>, 
3574             R. Simpson, May 2009.
3575         </dd>
3576         <dt id="refsREGISTRY">[REGISTRY]</dt>
3577         <dd><cite><a href="http://www.khronos.org/registry/webgl/extensions/">
3578             WebGL Extension Registry</a></cite>
3579         </dd>
3580         <dt id="refsRFC2119">[RFC2119]</dt>
3581         <dd><cite><a href="http://www.ietf.org/rfc/rfc2119.txt">
3582             Key words for use in RFCs to Indicate Requirement Levels</a></cite>,
3583             S. Bradner. IETF, March 1997.
3584         </dd>
3585         <dt id="refsCSS">[CSS]</dt>
3586         <dd><cite><a href="http://www.w3.org/TR/CSS21/">
3587             Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a></cite>,
3588             B. Bos, T. Celik, I. Hickson, H. W. Lie, June 2011.
3589         </dd>
3590         <dt id="refsCORS">[CORS]</dt>
3591         <dd><cite><a href="http://www.w3.org/TR/cors/">
3592             Cross-Origin Resource Sharing</a></cite>,
3593             A. van Kesteren, July 2010.
3594         </dd>
3595         <dt id="refsDOM4">[DOM4]</dt>
3596         <dd><cite><a href="http://www.w3.org/TR/domcore/">
3597             DOM4</a></cite>,
3598             A. van Kesteren, A. Gregor, Ms2ger.
3599         </dd>
3600         <dt id="refsDOM3EVENTS">[DOM3EVENTS]</dt>
3601         <dd><cite><a href="http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html">
3602             Document Object Model (DOM) Level 3 Events Specification</a></cite>,
3603             Doug Schepers and Jacob Rossi. W3C.
3604         </dd>
3605         <dt id="refsHTML">[HTML]</dt>
3606         <dd><cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">
3607             HTML</a></cite>,
3608             I. Hickson, June 2011.
3609         </dd>
3610         <dt id="refsWEBIDL">[WEBIDL]</dt>
3611         <dd><cite><a href="http://dev.w3.org/2006/webapi/WebIDL/">
3612             Web IDL: W3C Editor’s Draft</a></cite>, 
3613             C. McCormack.
3614         </dd>
3615         <dt id="refsASCII">[ASCII]</dt>
3616         <dd><cite>International Standard ISO/IEC 646:1991. Information technology - 
3617             ISO 7-bit coded character set for information interchange</cite>
3618         </dd>
3619         <dt id="refsDOMSTRING">[DOMSTRING]</dt>
3620         <dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#DOMString">
3621             Document Object Model Core: The DOMString type</a></cite>,
3622             World Wide Web Consortium (W3C).
3623         </dd>
3624     </dl>
3625
3626     <h3>Other references</h3>
3627
3628 <!-- ======================================================================================================= -->
3629     
3630     <h2>Acknowledgments</h2>
3631     <p>This specification is produced by the Khronos WebGL Working Group.</p>
3632     
3633     <p>
3634        Special thanks to: Arun Ranganathan (Mozilla), Jon Leech, Kenneth Russell (Google), 
3635        Kenneth Waters (Google), Mark Callow (HI), Mark Steele (Mozilla), Oliver Hunt (Apple), 
3636        Tim Johansson (Opera), Vangelis Kokkevis (Google), Vladimir Vukicevic (Mozilla),
3637        Gregg Tavares (Google)
3638     </p>
3639     <p>
3640         Additional thanks to: Alan Hudson (Yumetech), Bill Licea Kane (AMD), Boris Zbarsky
3641         (Mozilla), Cameron McCormack (Mozilla), Cedric Vivier (Zegami), Dan Gessel (Apple), David
3642         Ligon (Qualcomm), David Sheets (Ashima Arts), Glenn Maynard, Greg Roth (Nvidia), Jacob Strom
3643         (Ericsson), Kari Pulli (Nokia), Teddie Stenvi (ST-Ericsson), Neil Trevett (Nvidia), Per
3644         Wennersten (Ericsson), Per-Erik Brodin (Ericsson), Shiki Okasaka (Google), Tom Olson (ARM),
3645         Zhengrong Yao (Ericsson), and the members of the Khronos WebGL Working Group.
3646 </p>
3647
3648 </body>
3649 </html>