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
|
---
title: WebGLRenderingContext.renderbufferStorage()
slug: Web/API/WebGLRenderingContext/renderbufferStorage
translation_of: Web/API/WebGLRenderingContext/renderbufferStorage
---
<div>{{APIRef("WebGL")}}</div>
<p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 的 <strong><code>WebGLRenderingContext.renderbufferStorage()</code></strong> 方法用来创建和初始化一个渲染缓冲区对象的数据存储.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">void <var>gl</var>.renderbufferStorage(<var>target</var>, <var>internalFormat</var>, <var>width</var>, <var>height</var>);
</pre>
<h3 id="参数">参数</h3>
<dl>
<dt>target</dt>
<dd> {{domxref("Glenum")}} 指定一个渲染缓冲区对象. 可能的值:
<ul>
<li><code>gl.RENDERBUFFER</code>:单一图像的缓冲数据存储在一个可渲染的内部格式。<br>
.</li>
</ul>
</dd>
<dt>internalFormat</dt>
<dd> {{domxref("Glenum")}} 指定渲染缓冲区的内部格式. 可能的值:
<ul>
<li><code>gl.RGBA4</code>: 4 red bits, 4 green bits, 4 blue bits 4 alpha bits.</li>
<li><code>gl.RGB565</code>: 5 red bits, 6 green bits, 5 blue bits.</li>
<li><code>gl.RGB5_A1</code>: 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.</li>
<li><code>gl.DEPTH_COMPONENT16</code>: 16 depth bits.</li>
<li><code>gl.STENCIL_INDEX8</code>: 8 stencil bits.</li>
<li><code>gl.DEPTH_STENCIL</code></li>
<li>当使用{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}时, 下面的值也是可用的:
<ul>
<li><code>gl.R8</code></li>
<li><code>gl.R8UI</code></li>
<li><code>gl.R8I</code></li>
<li><code>gl.R16UI</code></li>
<li><code>gl.R16I</code></li>
<li><code>gl.R32UI</code></li>
<li><code>gl.R32I</code></li>
<li><code>gl.RG8</code></li>
<li><code>gl.RG8UI</code></li>
<li><code>gl.RG8I</code></li>
<li><code>gl.RG16UI</code></li>
<li><code>gl.RG16I</code></li>
<li><code>gl.RG32UI</code></li>
<li><code>gl.RG32I</code></li>
<li><code>gl.RGB8</code></li>
<li><code>gl.RGBA8</code></li>
<li><code>gl.SRGB8_ALPHA8</code> (也可以作为WebGL 1的扩展,参见下面)</li>
<li><code>gl.RGB10_A2</code></li>
<li><code>gl.RGBA8UI</code></li>
<li><code>gl.RGBA8I</code></li>
<li><code>gl.RGB10_A2UI</code></li>
<li><code>gl.RGBA16UI</code></li>
<li><code>gl.RGBA16I</code></li>
<li><code>gl.RGBA32I</code></li>
<li><code>gl.RGBA32UI</code></li>
<li><code>gl.DEPTH_COMPONENT24</code></li>
<li><code>gl.DEPTH_COMPONENT32F</code></li>
<li><code>gl.DEPTH24_STENCIL8</code></li>
<li><code>gl.DEPTH32F_STENCIL8</code></li>
</ul>
</li>
<li>当使用{domxref("WEBGL_color_buffer_float")}} 扩展:
<ul>
<li><code>ext.RGBA32F_EXT</code>: RGBA 32-bit 浮点类型.</li>
<li><code>ext.RGB32F_EXT</code>: RGB 32-bit 浮点类型.</li>
</ul>
</li>
<li>当使用{domxref("EXT_sRGB")}} 扩展:
<ul>
<li><code>ext.SRGB8_ALPHA8_EXT</code>: 8-bit sRGB 和 alpha.</li>
</ul>
</li>
<li>当使用{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}} 和 {{domxref("EXT_color_buffer_float")}} 扩展:
<ul>
<li><code>gl.R16F</code></li>
<li><code>gl.RG16F</code></li>
<li><code>gl.RGBA16F</code></li>
<li><code>gl.R32F</code></li>
<li><code>gl.RG32F</code></li>
<li><code>gl.RGBA32F</code></li>
<li><code>gl.R11F_G11F_B10F</code></li>
</ul>
</li>
</ul>
</dd>
<dt>width</dt>
<dd> {{domxref("GLsizei")}} 指定渲染缓冲区的宽度(以像素为单位).</dd>
<dt>height</dt>
<dd> {{domxref("GLsizei")}} 指定渲染缓冲区的高度(以像素为单位).</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p>None.</p>
<h2 id="示例">示例</h2>
<pre class="brush: js">gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256);
</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.7", "renderbufferStorage")}}</td>
<td>{{Spec2('WebGL')}}</td>
<td>WebGL初始定义.</td>
</tr>
<tr>
<td>{{SpecName('OpenGL ES 2.0', "glRenderbufferStorage.xml", "glRenderbufferStorage")}}</td>
<td>{{Spec2('OpenGL ES 2.0')}}</td>
<td>OpenGL ES 2 API手册.</td>
</tr>
<tr>
<td>{{SpecName('WebGL2', "#3.7.5", "getRenderbufferParameter")}}</td>
<td>{{Spec2('WebGL2')}}</td>
<td>WebGL 2更新定义.</td>
</tr>
<tr>
<td>{{SpecName('OpenGL ES 3.0', "glRenderbufferStorage.xhtml", "glRenderbufferStorage")}}</td>
<td>{{Spec2('OpenGL ES 3.0')}}</td>
<td> OpenGL ES 3 API手册(类似).<br>
添加许多新的内部格式.</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.renderbufferStorage")}}</p>
<h2 id="另见">另见</h2>
<ul>
<li>{{domxref("WebGLRenderingContext.bindRenderbuffer()")}}</li>
<li>{{domxref("WebGLRenderingContext.createRenderbuffer()")}}</li>
<li>{{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}</li>
<li>{{domxref("WebGLRenderingContext.getRenderbufferParameter()")}}</li>
<li>{{domxref("WEBGL_color_buffer_float")}}</li>
<li>{{domxref("EXT_sRGB")}}</li>
<li>{{domxref("EXT_color_buffer_float")}}</li>
</ul>
|