Skip to content

Commit 7806f49

Browse files
aardgooseaardgoose
andauthored
WebGPURenderer: implement WebGLBackend copyFramebufferToTexture() (#27012)
Co-authored-by: aardgoose <[email protected]>
1 parent 8bbe37b commit 7806f49

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

examples/jsm/renderers/webgl/WebGLBackend.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,20 @@ class WebGLBackend extends Backend {
830830

831831
}
832832

833-
copyFramebufferToTexture( /*texture, renderContext*/ ) {
833+
copyFramebufferToTexture( texture /*, renderContext */ ) {
834834

835-
console.warn( 'Abstract class.' );
835+
const { gl } = this;
836+
837+
const { textureGPU } = this.get( texture );
838+
839+
gl.bindFramebuffer( gl.FRAMEBUFFER, null );
840+
gl.bindTexture( gl.TEXTURE_2D, textureGPU );
841+
842+
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, 0, 0, texture.image.width, texture.image.height );
843+
844+
if ( texture.generateMipmaps ) gl.generateMipmap( gl.TEXTURE_2D );
845+
846+
gl.bindTexture( gl.TEXTURE_2D, null );
836847

837848
}
838849

0 commit comments

Comments
 (0)