src/Common/Misc/WebGl/index.js
function freeGLResources(glResources) {
  const gl = glResources.gl;

  // Delete each program
  Object.keys(glResources.programs).forEach((programName) => {
    const program = glResources.programs[programName];
    const shaders = program.shaders;

    let count = shaders.length;

    // Delete shaders
    while (count) {
      count -= 1;
      gl.deleteShader(shaders[count]);
    }

    // Delete program
    gl.deleteProgram(program);
  });

  // Delete framebuffers
  Object.keys(glResources.framebuffers).forEach((fbName) => {
    gl.deleteFramebuffer(glResources.framebuffers[fbName]);
  });

  // Delete textures
  Object.keys(glResources.textures).forEach((textureName) => {
    gl.deleteTexture(glResources.textures[textureName]);
  });

  // Delete buffers
  Object.keys(glResources.buffers).forEach((bufferName) => {
    gl.deleteBuffer(glResources.buffers[bufferName]);
  });
}
function freeGLResources(glResources) {
  const gl = glResources.gl;

  // Delete each program
  Object.keys(glResources.programs).forEach((programName) => {
    const program = glResources.programs[programName];
    const shaders = program.shaders;

    let count = shaders.length;

    // Delete shaders
    while (count) {
      count -= 1;
      gl.deleteShader(shaders[count]);
    }

    // Delete program
    gl.deleteProgram(program);
  });

  // Delete framebuffers
  Object.keys(glResources.framebuffers).forEach((fbName) => {
    gl.deleteFramebuffer(glResources.framebuffers[fbName]);
  });

  // Delete textures
  Object.keys(glResources.textures).forEach((textureName) => {
    gl.deleteTexture(glResources.textures[textureName]);
  });

  // Delete buffers
  Object.keys(glResources.buffers).forEach((bufferName) => {
    gl.deleteBuffer(glResources.buffers[bufferName]);
  });
}
function freeGLResources ( glResources ) { const gl = glResources . gl ; // Delete each program Object . keys ( glResources . programs ) . forEach ( ( programName ) => { const program = glResources . programs [ programName ] ; const shaders = program . shaders ; let count = shaders . length ; // Delete shaders while ( count ) { count -= 1 ; gl . deleteShader ( shaders [ count ] ) ; } // Delete program gl . deleteProgram ( program ) ; } ) ; // Delete framebuffers Object . keys ( glResources . framebuffers ) . forEach ( ( fbName ) => { gl . deleteFramebuffer ( glResources . framebuffers [ fbName ] ) ; } ) ; // Delete textures Object . keys ( glResources . textures ) . forEach ( ( textureName ) => { gl . deleteTexture ( glResources . textures [ textureName ] ) ; } ) ; // Delete buffers Object . keys ( glResources . buffers ) . forEach ( ( bufferName ) => { gl . deleteBuffer ( glResources . buffers [ bufferName ] ) ; } ) ; }
Free GL resources
Free GL resources