MCPcopy Index your code
hub / github.com/gpujs/gpu.js / cloneTexture

Method cloneTexture

src/backend/gl/texture/index.js:35–50  ·  view source on GitHub ↗

* @private

()

Source from the content-addressed store, hash-verified

33 * @private
34 */
35 cloneTexture() {
36 this.texture._refs--;
37 const { context: gl, size, texture, kernel } = this;
38 if (kernel.debug) {
39 console.warn('cloning internal texture');
40 }
41 gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer());
42 selectTexture(gl, texture);
43 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
44 const target = gl.createTexture();
45 selectTexture(gl, target);
46 gl.texImage2D(gl.TEXTURE_2D, 0, this.internalFormat, size[0], size[1], 0, this.textureFormat, this.textureType, null);
47 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, size[0], size[1]);
48 target._refs = 1;
49 this.texture = target;
50 }
51
52 /**
53 * @private

Callers 1

testCloningFunction · 0.80

Calls 3

framebufferMethod · 0.95
selectTextureFunction · 0.85
createTextureMethod · 0.80

Tested by

no test coverage detected