Browse Source

WebGLState: Use getParameter() to detect current scissor/viewport. (#21831)

* WebGLState: Use getParameter() to detect current scissor/viewport.

* WebGLState: Simplify code.
Michael Herzog 4 years ago
parent
commit
be73fc9bdc
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/renderers/webgl/WebGLState.js

+ 5 - 2
src/renderers/webgl/WebGLState.js

@@ -360,8 +360,11 @@ function WebGLState( gl, extensions, capabilities ) {
 	let currentTextureSlot = null;
 	let currentTextureSlot = null;
 	let currentBoundTextures = {};
 	let currentBoundTextures = {};
 
 
-	const currentScissor = new Vector4( 0, 0, gl.canvas.width, gl.canvas.height );
-	const currentViewport = new Vector4( 0, 0, gl.canvas.width, gl.canvas.height );
+	const scissorParam = gl.getParameter( gl.SCISSOR_BOX );
+	const viewportParam = gl.getParameter( gl.VIEWPORT );
+
+	const currentScissor = new Vector4().fromArray( scissorParam );
+	const currentViewport = new Vector4().fromArray( viewportParam );
 
 
 	function createTexture( type, target, count ) {
 	function createTexture( type, target, count ) {