WebGLRenderingContext.renderbufferStorage()

WebGL APIWebGLRenderingContext.renderbufferStorage() 方法用来创建和初始化一个渲染缓冲区对象的数据存储.

语法

void gl.renderbufferStorage(target, internalFormat, width, height);

参数

target
 Glenum 指定一个渲染缓冲区对象. 可能的值:
  • gl.RENDERBUFFER:单一图像的缓冲数据存储在一个可渲染的内部格式。
    .
internalFormat
 Glenum 指定渲染缓冲区的内部格式. 可能的值:
  • gl.RGBA4: 4 red bits, 4 green bits, 4 blue bits 4 alpha bits.
  • gl.RGB565: 5 red bits, 6 green bits, 5 blue bits.
  • gl.RGB5_A1: 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.
  • gl.DEPTH_COMPONENT16: 16 depth bits.
  • gl.STENCIL_INDEX8: 8 stencil bits.
  • gl.DEPTH_STENCIL
  • 当使用{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}时, 下面的值也是可用的:
    • gl.R8
    • gl.R8UI
    • gl.R8I
    • gl.R16UI
    • gl.R16I
    • gl.R32UI
    • gl.R32I
    • gl.RG8
    • gl.RG8UI
    • gl.RG8I
    • gl.RG16UI
    • gl.RG16I
    • gl.RG32UI
    • gl.RG32I
    • gl.RGB8
    • gl.RGBA8
    • gl.SRGB8_ALPHA8 (也可以作为WebGL 1的扩展,参见下面)
    • gl.RGB10_A2
    • gl.RGBA8UI
    • gl.RGBA8I
    • gl.RGB10_A2UI
    • gl.RGBA16UI
    • gl.RGBA16I
    • gl.RGBA32I
    • gl.RGBA32UI
    • gl.DEPTH_COMPONENT24
    • gl.DEPTH_COMPONENT32F
    • gl.DEPTH24_STENCIL8
    • gl.DEPTH32F_STENCIL8
  • 当使用{domxref("WEBGL_color_buffer_float")}} 扩展:
    • ext.RGBA32F_EXT: RGBA 32-bit 浮点类型.
    • ext.RGB32F_EXT: RGB 32-bit 浮点类型.
  • 当使用{domxref("EXT_sRGB")}} 扩展:
    • ext.SRGB8_ALPHA8_EXT: 8-bit sRGB 和 alpha.
  • 当使用{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}} 和 EXT_color_buffer_float 扩展:
    • gl.R16F
    • gl.RG16F
    • gl.RGBA16F
    • gl.R32F
    • gl.RG32F
    • gl.RGBA32F
    • gl.R11F_G11F_B10F
width
 GLsizei 指定渲染缓冲区的宽度(以像素为单位).
height
 GLsizei 指定渲染缓冲区的高度(以像素为单位).

返回值

None.

示例

gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256);

说明

Specification Status Comment
WebGL 1.0
renderbufferStorage
Recommendation WebGL初始定义.
OpenGL ES 2.0
glRenderbufferStorage
Standard OpenGL ES 2 API手册.
WebGL 2.0
getRenderbufferParameter
Editor's Draft WebGL 2更新定义.
OpenGL ES 3.0
glRenderbufferStorage
Standard  OpenGL ES 3 API手册(类似).
添加许多新的内部格式.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
renderbufferStorageChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 12Safari iOS Full support 8Samsung Internet Android Full support 1.5
WebGL2Chrome Full support 56Edge No support NoFirefox Full support 51IE No support NoOpera Full support 43Safari No support NoWebView Android Full support 58Chrome Android Full support 58Firefox Android Full support 51Opera Android Full support 43Safari iOS No support NoSamsung Internet Android Full support 7.0

Legend

Full support  
Full support
No support  
No support

另见