Skip to content

Commit 056e74d

Browse files
committed
Added compression object for future texture compression support.
1 parent 39cf725 commit 056e74d

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
* 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()`.
1010
* WebGLRenderer.config has a new property `maxTextureSize` which is derived from `gl.MAX_TEXTURE_SIZE`, you can get it via the new method `getMaxTextureSize()`
11+
* WebGLRenderer has a new property `compression` which holds the browser / devices compressed texture support gl extensions, which is populated during `init`.
1112

1213
### Bug Fixes
1314

1415
* The Script File type in the Loader didn't create itself correctly as it was missing an argument (thanks @TadejZupancic)
1516
* The Plugin File type in the Loader didn't create itself correctly as it was missing an argument.
17+
* 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)
1618

1719
### Examples, Documentation and TypeScript
1820

src/renderer/webgl/WebGLRenderer.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,19 @@ var WebGLRenderer = new Class({
390390
*/
391391
this.glFormats = [];
392392

393+
/**
394+
* Stores the supported WebGL texture compression formats.
395+
*
396+
* @name Phaser.Renderer.WebGL.WebGLRenderer#compression
397+
* @type {array}
398+
* @since 3.8.0
399+
*/
400+
this.compression = {
401+
ETC1: false,
402+
PVRTC: false,
403+
S3TC: false
404+
};
405+
393406
this.init(this.config);
394407
},
395408

@@ -434,7 +447,7 @@ var WebGLRenderer = new Class({
434447
this.glFormats[4] = gl.FLOAT;
435448

436449
// Load supported extensions
437-
this.supportedExtensions = gl.getSupportedExtensions();
450+
var exts = gl.getSupportedExtensions();
438451

439452
var config = this.config;
440453

@@ -448,6 +461,15 @@ var WebGLRenderer = new Class({
448461
config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
449462
}
450463

464+
var extString = 'WEBGL_compressed_texture_'
465+
var wkExtString = 'WEBKIT_' + extString;
466+
467+
this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1');
468+
this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc');
469+
this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc');
470+
471+
this.supportedExtensions = exts;
472+
451473
// Setup initial WebGL state
452474
gl.disable(gl.DEPTH_TEST);
453475
gl.disable(gl.CULL_FACE);

0 commit comments

Comments
 (0)