diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index d569e6d6a7d3bb14db68c4b84bfeba19bd1b4091..e38f6086ec6049ab0fb795e06724ed0ac0c2d30c 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -274,7 +274,7 @@ function WebGLRenderer( parameters ) { 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.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() ); diff --git a/src/renderers/webgl/WebGLState.d.ts b/src/renderers/webgl/WebGLState.d.ts index fe22828767e91d6bb9810b668726bbd2e245ebca..5e4748895956bea275c079da8375ee47b7f76138 100644 --- a/src/renderers/webgl/WebGLState.d.ts +++ b/src/renderers/webgl/WebGLState.d.ts @@ -44,7 +44,7 @@ export class WebGLStencilBuffer { export class WebGLState { - constructor( gl: WebGLRenderingContext, extensions: WebGLExtensions, utils: any, capabilities: WebGLCapabilities ); + constructor( gl: WebGLRenderingContext, extensions: WebGLExtensions, capabilities: WebGLCapabilities ); buffers: { color: WebGLColorBuffer; @@ -58,7 +58,6 @@ export class WebGLState { disableUnusedAttributes(): void; enable( id: number ): void; disable( id: number ): void; - getCompressedTextureFormats(): number[]; useProgram( program: any ): boolean; setBlending( blending: Blending, diff --git a/src/renderers/webgl/WebGLState.js b/src/renderers/webgl/WebGLState.js index d56c732413531225f8ff5d9828e51e1e8ed960e6..7072651cd48a5e90aaf1511b97e60f1d6a168cfa 100644 --- a/src/renderers/webgl/WebGLState.js +++ b/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 { Vector4 } from '../../math/Vector4.js'; -function WebGLState( gl, extensions, utils, capabilities ) { +function WebGLState( gl, extensions, capabilities ) { var isWebGL2 = capabilities.isWebGL2; @@ -325,8 +325,6 @@ function WebGLState( gl, extensions, utils, capabilities ) { var enabledCapabilities = {}; - var compressedTextureFormats = null; - var currentProgram = 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 ) { if ( currentProgram !== program ) { @@ -965,8 +936,6 @@ function WebGLState( gl, extensions, utils, capabilities ) { enabledCapabilities = {}; - compressedTextureFormats = null; - currentTextureSlot = null; currentBoundTextures = {}; @@ -997,7 +966,6 @@ function WebGLState( gl, extensions, utils, capabilities ) { disableUnusedAttributes: disableUnusedAttributes, enable: enable, disable: disable, - getCompressedTextureFormats: getCompressedTextureFormats, useProgram: useProgram, @@ -1028,5 +996,4 @@ function WebGLState( gl, extensions, utils, capabilities ) { } - export { WebGLState }; diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 4746bc669727a3afbd15ead4a52fa9b7db942a94..99c2c955fbe2bae339d52903171fa641e36e14d2 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/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 ( 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 ); @@ -733,7 +733,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, 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 ); diff --git a/src/renderers/webgl/WebGLUtils.js b/src/renderers/webgl/WebGLUtils.js index 875fff2a53980c1226c1c9523559550394daaab7..2bf64a9fcacf4157457addf16cb0a669470eb489 100644 --- a/src/renderers/webgl/WebGLUtils.js +++ b/src/renderers/webgl/WebGLUtils.js @@ -30,7 +30,15 @@ function WebGLUtils( gl, extensions, capabilities ) { 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_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_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' ); - 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 ) { + // TODO Complete? + return p; + } else { + + return null; + } } @@ -105,11 +135,17 @@ function WebGLUtils( gl, extensions, capabilities ) { 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; + } + + } }