files/en-us/web/api/webglrenderingcontext/pixelstorei/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The WebGLRenderingContext.pixelStorei() method of the WebGL API specifies the pixel storage modes.
pixelStorei(pname, param)
pname
param
pname
parameter to. See below for possible values.None ({{jsxref("undefined")}}).
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
<table class="no-markdown"> <thead> <tr> <th scope="col">Constant</th> <th scope="col">Description</th> <th scope="col">Type</th> <th scope="col">Default value</th> <th scope="col">Allowed values (for <code>param</code>)</th> <th scope="col">Specified in</th> </tr> </thead> <tbody> <tr> <td><code>gl.PACK_ROW_LENGTH</code></td> <td>Number of pixels in a row.</td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.PACK_SKIP_PIXELS</code></td> <td> Number of pixel locations skipped before the first pixel is written into memory. </td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.PACK_SKIP_ROWS</code></td> <td> Number of rows of pixel locations skipped before the first pixel is written into memory </td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.UNPACK_ROW_LENGTH</code></td> <td>Number of pixels in a row.</td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.UNPACK_IMAGE_HEIGHT</code></td> <td>Image height used for reading pixel data from memory</td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.UNPACK_SKIP_PIXELS</code></td> <td> Number of pixel images skipped before the first pixel is read from memory </td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.UNPACK_SKIP_ROWS</code></td> <td> Number of rows of pixel locations skipped before the first pixel is read from memory </td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> <tr> <td><code>gl.UNPACK_SKIP_IMAGES</code></td> <td> Number of pixel images skipped before the first pixel is read from memory </td> <td>{{domxref("WebGL_API/Types", "GLint")}}</td> <td>0</td> <td>0 to <code>Infinity</code></td> <td>OpenGL ES 3.0</td> </tr> </tbody> </table>Setting the pixel storage mode affects the {{domxref("WebGLRenderingContext.readPixels()")}} operations, as well as unpacking of textures with the {{domxref("WebGLRenderingContext.texImage2D()")}} and {{domxref("WebGLRenderingContext.texSubImage2D()")}} methods.
const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
To check the values for packing and unpacking of pixel data, you can query the same pixel storage parameters with {{domxref("WebGLRenderingContext.getParameter()")}}.
gl.getParameter(gl.PACK_ALIGNMENT);
gl.getParameter(gl.UNPACK_ALIGNMENT);
{{Specifications}}
{{Compat}}