--- title: WebGLTexture slug: Web/API/WebGLTexture tags: - API - Reference - WebGL translation_of: Web/API/WebGLTexture --- <div><strong>WebGLTexture</strong>接口是<a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a>的一部分,为不透明的纹理对象提供储存和状态等纹理操作。</div> <h2 id="描述">描述</h2> <p><code>WebGLTexture</code>对象自身未定义任何属性或方法, 其内容无法被直接访问。当使用<code>WebGLTexture</code>对象时, {{domxref("WebGLRenderingContext")}} 里的这些方法会很有用:</p> <ul> <li>{{domxref("WebGLRenderingContext.bindTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.createTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.deleteTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.isTexture()")}}</li> </ul> <h2 id="例子">例子</h2> <h3 id="创建一个纹理">创建一个纹理</h3> <pre class="brush: js">var canvas = document.getElementById('canvas'); var gl = canvas.getContext('webgl'); var texture = gl.createTexture(); </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.9", "WebGLTexture")}}</td> <td>{{Spec2('WebGL')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.WebGLTexture")}}</p> <h2 id="See_also">See also</h2> <ul> <li>{{domxref("WebGLRenderingContext.bindTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.createTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.deleteTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.isTexture()")}}</li> <li>{{domxref("WebGLRenderingContext.compressedTexImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.compressedTexSubImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.copyTexImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.copyTexSubImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.generateMipmap()")}}</li> <li>{{domxref("WebGLRenderingContext.getTexParameter()")}}</li> <li>{{domxref("WebGLRenderingContext.texImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.texSubImage2D()")}}</li> <li>{{domxref("WebGLRenderingContext.texParameterf()")}}</li> <li>{{domxref("WebGLRenderingContext.texParameteri()")}}</li> </ul>