mirror of
https://github.com/photonstorm/phaser
synced 2025-01-05 09:48:49 +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) {
|
addCompressedTextureMetaData: function (key, url, extension, arrayBuffer) {
|
||||||
|
var data = (extension in Phaser.LoaderParser) ? Phaser.LoaderParser[extension](arrayBuffer) : arrayBuffer;
|
||||||
this._cache.compressedTexture[key] = {
|
this._cache.compressedTexture[key] = {
|
||||||
data: Phaser.LoaderParser[extension](arrayBuffer),
|
data: data,
|
||||||
url: url,
|
url: url,
|
||||||
key: key,
|
key: key,
|
||||||
fileFormat: extension
|
fileFormat: extension
|
||||||
|
|
|
@ -720,7 +720,17 @@ Phaser.Loader.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
texture: function (key, object, overwrite) {
|
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;
|
file.errorMessage = errorMessage;
|
||||||
|
|
||||||
console.warn('Phaser.Loader - ' + file.type + '[' + file.key + ']' + ': ' + errorMessage);
|
console.warn('Phaser.Loader - ' + file.type + '[' + file.key + ']' + ': ' + errorMessage);
|
||||||
// debugger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.processLoadQueue();
|
this.processLoadQueue();
|
||||||
|
@ -2192,6 +2201,10 @@ Phaser.Loader.prototype = {
|
||||||
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
|
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
|
||||||
break;
|
break;
|
||||||
case 'texture':
|
case 'texture':
|
||||||
|
if (file.key.split('_').pop() === 'truecolor') {
|
||||||
|
this.loadImageTag(file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'binary':
|
case 'binary':
|
||||||
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
|
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
|
||||||
break;
|
break;
|
||||||
|
@ -2666,6 +2679,9 @@ Phaser.Loader.prototype = {
|
||||||
file.data = data || {};
|
file.data = data || {};
|
||||||
break;
|
break;
|
||||||
case 'texture':
|
case 'texture':
|
||||||
|
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);
|
this.cache.addCompressedTextureMetaData(file.key, file.url, file.url.split('.').pop().toLowerCase(), xhr.response);
|
||||||
break;
|
break;
|
||||||
case 'image':
|
case 'image':
|
||||||
|
|
|
@ -34,6 +34,8 @@ PIXI.WebGLRenderer = function (game) {
|
||||||
*/
|
*/
|
||||||
this.type = PIXI.WEBGL_RENDERER;
|
this.type = PIXI.WEBGL_RENDERER;
|
||||||
|
|
||||||
|
this.extensions = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resolution of the renderer
|
* The resolution of the renderer
|
||||||
*
|
*
|
||||||
|
@ -208,6 +210,7 @@ PIXI.WebGLRenderer.prototype.constructor = PIXI.WebGLRenderer;
|
||||||
PIXI.WebGLRenderer.prototype.initContext = function()
|
PIXI.WebGLRenderer.prototype.initContext = function()
|
||||||
{
|
{
|
||||||
var gl = this.view.getContext('webgl', this._contextOptions) || this.view.getContext('experimental-webgl', this._contextOptions);
|
var gl = this.view.getContext('webgl', this._contextOptions) || this.view.getContext('experimental-webgl', this._contextOptions);
|
||||||
|
var etc1, pvrtc, s3tc;
|
||||||
|
|
||||||
this.gl = gl;
|
this.gl = gl;
|
||||||
this.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
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!
|
// now resize and we are good to go!
|
||||||
this.resize(this.width, this.height);
|
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) {
|
PIXI.WebGLRenderer.prototype.setTexturePriority = function (textureNameCollection) {
|
||||||
|
|
Loading…
Reference in a new issue