forked from 2youyou2/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe-buffer.js
41 lines (35 loc) · 1.01 KB
/
frame-buffer.js
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
export default class FrameBuffer {
/**
* @constructor
* @param {Device} device
* @param {Number} width
* @param {Number} height
* @param {Object} options
* @param {Array} options.colors
* @param {RenderBuffer|Texture2D|TextureCube} options.depth
* @param {RenderBuffer|Texture2D|TextureCube} options.stencil
* @param {RenderBuffer|Texture2D|TextureCube} options.depthStencil
*/
constructor(device, width, height, options) {
this._device = device;
this._width = width;
this._height = height;
this._colors = options.colors || [];
this._depth = options.depth || null;
this._stencil = options.stencil || null;
this._depthStencil = options.depthStencil || null;
this._glID = device._gl.createFramebuffer();
}
/**
* @method destroy
*/
destroy() {
if (this._glID === null) {
console.error('The frame-buffer already destroyed');
return;
}
const gl = this._device._gl;
gl.deleteFramebuffer(this._glID);
this._glID = null;
}
}