浏览代码

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

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

* WebGLState: Simplify code.
Michael Herzog 4 年之前
父节点
当前提交
be73fc9bdc
共有 1 个文件被更改,包括 5 次插入2 次删除
  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 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 ) {