aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/texparameter/index.html
blob: 6d32ac62e4a473745459b31dfc4b5b0924b5c4de (plain)
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
---
title: 'WebGLRenderingContext.texParameter[fi]()'
slug: Web/API/WebGLRenderingContext/texParameter
translation_of: Web/API/WebGLRenderingContext/texParameter
---
<div>{{APIRef("WebGL")}}</div>

<p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a>  的<strong><code>WebGLRenderingContext.texParameter[fi]()</code></strong>方法用于设置纹理参数.</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">void <var>gl</var>.texParameterf(GLenum <var>target</var>, GLenum <var>pname</var>, GLfloat <var>param</var>);
void <var>gl</var>.texParameteri(GLenum <var>target</var>, GLenum <var>pname</var>, GLint <var>param</var>);
</pre>

<h3 id="参数">参数</h3>

<dl>
 <dt>target</dt>
 <dd>{{domxref("GLenum")}} 指定绑定点(目标)。可能的值:</dd>
 <dd>
 <ul>
  <li><code>gl.TEXTURE_2D</code>: 二维纹理.</li>
  <li><code>gl.TEXTURE_CUBE_MAP</code>: 立方体纹理.</li>
  <li>当使用 {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}} 时,还可以使用以下值
   <ul>
    <li><code>gl.TEXTURE_3D</code>: 三维贴图.</li>
    <li><code>gl.TEXTURE_2D_ARRAY</code>: 二维数组贴图.</li>
   </ul>
  </li>
 </ul>
 </dd>
</dl>

<p><code>pname</code> 参数是 {{domxref("Glenum")}}  指定要设置的纹理参数. <code>param</code> 参数是 {{domxref("GLfloat")}} 或 {{domxref("GLint")}} 已指定的 <code>pname</code>参数的值。</p>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col"><code>pname</code></th>
   <th scope="col">描述</th>
   <th scope="col"><code>参数</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>纹理放大滤波器</td>
   <td><code>gl.LINEAR</code> (默认值), <code>gl.NEAREST</code>.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_MIN_FILTER</code></td>
   <td>纹理缩小滤波器</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> (默认值), <code>gl.LINEAR_MIPMAP_LINEAR</code>.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_WRAP_S</code></td>
   <td>纹理坐标水平填充 <code>s</code></td>
   <td><code>gl.REPEAT</code> (默认值),<code>gl.CLAMP_TO_EDGE</code>, <code>gl.MIRRORED_REPEAT</code>.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_WRAP_T</code></td>
   <td>纹理坐标垂直填充 <code>t</code></td>
   <td><code>gl.REPEAT</code> (默认值),<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>纹理最大向异性</td>
   <td> {{domxref("GLfloat")}} 值.</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>纹理映射等级</td>
   <td>任何整型值.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_COMPARE_FUNC</code></td>
   <td>纹理对比函数</td>
   <td><code>gl.LEQUAL</code> (默认值), <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>纹理对比模式</td>
   <td><code>gl.NONE</code> (默认值), <code>gl.COMPARE_REF_TO_TEXTURE</code>.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_MAX_LEVEL</code></td>
   <td>最大纹理映射数组等级</td>
   <td>任何整型值.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_MAX_LOD</code></td>
   <td>纹理最大细节层次值</td>
   <td>任何整型值.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_MIN_LOD</code></td>
   <td>纹理最小细节层次值</td>
   <td>任何浮点型值.</td>
  </tr>
  <tr>
   <td><code>gl.TEXTURE_WRAP_R</code></td>
   <td>纹理坐标<code>r</code>包装功能</td>
   <td><code>gl.REPEAT</code> (默认值), <code>gl.CLAMP_TO_EDGE</code>, <code>gl.MIRRORED_REPEAT</code>.</td>
  </tr>
 </tbody>
</table>

<h3 id="返回值">返回值</h3>

<p><code>INVALID_ENUM </code>target不是合法的值。</p>

<p><code>INVALID_OPRATION </code>当前目标上没有绑定纹理对象。</p>

<h2 id="示例">示例</h2>

<pre class="brush: 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);
</pre>

<h2 id="说明">说明</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('WebGL', "#5.14.8", "texParameter[fi]")}}</td>
   <td>{{Spec2('WebGL')}}</td>
   <td>WebGL初始定义.</td>
  </tr>
  <tr>
   <td>{{SpecName('OpenGL ES 2.0', "glTexParameter.xml", "glTexParameter")}}</td>
   <td>{{Spec2('OpenGL ES 2.0')}}</td>
   <td>OpenGL ES 2.0 API手册(类似).</td>
  </tr>
  <tr>
   <td>{{SpecName('WebGL2', "#3.7.6", "texParameter[fi]")}}</td>
   <td>{{Spec2('WebGL2')}}</td>
   <td>WebGL更新定义.</td>
  </tr>
  <tr>
   <td>{{SpecName('OpenGL ES 3.0', "glTexParameter.xhtml", "glTexParameter")}}</td>
   <td>{{Spec2('OpenGL ES 3.0')}}</td>
   <td>OpenGL ES 3.0 API手册(类似).</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</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.WebGLRenderingContext.texParameterf")}}</p>

<h2 id="另见">另见</h2>

<ul>
 <li>{{domxref("WebGLRenderingContext.getTexParameter()")}}</li>
 <li>{{domxref("EXT_texture_filter_anisotropic")}}</li>
</ul>