Browse Source

WebGLState: Added init().

Mr.doob 10 years ago
parent
commit
769180018e
2 changed files with 20 additions and 14 deletions
  1. 1 14
      src/renderers/WebGLRenderer.js
  2. 19 0
      src/renderers/webgl/WebGLState.js

+ 1 - 14
src/renderers/WebGLRenderer.js

@@ -245,20 +245,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	var setDefaultGLState = function () {
 
-		_gl.clearColor( 0, 0, 0, 1 );
-		_gl.clearDepth( 1 );
-		_gl.clearStencil( 0 );
-
-		_gl.enable( _gl.DEPTH_TEST );
-		_gl.depthFunc( _gl.LEQUAL );
-
-		_gl.frontFace( _gl.CCW );
-		_gl.cullFace( _gl.BACK );
-		_gl.enable( _gl.CULL_FACE );
-
-		_gl.enable( _gl.BLEND );
-		_gl.blendEquation( _gl.FUNC_ADD );
-		_gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA );
+		state.init();
 
 		_gl.viewport( _viewportX, _viewportY, _viewportWidth, _viewportHeight );
 

+ 19 - 0
src/renderers/webgl/WebGLState.js

@@ -37,6 +37,25 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
 	var currentTextureSlot = undefined;
 	var currentBoundTextures = {};
 
+	this.init = function () {
+
+		gl.clearColor( 0, 0, 0, 1 );
+		gl.clearDepth( 1 );
+		gl.clearStencil( 0 );
+
+		gl.enable( gl.DEPTH_TEST );
+		gl.depthFunc( gl.LEQUAL );
+
+		gl.frontFace( gl.CCW );
+		gl.cullFace( gl.BACK );
+		gl.enable( gl.CULL_FACE );
+
+		gl.enable( gl.BLEND );
+		gl.blendEquation( gl.FUNC_ADD );
+		gl.blendFunc( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA );
+
+	};
+
 	this.initAttributes = function () {
 
 		for ( var i = 0, l = newAttributes.length; i < l; i ++ ) {