WebGLRenderingContext.createBuffer()

WebGL API 下的 WebGLRenderingContext.createBuffer() 方法可创建并初始化一个用于储存顶点数据或着色数据的WebGLBuffer对象

语法

WebGLBuffer gl.createBuffer();

参数

无。

返回值

一个用于储存顶点数据或着色数据的WebGLBuffer对象

范例

创建一个缓冲区

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
var buffer = gl.createBuffer();

说明

Specification Status Comment
WebGL 1.0
createBuffer
Recommendation Initial definition.
OpenGL ES 2.0
glGenBuffers
Standard Man page of the (similar) OpenGL API.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
createBufferChrome 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 8.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support

See also