-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
175 lines (156 loc) · 5.06 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
---
title: WebGLRenderingContext.texParameter[fi]()
slug: Web/API/WebGLRenderingContext/texParameter
page-type: web-api-instance-method
tags:
- API
- Method
- Reference
- Textures
- WebGL
- WebGLRenderingContext
browser-compat:
- api.WebGLRenderingContext.texParameterf
- api.WebGLRenderingContext.texParameteri
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.texParameter[fi]()`** methods of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) set texture parameters.
## Syntax
```js
texParameterf(target, GLenum pname, GLfloat param)
texParameteri(target, GLenum pname, GLint param)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP`: A cube-mapped texture.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
- `gl.TEXTURE_3D`: A three-dimensional texture.
- `gl.TEXTURE_2D_ARRAY`: A two-dimensional array texture.
- `param`
- : The `param` parameter is a {{domxref("WebGL_API/Types", "GLfloat")}} or
{{domxref("WebGL_API/Types", "GLint")}} specifying the value for the specified parameter
- `pname`
- : The `pname` parameter is a {{domxref("WebGL_API/Types", "GLenum")}} specifying the texture
parameter to set.
<table class="standard-table">
<thead>
<tr>
<th scope="col"><code>pname</code></th>
<th scope="col">Description</th>
<th scope="col"><code>param</code></th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="3">Available in WebGL 1</th>
</tr>
<tr>
<td><code>gl.TEXTURE_MAG_FILTER</code></td>
<td>Texture magnification filter</td>
<td><code>gl.LINEAR</code> (default value), <code>gl.NEAREST</code>.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_FILTER</code></td>
<td>Texture minification filter</td>
<td>
<code>gl.LINEAR</code>, <code>gl.NEAREST</code>,
<code>gl.NEAREST_MIPMAP_NEAREST</code>,
<code>gl.LINEAR_MIPMAP_NEAREST</code>,
<code>gl.NEAREST_MIPMAP_LINEAR</code> (default value),
<code>gl.LINEAR_MIPMAP_LINEAR</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_S</code></td>
<td>Wrapping function for texture coordinate <code>s</code></td>
<td>
<code>gl.REPEAT</code> (default value),<code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_T</code></td>
<td>Wrapping function for texture coordinate <code>t</code></td>
<td>
<code>gl.REPEAT</code> (default value),<code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<th colspan="3">
Additionally available when using the
{{domxref("EXT_texture_filter_anisotropic")}} extension
</th>
</tr>
<tr>
<td><code>ext.TEXTURE_MAX_ANISOTROPY_EXT</code></td>
<td>Maximum anisotropy for a texture</td>
<td>A {{domxref("WebGL_API/Types", "GLfloat")}} value.</td>
</tr>
<tr>
<th colspan="3">Additionally available when using a WebGL 2 context</th>
</tr>
<tr>
<td><code>gl.TEXTURE_BASE_LEVEL</code></td>
<td>Texture mipmap level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_FUNC</code></td>
<td>Texture Comparison function</td>
<td>
<code>gl.LEQUAL</code> (default value), <code>gl.GEQUAL</code>,
<code>gl.LESS</code>, <code>gl.GREATER</code>, <code>gl.EQUAL</code>,
<code>gl.NOTEQUAL</code>, <code>gl.ALWAYS</code>, <code>gl.NEVER</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_MODE</code></td>
<td>Texture comparison mode</td>
<td>
<code>gl.NONE</code> (default value),
<code>gl.COMPARE_REF_TO_TEXTURE</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LEVEL</code></td>
<td>Maximum texture mipmap array level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LOD</code></td>
<td>Texture maximum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_LOD</code></td>
<td>Texture minimum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_R</code></td>
<td>Wrapping function for texture coordinate <code>r</code></td>
<td>
<code>gl.REPEAT</code> (default value), <code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
</tbody>
</table>
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- {{domxref("EXT_texture_filter_anisotropic")}}