Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for EXT_texture_norm16 #187

Merged
merged 2 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions files/en-us/web/api/ext_texture_norm16/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: EXT_texture_norm16
slug: Web/API/EXT_texture_norm16
tags:
- API
- Reference
- WebGL
- WebGL extension
---
<div>{{APIRef("WebGL")}}</div>

<p>The <code><strong>EXT_texture_norm16</strong></code> extension is part of the <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> and provides a set of new 16-bit signed normalized and unsigned normalized formats (fixed-point texture, renderbuffer and texture buffer).</p>

<p>When this extension is enabled:</p>
<ul>
<li>The {{domxref("WebGLRenderingContext.texImage2D()")}} and {{domxref("WebGLRenderingContext.texSubImage2D()")}} methods accept new formats provided by this extension.</li>
<li>The 16-bit normalized fixed-point types <code>ext.R16_EXT</code>, <code>ext.RG16_EXT</code> and <code>ext.RGBA16_EXT</code> become available as color-renderable formats and renderbuffers and be created in these formats.</li>
</ul>

<p>WebGL extensions are available using the {{domxref("WebGLRenderingContext.getExtension()")}} method. For more information, see also <a href="/en-US/docs/Web/API/WebGL_API/Using_Extensions">Using Extensions</a> in the <a href="/en-US/docs/Web/API/WebGL_API/Tutorial">WebGL tutorial</a>.</p>

<div class="note">
<p><strong>Availability:</strong> This extension is only available to {{domxref("WebGL2RenderingContext", "WebGL 2", "", 1)}} contexts.</p>
</div>

<h2 id="Constants">Constants</h2>

<dl>
<dt><code>ext.R16_EXT</code></dt>
<dd>Red 16-bit unsigned format. Color-renderable.</dd>
<dt><code>ext.RG16_EXT</code></dt>
<dd>RG 16-bit unsigned format. Color-renderable.</dd>
<dt><code>ext.RGB16_EXT</code></dt>
<dd>RGB 16-bit unsigned format.</dd>
<dt><code>ext.RGBA16_EXT</code></dt>
<dd>RGBA 16-bit unsigned format. Color-renderable.</dd>
<dt><code>ext.R16_SNORM_EXT</code></dt>
<dd>Red 16-bit signed normalized format.</dd>
<dt><code>ext.RG16_SNORM__EXT</code></dt>
<dd>RG 16-bit signed normalized format.</dd>
<dt><code>ext.RGB16_SNORM__EXT</code></dt>
<dd>RGB 16-bit signed normalized format.</dd>
<dt><code>ext.RGBA16_SNORM__EXT</code></dt>
<dd>RGBA 16-bit signed normalized format.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3>Enabling the extension</h3>
<pre class="brush:js">
let ext = gl.getExtension('EXT_texture_norm16');
</pre>

<h3>Texture formats</h3>

<p>The {{domxref("WebGLRenderingContext.texImage2D()")}} method accepts new formats when <code>EXT_texture_norm16</code> is enabled. Example calls:</p>

<pre class="brush:js">
// imageData = Uint16Array
gl.texImage2D(gl.TEXTURE_2D, 0, ext.R16_EXT, 1, 1, 0, gl.RED, gl.UNSIGNED_SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RG16_EXT, 1, 1, 0, gl.RG, gl.UNSIGNED_SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RGB16_EXT, 1, 1, 0, gl.RGB, gl.UNSIGNED_SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RGBA16_EXT, 1, 1, 0, gl.RGBA, gl.UNSIGNED_SHORT, imageData);

// imageData = Int16Array
gl.texImage2D(gl.TEXTURE_2D, 0, ext.R16_SNORM_EXT, 1, 1, 0, gl.RED, gl.SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RG16_SNORM_EXT, 1, 1, 0, gl.RG, gl.SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RGB16_SNORM_EXT, 1, 1, 0, gl.RGB, gl.SHORT, imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.RGBA16_SNORM_EXT, 1, 1, 0, gl.RGBA, gl.SHORT, imageData);
</pre>

<h3>Renderbuffer formats</h3>

<p>The {{domxref("WebGLRenderingContext.renderbufferStorage()")}} method accepts <code>ext.R16_EXT</code>,
<code>ext.RG16_EXT</code> and <code>ext.RGBA16_EXT</code> as internal formats to create renderbuffers in these formats. Example calls:</p>

<pre class="brush:js">
gl.renderbufferStorage(gl.RENDERBUFFER, ext.R16_EXT, 1, 1);
gl.renderbufferStorage(gl.RENDERBUFFER, ext.RG16_EXT, 1, 1);
gl.renderbufferStorage(gl.RENDERBUFFER, ext.RGBA16_EXT, 1, 1);
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
</tr>
<tr>
<td>{{SpecName('EXT_texture_norm16', "", "EXT_texture_norm16")}}</td>
</tr>
</tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat("api.EXT_texture_norm16")}}</p>

<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("WebGLRenderingContext.getExtension()")}}</li>
<li>{{domxref("WebGLRenderingContext.texImage2D()")}}</li>
<li>{{domxref("WebGLRenderingContext.renderbufferStorage()")}}</li>
</ul>
1 change: 1 addition & 0 deletions files/en-us/web/api/webgl_api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h3 id="Extensions">Extensions</h3>
<li>{{domxref("EXT_texture_compression_bptc")}}</li>
<li>{{domxref("EXT_texture_compression_rgtc")}}</li>
<li>{{domxref("EXT_texture_filter_anisotropic")}}</li>
<li>{{domxref("EXT_texture_norm16")}}</li>
<li>{{domxref("KHR_parallel_shader_compile")}}</li>
<li>{{domxref("OES_element_index_uint")}}</li>
<li>{{domxref("OES_fbo_render_mipmap")}}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ <h2 id="See_also">See also</h2>
<li>{{domxref("WEBGL_color_buffer_float")}}</li>
<li>{{domxref("EXT_sRGB")}}</li>
<li>{{domxref("EXT_color_buffer_float")}}</li>
<li>{{domxref("EXT_texture_norm16")}}</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -876,5 +876,6 @@ <h2 id="See_also">See also</h2>
<li>{{domxref("WEBGL_depth_texture")}}</li>
<li>{{domxref("OES_texture_float")}}</li>
<li>{{domxref("OES_texture_half_float")}}</li>
<li>{{domxref("EXT_texture_norm16")}}</li>
<li>{{domxref("EXT_sRGB")}}</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ <h2 id="See_also">See also</h2>
<li>{{domxref("OES_texture_float")}}</li>
<li>{{domxref("OES_texture_half_float")}}</li>
<li>{{domxref("EXT_sRGB")}}</li>
<li>{{domxref("EXT_texture_norm16")}}</li>
</ul>