mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 01:17:43 +00:00
Array Remove and unbind before deleting the framebuffer
This commit is contained in:
parent
2d364f08c4
commit
1935119141
1 changed files with 36 additions and 34 deletions
|
@ -2291,43 +2291,45 @@ var WebGLRenderer = new Class({
|
|||
*/
|
||||
deleteFramebuffer: function (framebuffer)
|
||||
{
|
||||
if (framebuffer)
|
||||
if (!framebuffer)
|
||||
{
|
||||
var gl = this.gl;
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
||||
|
||||
// Check for a color attachment and remove it
|
||||
var colorAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
|
||||
if (colorAttachment !== null)
|
||||
{
|
||||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
|
||||
|
||||
// TODO: Check if this texture is used elsewhere. If not, delete it:
|
||||
// gl.deleteTexture(colorAttachment);
|
||||
}
|
||||
|
||||
// Check for a depth-stencil attachment and delete it
|
||||
var depthStencilAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
|
||||
if (depthStencilAttachment !== null)
|
||||
{
|
||||
gl.deleteRenderbuffer(depthStencilAttachment);
|
||||
}
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
||||
|
||||
gl.deleteFramebuffer(framebuffer);
|
||||
|
||||
ArrayRemove(this.fboStack, framebuffer);
|
||||
|
||||
if (this.currentFramebuffer === framebuffer)
|
||||
{
|
||||
this.currentFramebuffer = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
if (this.currentFramebuffer === framebuffer)
|
||||
{
|
||||
this.currentFramebuffer = null;
|
||||
}
|
||||
|
||||
ArrayRemove(this.fboStack, framebuffer);
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
||||
|
||||
// Check for a color attachment and remove it
|
||||
var colorAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
|
||||
if (colorAttachment !== null)
|
||||
{
|
||||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
|
||||
|
||||
// TODO: Check if this texture is used elsewhere. If not, delete it:
|
||||
// gl.deleteTexture(colorAttachment);
|
||||
}
|
||||
|
||||
// Check for a depth-stencil attachment and delete it
|
||||
var depthStencilAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||
|
||||
if (depthStencilAttachment !== null)
|
||||
{
|
||||
gl.deleteRenderbuffer(depthStencilAttachment);
|
||||
}
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
||||
|
||||
gl.deleteFramebuffer(framebuffer);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue