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