diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 620e47f42eecff2ad2f24dbc5da0133cab681645..38ba4a16cdd2eaa78cc867b59b14adbe6fec691e 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -322,18 +322,6 @@ function WebGLRenderer( parameters ) { } - function glClearColor( r, g, b, a ) { - - if ( _premultipliedAlpha === true ) { - - r *= a; g *= a; b *= a; - - } - - state.clearColor( r, g, b, a ); - - } - function setDefaultGLState() { state.init(); @@ -341,7 +329,7 @@ function WebGLRenderer( parameters ) { state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) ); state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) ); - glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); + state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); } @@ -485,7 +473,7 @@ function WebGLRenderer( parameters ) { _clearAlpha = alpha !== undefined ? alpha : 1; - glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); + state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); }; @@ -499,7 +487,7 @@ function WebGLRenderer( parameters ) { _clearAlpha = alpha; - glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); + state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); }; @@ -1209,11 +1197,11 @@ function WebGLRenderer( parameters ) { if ( background === null ) { - glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); + state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); } else if ( background && background.isColor ) { - glClearColor( background.r, background.g, background.b, 1 ); + state.buffers.color.setClear( background.r, background.g, background.b, 1, _premultipliedAlpha ); forceClear = true; } @@ -1742,7 +1730,7 @@ function WebGLRenderer( parameters ) { material.needsUpdate = true; } else if ( materialProperties.numClippingPlanes !== undefined && - ( materialProperties.numClippingPlanes !== _clipping.numPlanes || + ( materialProperties.numClippingPlanes !== _clipping.numPlanes || materialProperties.numIntersection !== _clipping.numIntersection ) ) { material.needsUpdate = true; diff --git a/src/renderers/webgl/WebGLShadowMap.js b/src/renderers/webgl/WebGLShadowMap.js index 93cf402a86f538f152b0855577f70dcabd2aafc5..e2438c1077beb544645ecc6e3713712599943021 100644 --- a/src/renderers/webgl/WebGLShadowMap.js +++ b/src/renderers/webgl/WebGLShadowMap.js @@ -115,7 +115,7 @@ function WebGLShadowMap( _renderer, _lights, _objects, capabilities ) { if ( _lightShadows.length === 0 ) return; // Set GL state for depth map. - _state.clearColor( 1, 1, 1, 1 ); + _state.buffers.color.setClear( 1, 1, 1, 1 ); _state.disable( _gl.BLEND ); _state.setDepthTest( true ); _state.setScissorTest( false ); diff --git a/src/renderers/webgl/WebGLState.js b/src/renderers/webgl/WebGLState.js index 65d600d6985daf3b6236af7778e8871d82289584..4ad69938f836a168e5012297ef6537f8b9bdd1da 100644 --- a/src/renderers/webgl/WebGLState.js +++ b/src/renderers/webgl/WebGLState.js @@ -34,7 +34,13 @@ function WebGLState( gl, extensions, paramThreeToGL ) { }, - setClear: function ( r, g, b, a ) { + setClear: function ( r, g, b, a, premultipliedAlpha ) { + + if ( premultipliedAlpha === true ) { + + r *= a; g *= a; b *= a; + + } color.set( r, g, b, a ); @@ -369,9 +375,9 @@ function WebGLState( gl, extensions, paramThreeToGL ) { function init() { - clearColor( 0, 0, 0, 1 ); - clearDepth( 1 ); - clearStencil( 0 ); + colorBuffer.setClear( 0, 0, 0, 1 ); + depthBuffer.setClear( 1 ); + stencilBuffer.setClear( 0 ); enable( gl.DEPTH_TEST ); setDepthFunc( LessEqualDepth ); @@ -850,26 +856,6 @@ function WebGLState( gl, extensions, paramThreeToGL ) { } - // TODO Deprecate - - function clearColor( r, g, b, a ) { - - colorBuffer.setClear( r, g, b, a ); - - } - - function clearDepth( depth ) { - - depthBuffer.setClear( depth ); - - } - - function clearStencil( stencil ) { - - stencilBuffer.setClear( stencil ); - - } - // function scissor( scissor ) { @@ -969,10 +955,6 @@ function WebGLState( gl, extensions, paramThreeToGL ) { compressedTexImage2D: compressedTexImage2D, texImage2D: texImage2D, - clearColor: clearColor, - clearDepth: clearDepth, - clearStencil: clearStencil, - scissor: scissor, viewport: viewport,