mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Added getCompressedTextures method
This commit is contained in:
parent
2e06243675
commit
573dd3a14d
1 changed files with 53 additions and 11 deletions
|
@ -420,15 +420,13 @@ var WebGLRenderer = new Class({
|
|||
/**
|
||||
* Stores the supported WebGL texture compression formats.
|
||||
*
|
||||
* Overhauled in version 3.60.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.WebGLRenderer#compression
|
||||
* @type {Phaser.Types.Renderer.WebGL.WebGLTextureCompression}
|
||||
* @since 3.8.0
|
||||
*/
|
||||
this.compression = {
|
||||
ETC1: false,
|
||||
PVRTC: false,
|
||||
S3TC: false
|
||||
};
|
||||
this.compression;
|
||||
|
||||
/**
|
||||
* Cached drawing buffer height to reduce gl calls.
|
||||
|
@ -780,12 +778,7 @@ 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.compression = this.getCompressedTextures();
|
||||
|
||||
this.supportedExtensions = exts;
|
||||
|
||||
|
@ -999,6 +992,55 @@ var WebGLRenderer = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines which compressed texture formats this browser and device supports.
|
||||
*
|
||||
* Called automatically as part of the WebGL Renderer init process. If you need to investigate
|
||||
* which formats it supports, see the `Phaser.Renderer.WebGL.WebGLRenderer#compression` property instead.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.WebGLRenderer#getCompressedTextures
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @return {Phaser.Types.Renderer.WebGL.WebGLTextureCompression} The compression object.
|
||||
*/
|
||||
getCompressedTextures: function ()
|
||||
{
|
||||
var extString = 'WEBGL_compressed_texture_';
|
||||
var wkExtString = 'WEBKIT_' + extString;
|
||||
|
||||
var hasExt = function (gl, format)
|
||||
{
|
||||
var results = gl.getExtension(extString + format) || gl.getExtension(wkExtString + format);
|
||||
|
||||
if (results)
|
||||
{
|
||||
var glEnums = {};
|
||||
|
||||
for (var key in results)
|
||||
{
|
||||
glEnums[results[key]] = key;
|
||||
}
|
||||
|
||||
return glEnums;
|
||||
}
|
||||
};
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
return {
|
||||
ETC: hasExt(gl, 'etc'),
|
||||
ETC1: hasExt(gl, 'etc1'),
|
||||
ATC: hasExt(gl, 'atc'),
|
||||
ASTC: hasExt(gl, 'astc'),
|
||||
BPTC: hasExt(gl, 'bptc'),
|
||||
RGTC: hasExt(gl, 'rgtc'),
|
||||
PVRTC: hasExt(gl, 'pvrtc'),
|
||||
S3TC: hasExt(gl, 's3tc'),
|
||||
S3TCSRGB: hasExt(gl, 's3tc_srgb'),
|
||||
IMG: true
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the aspect ratio of the WebGLRenderer dimensions.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue