-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
219 lines (196 loc) · 6.26 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
title: "WebGLRenderingContext: pixelStorei() method"
short-title: pixelStorei()
slug: Web/API/WebGLRenderingContext/pixelStorei
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.pixelStorei
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.pixelStorei()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the pixel storage modes.
## Syntax
```js-nolint
pixelStorei(pname, param)
```
### Parameters
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which parameter to set. See below for possible
values.
- `param`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying a value to set the `pname`
parameter to. See below for possible values.
### Return value
None ({{jsxref("undefined")}}).
## Pixel storage parameters
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Parameter name (for <code>pname</code>)</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_ALIGNMENT</code></td>
<td>Packing of pixel data into memory</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>4</td>
<td>1, 2, 4, 8</td>
<td>OpenGL ES 2.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_ALIGNMENT</code></td>
<td>Unpacking of pixel data from memory.</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>4</td>
<td>1, 2, 4, 8</td>
<td>OpenGL ES 2.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_FLIP_Y_WEBGL</code></td>
<td>Flips the source data along its vertical axis if true.</td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>false</td>
<td>true, false</td>
<td>WebGL</td>
</tr>
<tr>
<td><code>gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL</code></td>
<td>Multiplies the alpha channel into the other color channels</td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>false</td>
<td>true, false</td>
<td>WebGL</td>
</tr>
<tr>
<td><code>gl.UNPACK_COLORSPACE_CONVERSION_WEBGL</code></td>
<td>Default color space conversion or no color space conversion.</td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td><code>gl.BROWSER_DEFAULT_WEBGL</code></td>
<td><code>gl.BROWSER_DEFAULT_WEBGL</code>, <code>gl.NONE</code></td>
<td>WebGL</td>
</tr>
</tbody>
</table>
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>
## Examples
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.
```js
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()")}}.
```js
gl.getParameter(gl.PACK_ALIGNMENT);
gl.getParameter(gl.UNPACK_ALIGNMENT);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.readPixels()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}