@@ -2,6 +2,7 @@ var Class = require('../../utils/Class');
22var CONST = require ( '../../const' ) ;
33var WebGLSnapshot = require ( '../snapshot/WebGLSnapshot' ) ;
44var IsSizePowerOfTwo = require ( '../../math/pow2/IsSizePowerOfTwo' ) ;
5+ var Utils = require ( './Utils' ) ;
56
67// Default Pipelines
78var TextureTintPipeline = require ( './pipelines/TextureTintPipeline' ) ;
@@ -233,13 +234,19 @@ var WebGLRenderer = new Class({
233234 var gl = this . gl ;
234235 var scissorState = this . currentScissorState ;
235236
236- if ( ! x !== 0 || y !== 0 || width !== gl . canvas . width || height !== gl . canvas . height )
237+ if ( x == 0 &&
238+ y == 0 &&
239+ width == gl . canvas . width &&
240+ height == gl . canvas . height &&
241+ width > 0 &&
242+ height > 0 )
237243 {
238- return ;
244+ return ;
239245 }
240246
241247 if ( ! scissorState . enabled )
242248 {
249+ this . flush ( ) ;
243250 gl . enable ( gl . SCISSOR_TEST ) ;
244251 scissorState . enabled = true ;
245252 }
@@ -259,6 +266,7 @@ var WebGLRenderer = new Class({
259266 if ( scissorState . enabled )
260267 {
261268 gl . disable ( gl . SCISSOR_TEST ) ;
269+ scissorState . enabled = false ;
262270 }
263271 } ,
264272
@@ -549,6 +557,60 @@ var WebGLRenderer = new Class({
549557 } ,
550558
551559 /* Rendering Functions */
560+ preRenderCamera : function ( camera )
561+ {
562+ this . beginScissor ( camera . x , camera . y , camera . width , camera . height ) ;
563+
564+ if ( camera . backgroundColor . alphaGL > 0 )
565+ {
566+ var color = camera . backgroundColor ;
567+ var FlatTintPipeline = this . pipelines . FlatTintPipeline ;
568+
569+ FlatTintPipeline . batchFillRect (
570+ 0 , 0 , 1 , 1 , 0 ,
571+ camera . x , camera . y , camera . width , camera . height ,
572+ Utils . getTintFromFloats ( color . redGL , color . greenGL , color . blueGL , 1.0 ) ,
573+ color . alphaGL ,
574+ 1 , 0 , 0 , 1 , 0 , 0 ,
575+ [ 1 , 0 , 0 , 1 , 0 , 0 ]
576+ ) ;
577+
578+ FlatTintPipeline . flush ( ) ;
579+ }
580+ } ,
581+
582+ postRenderCamera : function ( camera )
583+ {
584+ if ( camera . _fadeAlpha > 0 || camera . _flashAlpha > 0 )
585+ {
586+ var FlatTintPipeline = this . pipelines . FlatTintPipeline ;
587+
588+ // Fade
589+ FlatTintPipeline . batchFillRect (
590+ 0 , 0 , 1 , 1 , 0 ,
591+ camera . x , camera . y , camera . width , camera . height ,
592+ Utils . getTintFromFloats ( camera . _fadeRed , camera . _fadeGreen , camera . _fadeBlue , 1.0 ) ,
593+ camera . _fadeAlpha ,
594+ 1 , 0 , 0 , 1 , 0 , 0 ,
595+ [ 1 , 0 , 0 , 1 , 0 , 0 ]
596+ ) ;
597+
598+ // Flash
599+ FlatTintPipeline . batchFillRect (
600+ 0 , 0 , 1 , 1 , 0 ,
601+ camera . x , camera . y , camera . width , camera . height ,
602+ Utils . getTintFromFloats ( camera . _flashRed , camera . _flashGreen , camera . _flashBlue , 1.0 ) ,
603+ camera . _flashAlpha ,
604+ 1 , 0 , 0 , 1 , 0 , 0 ,
605+ [ 1 , 0 , 0 , 1 , 0 , 0 ]
606+ ) ;
607+
608+ FlatTintPipeline . flush ( ) ;
609+ }
610+
611+ this . endScissor ( ) ;
612+ } ,
613+
552614 preRender : function ( )
553615 {
554616 if ( this . contextLost ) return ;
@@ -569,7 +631,7 @@ var WebGLRenderer = new Class({
569631 var list = children . list ;
570632 var childCount = list . length ;
571633
572- this . beginScissor ( camera . x , camera . y , camera . width , camera . height ) ;
634+ this . preRenderCamera ( camera ) ;
573635
574636 for ( var index = 0 ; index < childCount ; ++ index )
575637 {
@@ -599,7 +661,8 @@ var WebGLRenderer = new Class({
599661 }
600662
601663 this . flush ( ) ;
602- this . endScissor ( ) ;
664+ this . setBlendMode ( CONST . BlendModes . NORMAL ) ;
665+ this . postRenderCamera ( camera ) ;
603666 } ,
604667
605668 postRender : function ( )
0 commit comments