|
@@ -10,6 +10,7 @@ import WebGLTextureUtils from './utils/WebGLTextureUtils.js';
|
|
|
import WebGLExtensions from './utils/WebGLExtensions.js';
|
|
|
import WebGLCapabilities from './utils/WebGLCapabilities.js';
|
|
|
import { GLFeatureName } from './utils/WebGLConstants.js';
|
|
|
+
|
|
|
//
|
|
|
|
|
|
class WebGLBackend extends Backend {
|
|
@@ -115,6 +116,24 @@ class WebGLBackend extends Backend {
|
|
|
const renderContextData = this.get( renderContext );
|
|
|
const previousContext = renderContextData.previousContext;
|
|
|
|
|
|
+ const textures = renderContext.textures;
|
|
|
+
|
|
|
+ if ( textures !== null ) {
|
|
|
+
|
|
|
+ for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
+
|
|
|
+ const texture = textures[ i ];
|
|
|
+
|
|
|
+ if ( texture.generateMipmaps ) {
|
|
|
+
|
|
|
+ this.generateMipmaps( texture );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
this._currentContext = previousContext;
|
|
|
|
|
|
|
|
@@ -809,9 +828,9 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- destroyAttribute( /*attribute*/ ) {
|
|
|
+ destroyAttribute( attribute ) {
|
|
|
|
|
|
- console.warn( 'Abstract class.' );
|
|
|
+ this.attributeUtils.destroyAttribute( attribute );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -855,18 +874,36 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const { gl, state } = this;
|
|
|
|
|
|
- let fb = null;
|
|
|
let currentFrameBuffer = null;
|
|
|
|
|
|
if ( renderContext.textures !== null ) {
|
|
|
|
|
|
- const renderTargetContextData = this.get( renderContext.renderTarget );
|
|
|
- const { samples } = renderContext.renderTarget;
|
|
|
+ const renderTarget = renderContext.renderTarget;
|
|
|
+ const renderTargetContextData = this.get( renderTarget );
|
|
|
+ const { samples } = renderTarget;
|
|
|
+ const cubeFace = this.renderer._activeCubeFace;
|
|
|
+ const isCube = renderTarget.isWebGLCubeRenderTarget === true;
|
|
|
|
|
|
- fb = renderTargetContextData.framebuffer;
|
|
|
let msaaFb = renderTargetContextData.msaaFrameBuffer;
|
|
|
let depthRenderbuffer = renderTargetContextData.depthRenderbuffer;
|
|
|
|
|
|
+ let fb;
|
|
|
+
|
|
|
+ if ( isCube ) {
|
|
|
+
|
|
|
+ if ( renderTargetContextData.cubeFramebuffers === undefined ) {
|
|
|
+
|
|
|
+ renderTargetContextData.cubeFramebuffers = [];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ fb = renderTargetContextData.cubeFramebuffers[ cubeFace ];
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ fb = renderTargetContextData.framebuffer;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if ( fb === undefined ) {
|
|
|
|
|
@@ -876,16 +913,30 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const textures = renderContext.textures;
|
|
|
|
|
|
- for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
+ if ( isCube ) {
|
|
|
|
|
|
- const texture = textures[ i ];
|
|
|
- const textureData = this.get( texture );
|
|
|
- textureData.renderTarget = renderContext.renderTarget;
|
|
|
+ renderTargetContextData.cubeFramebuffers[ cubeFace ] = fb;
|
|
|
+ const { textureGPU } = this.get( textures[ 0 ] );
|
|
|
|
|
|
- const attachment = gl.COLOR_ATTACHMENT0 + i;
|
|
|
+ gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace, textureGPU, 0 );
|
|
|
+
|
|
|
+ } else {
|
|
|
|
|
|
+ for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
|
|
|
- gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
|
+ const texture = textures[ i ];
|
|
|
+ const textureData = this.get( texture );
|
|
|
+ textureData.renderTarget = renderContext.renderTarget;
|
|
|
+
|
|
|
+ const attachment = gl.COLOR_ATTACHMENT0 + i;
|
|
|
+
|
|
|
+ gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ renderTargetContextData.framebuffer = fb;
|
|
|
+
|
|
|
+ state.drawBuffers( renderContext, fb );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -897,11 +948,6 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- renderTargetContextData.framebuffer = fb;
|
|
|
-
|
|
|
- state.drawBuffers( renderContext, fb );
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if ( samples > 0 ) {
|