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