未验证 提交 41665054 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17783 from mrdoob/webgstate

WebGLState: Removed getCompressedTextureFormats method.
......@@ -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() );
......
......@@ -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,
......
......@@ -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 };
......@@ -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 );
......
......@@ -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;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册