mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 00:53:42 +00:00
Texture loading depending on webgl extensions included default truecolor
This commit is contained in:
parent
0cbe8969d1
commit
100aa413bf
3 changed files with 35 additions and 4 deletions
|
@ -236,8 +236,9 @@ Phaser.Cache.prototype = {
|
|||
//////////////////
|
||||
|
||||
addCompressedTextureMetaData: function (key, url, extension, arrayBuffer) {
|
||||
var data = (extension in Phaser.LoaderParser) ? Phaser.LoaderParser[extension](arrayBuffer) : arrayBuffer;
|
||||
this._cache.compressedTexture[key] = {
|
||||
data: Phaser.LoaderParser[extension](arrayBuffer),
|
||||
data: data,
|
||||
url: url,
|
||||
key: key,
|
||||
fileFormat: extension
|
||||
|
|
|
@ -720,7 +720,17 @@ Phaser.Loader.prototype = {
|
|||
},
|
||||
|
||||
texture: function (key, object, overwrite) {
|
||||
return this.addToFileList('texture', key, object, undefined, overwrite, '.pvr');
|
||||
var compression = this.game.renderer.extensions.compression, exkey;
|
||||
if (this.game.renderType === Phaser.WEBGL) {
|
||||
for (exkey in object) {
|
||||
if (exkey in compression) {
|
||||
this.addToFileList('texture', key + '_' + exkey, object[exkey], undefined, overwrite, '.pvr');
|
||||
} else if (exkey === 'truecolor') {
|
||||
this.addToFileList('texture', key + '_' + exkey, object[exkey], undefined, overwrite, '.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1958,7 +1968,6 @@ Phaser.Loader.prototype = {
|
|||
file.errorMessage = errorMessage;
|
||||
|
||||
console.warn('Phaser.Loader - ' + file.type + '[' + file.key + ']' + ': ' + errorMessage);
|
||||
// debugger;
|
||||
}
|
||||
|
||||
this.processLoadQueue();
|
||||
|
@ -2192,6 +2201,10 @@ Phaser.Loader.prototype = {
|
|||
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
|
||||
break;
|
||||
case 'texture':
|
||||
if (file.key.split('_').pop() === 'truecolor') {
|
||||
this.loadImageTag(file);
|
||||
break;
|
||||
}
|
||||
case 'binary':
|
||||
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
|
||||
break;
|
||||
|
@ -2666,7 +2679,10 @@ Phaser.Loader.prototype = {
|
|||
file.data = data || {};
|
||||
break;
|
||||
case 'texture':
|
||||
this.cache.addCompressedTextureMetaData(file.key, file.url, file.url.split('.').pop().toLowerCase(), xhr.response);
|
||||
if (file.data != null)
|
||||
this.cache.addCompressedTextureMetaData(file.key, file.url, file.url.split('.').pop().toLowerCase(), file.data);
|
||||
else
|
||||
this.cache.addCompressedTextureMetaData(file.key, file.url, file.url.split('.').pop().toLowerCase(), xhr.response);
|
||||
break;
|
||||
case 'image':
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ PIXI.WebGLRenderer = function (game) {
|
|||
*/
|
||||
this.type = PIXI.WEBGL_RENDERER;
|
||||
|
||||
this.extensions = {};
|
||||
|
||||
/**
|
||||
* The resolution of the renderer
|
||||
*
|
||||
|
@ -208,6 +210,7 @@ PIXI.WebGLRenderer.prototype.constructor = PIXI.WebGLRenderer;
|
|||
PIXI.WebGLRenderer.prototype.initContext = function()
|
||||
{
|
||||
var gl = this.view.getContext('webgl', this._contextOptions) || this.view.getContext('experimental-webgl', this._contextOptions);
|
||||
var etc1, pvrtc, s3tc;
|
||||
|
||||
this.gl = gl;
|
||||
this.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
||||
|
@ -240,6 +243,17 @@ PIXI.WebGLRenderer.prototype.initContext = function()
|
|||
|
||||
// now resize and we are good to go!
|
||||
this.resize(this.width, this.height);
|
||||
|
||||
// Load WebGL extension
|
||||
this.extensions.compression = {};
|
||||
|
||||
etc1 = gl.getExtension('WEBGL_compressed_texture_etc1') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
|
||||
pvrtc = gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
|
||||
s3tc = gl.getExtension('WEBGL_compressed_texture_s3tc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
|
||||
|
||||
if (etc1) this.extensions.compression.etc1 = etc1;
|
||||
if (pvrtc) this.extensions.compression.pvrtc = pvrtc;
|
||||
if (s3tc) this.extensions.compression.s3tc = s3tc;
|
||||
};
|
||||
|
||||
PIXI.WebGLRenderer.prototype.setTexturePriority = function (textureNameCollection) {
|
||||
|
|
Loading…
Reference in a new issue