Skip to content

Commit

Permalink
WebGLTextures: Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Dec 20, 2019
1 parent 5f74ae5 commit a8cc32b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/renderers/webgl/WebGLTextures.js
Expand Up @@ -137,12 +137,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

function getInternalFormat( texture, glFormat, glType ) {
function getInternalFormat( internalFormatName, glFormat, glType ) {

if ( isWebGL2 === false ) return glFormat;

var internalFormatName = texture.internalFormat; // User specified internal format.

if ( internalFormatName !== null ) {

if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
Expand Down Expand Up @@ -437,7 +435,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
supportsMips = isPowerOfTwo( image ) || isWebGL2,
glFormat = utils.convert( texture.format ),
glType = utils.convert( texture.type ),
glInternalFormat = getInternalFormat( texture, glFormat, glType );
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );

setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );

Expand Down Expand Up @@ -659,7 +657,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var supportsMips = isPowerOfTwo( image ) || isWebGL2,
glFormat = utils.convert( texture.format ),
glType = utils.convert( texture.type ),
glInternalFormat = getInternalFormat( texture, glFormat, glType );
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );

setTextureParameters( textureType, texture, supportsMips );

Expand Down Expand Up @@ -832,7 +830,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

var glFormat = utils.convert( renderTarget.texture.format );
var glType = utils.convert( renderTarget.texture.type );
var glInternalFormat = getInternalFormat( renderTarget.texture, glFormat, glType );
var glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );
state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );
Expand Down Expand Up @@ -882,7 +880,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

var glFormat = utils.convert( renderTarget.texture.format );
var glType = utils.convert( renderTarget.texture.type );
var glInternalFormat = getInternalFormat( renderTarget.texture, glFormat, glType );
var glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );

if ( isMultisample ) {

Expand Down Expand Up @@ -1029,9 +1027,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();

_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );

var glFormat = utils.convert( renderTarget.texture.format );
var glType = utils.convert( renderTarget.texture.type );
var glInternalFormat = getInternalFormat( renderTarget.texture, glFormat, glType );
var glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );
var samples = getRenderTargetSamples( renderTarget );
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );

Expand Down

0 comments on commit a8cc32b

Please sign in to comment.