mozilla

Compare Revisions

Using Extensions

Change Revisions

Revision 12086:

Revision 12086 by Sheppy on

Revision 12087:

Revision 12087 by jbuck on

Title:
Using Extensions
Using Extensions
Slug:
WebGL/Using_Extensions
WebGL/Using_Extensions
Tags:
WebGL
WebGL
Content:

Revision 12086
Revision 12087
n7    <h2>n7    <h2 id="The_extension_mechanism">
n16    <h3>n16    <h3 id="Canonical_extension_names_and_vendor_prefixes">
n35    <h3>n35    <h3 id="Querying_available_extensions">
n47    <h3>n47    <h3 id="Enabling_an_extension">
n59    <h3>n59    <h3 id="Extension_objects">
n65    <h2>n65    <h2 id="EXT_texture_filter_anisotropic">
n82    <h3>n82    <h3 id="Example">
tt98    <h2 id="WEBGL_compressed_texture_s3tc">
99      WEBGL_compressed_texture_s3tc
100    </h2>
101    <p>
102      Compressed textures reduce the amount of memory needed to s
 >tore a texture on the GPU, allowing for higher resolution texture
 >s or more of the same resolution textures.
103    </p>
104    <p>
105      The <a class="external" href="http://www.khronos.org/regist
 >ry/webgl/extensions/WEBGL_compressed_texture_s3tc/" title="http:/
 >/www.khronos.org/registry/webgl/extensions/WEBGL_compressed_textu
 >re_s3tc/">extension</a> defines four new texture types:
106    </p>
107    <ul>
108      <li>
109        <code>extension_object.COMPRESSED_RGB_S3TC_DXT1_EXT</code
 >>
110      </li>
111      <li>
112        <code>extension_object.COMPRESSED_RGBA_S3TC_DXT1_EXT</cod
 >e>
113      </li>
114      <li>
115        <code>extension_object.COMPRESSED_RGBA_S3TC_DXT3_EXT</cod
 >e>
116      </li>
117      <li>
118        <code>extension_object.COMPRESSED_RGBA_S3TC_DXT5_EXT</cod
 >e>
119      </li>
120    </ul>
121    <p>
122      These compressed texture formats can be used in two functio
 >ns: compressedTexImage2D and compressedTexSubImage2D.
123    </p>
124    <h3 id="Example">
125      Example
126    </h3>
127    <pre class="brush: js">
128var ext = (
129  gl.getExtension("WEBGL_compressed_texture_s3tc") ||
130  gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") ||
131  gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc")
132);
133var texture = gl.createTexture();
134gl.bindTexture(gl.TEXTURE_2D, texture);
135gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ext.COMPRESSED_RGBA_S3T
 >C_DXT5_EXT, 512, 512, 0, textureData); 
136gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
 >;
137gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_
 >MIPMAP_NEAREST);
138gl.generateMipmap(gl.TEXTURE_2D);
139</pre>

Back to History