Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1018368 of EXT_sRGB

  • Revision slug: Web/API/EXT_sRGB
  • Revision title: EXT_sRGB
  • Revision id: 1018368
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment

Revision Content

{{APIRef("WebGL")}}

The EXT_sRGB extension is part of the WebGL API and adds sRGB support to textures and framebuffer objects.

WebGL extensions are available using the {{domxref("WebGLRenderingContext.getExtension()")}} method. For more information, see also Using Extensions in the WebGL tutorial.

Availability: This extension is only available to {{domxref("WebGLRenderingContext", "WebGL1", "", 1)}} contexts. In {{domxref("WebGL2RenderingContext", "WebGL2", "", 1)}}, the functionality of this extension is available on the WebGL2 context by default. The constants in WebGL2 are: gl.SRGB, gl.SRGB8, gl.SRBG8_ALPHA8 and gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING.

Constants

This extension exposes the following constants, which can be used in the {{domxref("WebGLRenderingContext.texImage2D()", "texImage2D()")}}, {{domxref("WebGLRenderingContext.texSubImage2D()", "texSubImage2D()")}}, {{domxref("WebGLRenderingContext.renderbufferStorage()", "renderbufferStorage()")}} and {{domxref("WebGLRenderingContext.getFramebufferAttachmentParameter()", "getFramebufferAttachmentParameter()")}} methods.

ext.SRGB_EXT
Unsized sRGB format that leaves the precision up to the driver.
ext.SRGB_ALPHA_EXT
Unsized sRGB format with unsized alpha component.
ext.SRGB8_ALPHA8_EXT
Sized (8-bit) sRGB and alpha formats.
ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
Returns the framebuffer color encoding.

Examples

var ext = gl.getExtension("EXT_sRGB");

var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);

gl.texImage2D(gl.TEXTURE_2D, 0, ext.SRGB_EXT, 512, 521, 0, 
              ext.SRGB_EXT, gl.UNSIGNED_BYTE, image);  

Specifications

Specification Status Comment
{{SpecName('EXT_sRGB', '', 'EXT_sRGB')}} {{Spec2('EXT_sRGB')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatUnknown}} {{CompatGeckoDesktop("28.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

  • {{domxref("WebGLRenderingContext.getExtension()")}}
  • {{domxref("WebGLRenderingContext.texImage2D()")}}
  • {{domxref("WebGLRenderingContext.texSubImage2D()")}}
  • {{domxref("WebGLRenderingContext.renderbufferStorage()")}}
  • {{domxref("WebGLRenderingContext.getFramebufferAttachmentParameter()")}}

Revision Source

<div>{{APIRef("WebGL")}}</div>

<p>The <code><strong>EXT_sRGB</strong></code> extension is part of the <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> and adds sRGB support to textures and framebuffer objects.</p>

<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("WebGLRenderingContext", "WebGL1", "", 1)}} contexts. In {{domxref("WebGL2RenderingContext", "WebGL2", "", 1)}}, the functionality of this extension is available on the WebGL2 context by default. The constants in WebGL2 are: <code>gl.SRGB</code>, <code>gl.SRGB8</code>, <code>gl.SRBG8_ALPHA8</code> and <code>gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING</code>.</p>
</div>

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

<p>This extension exposes the following constants, which can be used in the {{domxref("WebGLRenderingContext.texImage2D()", "texImage2D()")}}, {{domxref("WebGLRenderingContext.texSubImage2D()", "texSubImage2D()")}}, {{domxref("WebGLRenderingContext.renderbufferStorage()", "renderbufferStorage()")}} and {{domxref("WebGLRenderingContext.getFramebufferAttachmentParameter()", "getFramebufferAttachmentParameter()")}} methods.</p>

<dl>
 <dt><code>ext.SRGB_EXT</code></dt>
 <dd>Unsized sRGB format that leaves the precision up to the driver.</dd>
 <dt><code>ext.SRGB_ALPHA_EXT</code></dt>
 <dd>Unsized sRGB format with unsized alpha component.</dd>
 <dt><code>ext.SRGB8_ALPHA8_EXT</code></dt>
 <dd>Sized (8-bit) sRGB and alpha formats.</dd>
 <dt><code>ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT</code></dt>
 <dd>Returns the framebuffer color encoding.</dd>
</dl>

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

<pre class="brush:js">
var ext = gl.getExtension("EXT_sRGB");

var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);

gl.texImage2D(gl.TEXTURE_2D, 0, ext.SRGB_EXT, 512, 521, 0, 
              ext.SRGB_EXT, gl.UNSIGNED_BYTE, image);  
</pre>

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

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('EXT_sRGB', '', 'EXT_sRGB')}}</td>
   <td>{{Spec2('EXT_sRGB')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

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

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("28.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

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

<ul>
 <li>{{domxref("WebGLRenderingContext.getExtension()")}}</li>
 <li>{{domxref("WebGLRenderingContext.texImage2D()")}}</li>
 <li>{{domxref("WebGLRenderingContext.texSubImage2D()")}}</li>
 <li>{{domxref("WebGLRenderingContext.renderbufferStorage()")}}</li>
 <li>{{domxref("WebGLRenderingContext.getFramebufferAttachmentParameter()")}}</li>
</ul>
Revert to this revision