Browse Source

WebGLState: Removed getCompressedTextureFormats method.

Mr.doob 5 years ago
parent
commit
6d35d8b582

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -274,7 +274,7 @@ function WebGLRenderer( parameters ) {
 
 
 		utils = new WebGLUtils( _gl, extensions, capabilities );
 		utils = new WebGLUtils( _gl, extensions, capabilities );
 
 
-		state = new WebGLState( _gl, extensions, utils, capabilities );
+		state = new WebGLState( _gl, extensions, capabilities );
 		state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
 		state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
 		state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
 		state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
 
 

+ 1 - 2
src/renderers/webgl/WebGLState.d.ts

@@ -44,7 +44,7 @@ export class WebGLStencilBuffer {
 
 
 export class WebGLState {
 export class WebGLState {
 
 
-	constructor( gl: WebGLRenderingContext, extensions: WebGLExtensions, utils: any, capabilities: WebGLCapabilities );
+	constructor( gl: WebGLRenderingContext, extensions: WebGLExtensions, capabilities: WebGLCapabilities );
 
 
 	buffers: {
 	buffers: {
 		color: WebGLColorBuffer;
 		color: WebGLColorBuffer;
@@ -58,7 +58,6 @@ export class WebGLState {
 	disableUnusedAttributes(): void;
 	disableUnusedAttributes(): void;
 	enable( id: number ): void;
 	enable( id: number ): void;
 	disable( id: number ): void;
 	disable( id: number ): void;
-	getCompressedTextureFormats(): number[];
 	useProgram( program: any ): boolean;
 	useProgram( program: any ): boolean;
 	setBlending(
 	setBlending(
 		blending: Blending,
 		blending: Blending,

+ 1 - 34
src/renderers/webgl/WebGLState.js

@@ -5,7 +5,7 @@
 import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';
 import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';
 import { Vector4 } from '../../math/Vector4.js';
 import { Vector4 } from '../../math/Vector4.js';
 
 
-function WebGLState( gl, extensions, utils, capabilities ) {
+function WebGLState( gl, extensions, capabilities ) {
 
 
 	var isWebGL2 = capabilities.isWebGL2;
 	var isWebGL2 = capabilities.isWebGL2;
 
 
@@ -325,8 +325,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 
 
 	var enabledCapabilities = {};
 	var enabledCapabilities = {};
 
 
-	var compressedTextureFormats = null;
-
 	var currentProgram = null;
 	var currentProgram = null;
 
 
 	var currentBlendingEnabled = null;
 	var currentBlendingEnabled = null;
@@ -486,33 +484,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 
 
 	}
 	}
 
 
-	function getCompressedTextureFormats() {
-
-		if ( compressedTextureFormats === null ) {
-
-			compressedTextureFormats = [];
-
-			if ( extensions.get( 'WEBGL_compressed_texture_pvrtc' ) ||
-			     extensions.get( 'WEBGL_compressed_texture_s3tc' ) ||
-			     extensions.get( 'WEBGL_compressed_texture_etc1' ) ||
-			     extensions.get( 'WEBGL_compressed_texture_astc' ) ) {
-
-				var formats = gl.getParameter( gl.COMPRESSED_TEXTURE_FORMATS );
-
-				for ( var i = 0; i < formats.length; i ++ ) {
-
-					compressedTextureFormats.push( formats[ i ] );
-
-				}
-
-			}
-
-		}
-
-		return compressedTextureFormats;
-
-	}
-
 	function useProgram( program ) {
 	function useProgram( program ) {
 
 
 		if ( currentProgram !== program ) {
 		if ( currentProgram !== program ) {
@@ -965,8 +936,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 
 
 		enabledCapabilities = {};
 		enabledCapabilities = {};
 
 
-		compressedTextureFormats = null;
-
 		currentTextureSlot = null;
 		currentTextureSlot = null;
 		currentBoundTextures = {};
 		currentBoundTextures = {};
 
 
@@ -997,7 +966,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 		disableUnusedAttributes: disableUnusedAttributes,
 		disableUnusedAttributes: disableUnusedAttributes,
 		enable: enable,
 		enable: enable,
 		disable: disable,
 		disable: disable,
-		getCompressedTextureFormats: getCompressedTextureFormats,
 
 
 		useProgram: useProgram,
 		useProgram: useProgram,
 
 
@@ -1028,5 +996,4 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 
 
 }
 }
 
 
-
 export { WebGLState };
 export { WebGLState };

+ 2 - 2
src/renderers/webgl/WebGLTextures.js

@@ -434,7 +434,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 						if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
 						if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
 
 
-							if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) {
+							if ( glFormat !== null ) {
 
 
 								state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
 								state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
 
 
@@ -733,7 +733,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 				if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
 				if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
 
 
-					if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) {
+					if ( glFormat !== null ) {
 
 
 						state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
 						state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
 
 

+ 41 - 5
src/renderers/webgl/WebGLUtils.js

@@ -30,7 +30,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 
 			extension = extensions.get( 'OES_texture_half_float' );
 			extension = extensions.get( 'OES_texture_half_float' );
 
 
-			if ( extension !== null ) return extension.HALF_FLOAT_OES;
+			if ( extension !== null ) {
+
+				return extension.HALF_FLOAT_OES;
+
+			} else {
+
+				return null;
+
+			}
 
 
 		}
 		}
 
 
@@ -55,6 +63,10 @@ function WebGLUtils( gl, extensions, capabilities ) {
 				if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
 				if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
 				if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
 				if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
 
 
+			} else {
+
+				return null;
+
 			}
 			}
 
 
 		}
 		}
@@ -71,6 +83,10 @@ function WebGLUtils( gl, extensions, capabilities ) {
 				if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
 				if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
 				if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
 				if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
 
 
+			} else {
+
+				return null;
+
 			}
 			}
 
 
 		}
 		}
@@ -79,7 +95,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 
 			extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
 			extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
 
 
-			if ( extension !== null ) return extension.COMPRESSED_RGB_ETC1_WEBGL;
+			if ( extension !== null ) {
+
+				return extension.COMPRESSED_RGB_ETC1_WEBGL;
+
+			} else {
+
+				return null;
+
+			}
 
 
 		}
 		}
 
 
@@ -93,8 +117,14 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 
 			if ( extension !== null ) {
 			if ( extension !== null ) {
 
 
+				// TODO Complete?
+
 				return p;
 				return p;
 
 
+			} else {
+
+				return null;
+
 			}
 			}
 
 
 		}
 		}
@@ -105,11 +135,17 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 
 			extension = extensions.get( 'WEBGL_depth_texture' );
 			extension = extensions.get( 'WEBGL_depth_texture' );
 
 
-			if ( extension !== null ) return extension.UNSIGNED_INT_24_8_WEBGL;
+			if ( extension !== null ) {
 
 
-		}
+				return extension.UNSIGNED_INT_24_8_WEBGL;
+
+			} else {
+
+				return null;
 
 
-		return 0;
+			}
+
+		}
 
 
 	}
 	}