Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebGLRenderer: Moved scissor/viewport state code to WebGLSate. Fixes #…
- Loading branch information
Showing
3 changed files
with
34 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,9 @@ THREE.WebGLRenderer = function ( parameters ) { | |
|
||
_usedTextureUnits = 0, | ||
|
||
_scissor = new THREE.Vector4( 0, 0, _canvas.width, _canvas.height ), | ||
This comment has been minimized.
Sorry, something went wrong. |
||
_scissorTest = false, | ||
|
||
_viewport = new THREE.Vector4( 0, 0, _canvas.width, _canvas.height ), | ||
|
||
_currentWidth = 0, | ||
|
@@ -238,7 +241,8 @@ THREE.WebGLRenderer = function ( parameters ) { | |
|
||
state.init(); | ||
|
||
_gl.viewport( _viewport.x, _viewport.y, _viewport.z, _viewport.w ); | ||
state.scissor( _scissor ); | ||
state.viewport( _viewport ); | ||
|
||
glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); | ||
|
||
|
@@ -370,39 +374,23 @@ THREE.WebGLRenderer = function ( parameters ) { | |
|
||
this.setViewport = function ( x, y, width, height ) { | ||
|
||
if ( _currentRenderTarget === null ) { | ||
|
||
x *= pixelRatio; | ||
y *= pixelRatio; | ||
|
||
width *= pixelRatio; | ||
height *= pixelRatio; | ||
|
||
_viewport.set( x, y, width, height ); | ||
_viewport.set( x, y, width, height ).multiplyScalar( pixelRatio ); | ||
This comment has been minimized.
Sorry, something went wrong.
WestLangley
Collaborator
|
||
|
||
} | ||
|
||
_gl.viewport( x, y, width, height ); | ||
state.viewport( _viewport ); | ||
|
||
}; | ||
|
||
this.setScissor = function ( x, y, width, height ) { | ||
|
||
if ( _currentRenderTarget === null ) { | ||
_scissor.set( x, y, width, height ).multiplyScalar( pixelRatio ); | ||
|
||
x *= pixelRatio; | ||
y *= pixelRatio; | ||
|
||
width *= pixelRatio; | ||
height *= pixelRatio; | ||
|
||
} | ||
|
||
_gl.scissor( x, y, width, height ); | ||
state.scissor( _scissor ); | ||
|
||
}; | ||
|
||
this.enableScissorTest = function ( boolean ) { | ||
this.setScissorTest = function ( boolean ) { | ||
|
||
_scissorTest = boolean; | ||
|
||
state.setScissorTest( boolean ); | ||
|
||
|
@@ -3381,7 +3369,7 @@ THREE.WebGLRenderer = function ( parameters ) { | |
} | ||
|
||
var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube ); | ||
var framebuffer, viewport; | ||
var framebuffer, scissor, scissorTest, viewport; | ||
|
||
if ( renderTarget ) { | ||
|
||
|
@@ -3397,34 +3385,44 @@ THREE.WebGLRenderer = function ( parameters ) { | |
|
||
} | ||
|
||
scissor = renderTarget.scissor; | ||
scissorTest = renderTarget.scissorTest; | ||
|
||
viewport = renderTarget.viewport; | ||
|
||
} else { | ||
|
||
framebuffer = null; | ||
|
||
scissor = _scissor; | ||
scissorTest = _scissorTest; | ||
|
||
viewport = _viewport; | ||
|
||
} | ||
|
||
if ( framebuffer !== _currentFramebuffer ) { | ||
|
||
_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); | ||
_gl.viewport( viewport.x, viewport.y, viewport.z, viewport.w ); | ||
|
||
_currentFramebuffer = framebuffer; | ||
|
||
} | ||
|
||
state.scissor( scissor ); | ||
state.setScissorTest( scissorTest ); | ||
|
||
state.viewport( viewport ); | ||
|
||
if ( isCube ) { | ||
|
||
var textureProperties = properties.get( renderTarget.texture ); | ||
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + renderTarget.activeCubeFace, textureProperties.__webglTexture, 0 ); | ||
|
||
} | ||
|
||
_currentWidth = viewport.width; | ||
_currentHeight = viewport.height; | ||
_currentWidth = viewport.z; | ||
_currentHeight = viewport.w; | ||
|
||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new THREE.Vector4
ornew THREE.Rectangle
? -- Although I prefer removingTHREE.Rectangle
, as I suggested elsewhere.