copyFramebufferToTexture method
void
copyFramebufferToTexture(
- Vector? position,
- Texture? texture, {
- int level = 0,
})
Implementation
void copyFramebufferToTexture(Vector? position, Texture? texture, {int level = 0}) {
//console.warning('copyFramebufferToTexture not supported');
if (texture is! FramebufferTexture) {
console.warning('WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.');
return;
}
final levelScale = math.pow(2, -level);
final width = (texture.image.width * levelScale).floor();
final height = (texture.image.height * levelScale).floor();
final x = position != null ? position.x.toInt() : 0;
final y = position != null ? position.y.toInt() : 0;
textures.setTexture2D(texture, 0);
_gl.copyTexSubImage2D(WebGL.TEXTURE_2D, level, 0, 0, x, y, width, height);
state.unbindTexture(WebGLTexture(WebGL.TEXTURE_2D));
}