Added compression object for future texture compression support.

This commit is contained in:
Richard Davey 2018-05-09 13:46:19 +01:00
parent 39cf7252c9
commit 056e74d6dc
2 changed files with 25 additions and 1 deletions

View file

@ -8,11 +8,13 @@
* WebGLRenderer.config has a new property `maxTextures` which is derived from `gl.MAX_TEXTURE_IMAGE_UNITS`, you can get it via the new method `getMaxTextures()`.
* WebGLRenderer.config has a new property `maxTextureSize` which is derived from `gl.MAX_TEXTURE_SIZE`, you can get it via the new method `getMaxTextureSize()`
* WebGLRenderer has a new property `compression` which holds the browser / devices compressed texture support gl extensions, which is populated during `init`.
### Bug Fixes
* The Script File type in the Loader didn't create itself correctly as it was missing an argument (thanks @TadejZupancic)
* The Plugin File type in the Loader didn't create itself correctly as it was missing an argument.
* WebAudioSoundManager.unlock will now check if `document.body` is available before setting the listeners on it. Fixes old versions of Firefox, apparently. #3649 (thanks @squilibob)
### Examples, Documentation and TypeScript

View file

@ -390,6 +390,19 @@ var WebGLRenderer = new Class({
*/
this.glFormats = [];
/**
* Stores the supported WebGL texture compression formats.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#compression
* @type {array}
* @since 3.8.0
*/
this.compression = {
ETC1: false,
PVRTC: false,
S3TC: false
};
this.init(this.config);
},
@ -434,7 +447,7 @@ var WebGLRenderer = new Class({
this.glFormats[4] = gl.FLOAT;
// Load supported extensions
this.supportedExtensions = gl.getSupportedExtensions();
var exts = gl.getSupportedExtensions();
var config = this.config;
@ -448,6 +461,15 @@ var WebGLRenderer = new Class({
config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
}
var extString = 'WEBGL_compressed_texture_'
var wkExtString = 'WEBKIT_' + extString;
this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1');
this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc');
this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc');
this.supportedExtensions = exts;
// Setup initial WebGL state
gl.disable(gl.DEPTH_TEST);
gl.disable(gl.CULL_FACE);