Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand Down
3 changes: 1 addition & 2 deletions src/renderers/webgl/WebGLState.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
35 changes: 1 addition & 34 deletions src/renderers/webgl/WebGLState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -325,8 +325,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {

var enabledCapabilities = {};

var compressedTextureFormats = null;

var currentProgram = null;

var currentBlendingEnabled = null;
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -965,8 +936,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {

enabledCapabilities = {};

compressedTextureFormats = null;

currentTextureSlot = null;
currentBoundTextures = {};

Expand Down Expand Up @@ -997,7 +966,6 @@ function WebGLState( gl, extensions, utils, capabilities ) {
disableUnusedAttributes: disableUnusedAttributes,
enable: enable,
disable: disable,
getCompressedTextureFormats: getCompressedTextureFormats,

useProgram: useProgram,

Expand Down Expand Up @@ -1028,5 +996,4 @@ function WebGLState( gl, extensions, utils, capabilities ) {

}


export { WebGLState };
4 changes: 2 additions & 2 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );

Expand Down
46 changes: 41 additions & 5 deletions src/renderers/webgl/WebGLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

}

Expand All @@ -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;

}

}
Expand All @@ -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;

}

}
Expand All @@ -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;

}

}

Expand All @@ -93,8 +117,14 @@ function WebGLUtils( gl, extensions, capabilities ) {

if ( extension !== null ) {

// TODO Complete?

return p;

} else {

return null;

}

}
Expand All @@ -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;
}

}

}

Expand Down