deallocateRenderTarget method
Implementation
void deallocateRenderTarget(RenderTarget renderTarget) {
var texture = renderTarget.texture;
var renderTargetProperties = properties.get(renderTarget);
var textureProperties = properties.get(texture);
if (textureProperties["__webglTexture"] != null) {
gl.deleteTexture(textureProperties["__webglTexture"]);
info.memory["textures"] = info.memory["textures"]! - 1;
}
if (renderTarget.depthTexture != null) {
renderTarget.depthTexture!.dispose();
}
if (renderTarget.isWebGLCubeRenderTarget) {
for (var i = 0; i < 6; i++) {
gl.deleteFramebuffer(renderTargetProperties["__webglFramebuffer"][i]);
if (renderTargetProperties["__webglDepthbuffer"] != null) {
gl.deleteRenderbuffer(
renderTargetProperties["__webglDepthbuffer"][i]);
}
}
} else {
gl.deleteFramebuffer(renderTargetProperties["__webglFramebuffer"]);
if (renderTargetProperties["__webglDepthbuffer"] != null) {
gl.deleteRenderbuffer(renderTargetProperties["__webglDepthbuffer"]);
}
if (renderTargetProperties["__webglMultisampledFramebuffer"] != null) {
gl.deleteFramebuffer(
renderTargetProperties["__webglMultisampledFramebuffer"]);
}
if (renderTargetProperties["__webglColorRenderbuffer"] != null) {
gl.deleteRenderbuffer(
renderTargetProperties["__webglColorRenderbuffer"]);
}
if (renderTargetProperties["__webglDepthRenderbuffer"] != null) {
gl.deleteRenderbuffer(
renderTargetProperties["__webglDepthRenderbuffer"]);
}
}
if (renderTarget.isWebGLMultipleRenderTargets) {
for (var i = 0, il = texture.length; i < il; i++) {
var attachmentProperties = properties.get(texture[i]);
if (attachmentProperties["__webglTexture"] != null) {
gl.deleteTexture(attachmentProperties["__webglTexture"]);
info.memory["textures"] = info.memory["textures"]! - 1;
}
properties.remove(texture[i]);
}
}
properties.remove(texture);
properties.remove(renderTarget);
}