mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 03:22:39 +08:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { GFXDevice } from '../device';
|
|
import { GFXFramebuffer, IGFXFramebufferInfo } from '../framebuffer';
|
|
import { WebGLGFXDevice } from './webgl-device';
|
|
import { WebGLGPUFramebuffer } from './webgl-gpu-objects';
|
|
|
|
export class WebGLGFXFramebuffer extends GFXFramebuffer {
|
|
|
|
public get webGLDevice (): WebGLGFXDevice {
|
|
return this._device as WebGLGFXDevice;
|
|
}
|
|
|
|
public get gpuFramebuffer (): WebGLGPUFramebuffer {
|
|
return this._gpuFramebuffer as WebGLGPUFramebuffer;
|
|
}
|
|
|
|
private _gpuFramebuffer: WebGLGPUFramebuffer | null = null;
|
|
|
|
constructor (device: GFXDevice) {
|
|
super(device);
|
|
}
|
|
|
|
public initialize (info: IGFXFramebufferInfo): boolean {
|
|
|
|
this._renderPass = info.renderPass;
|
|
|
|
if (info.colorViews !== undefined) {
|
|
this._colorViews = info.colorViews;
|
|
}
|
|
|
|
this._depthStencilView = info.depthStencilView !== undefined ? info.depthStencilView : null;
|
|
this._isOffscreen = info.isOffscreen !== undefined ? info.isOffscreen : true;
|
|
|
|
this._gpuFramebuffer = this.webGLDevice.emitCmdCreateGPUFramebuffer(info);
|
|
|
|
return true;
|
|
}
|
|
|
|
public destroy () {
|
|
|
|
if (this._gpuFramebuffer) {
|
|
this.webGLDevice.emitCmdDestroyGPUFramebuffer(this._gpuFramebuffer);
|
|
this._gpuFramebuffer = null;
|
|
}
|
|
}
|
|
}
|