mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
fixed issues with conflict resolving
This commit is contained in:
parent
d0c23c15b5
commit
702bc9b69f
1 changed files with 75 additions and 0 deletions
|
@ -28,6 +28,8 @@ PIXI.WebGLRenderer = function(game) {
|
||||||
PIXI.defaultRenderer = this;
|
PIXI.defaultRenderer = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.extensions = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property type
|
* @property type
|
||||||
* @type Number
|
* @type Number
|
||||||
|
@ -247,6 +249,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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,6 +439,65 @@ PIXI.WebGLRenderer.prototype.resize = function(width, height)
|
||||||
this.projection.y = -this.height / 2 / this.resolution;
|
this.projection.y = -this.height / 2 / this.resolution;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates and creates a WebGL compressed texture for the renderers context.
|
||||||
|
*
|
||||||
|
* @method updateCompressedTexture
|
||||||
|
* @param texture {Texture} the texture to update
|
||||||
|
* @return {boolean} True if the texture was successfully bound, otherwise false.
|
||||||
|
*/
|
||||||
|
PIXI.WebGLRenderer.prototype.updateCompressedTexture = function (texture) {
|
||||||
|
if (!texture.hasLoaded)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var gl = this.gl;
|
||||||
|
var textureMetaData = texture.source;
|
||||||
|
|
||||||
|
if (!texture._glTextures[gl.id])
|
||||||
|
{
|
||||||
|
texture._glTextures[gl.id] = gl.createTexture();
|
||||||
|
}
|
||||||
|
gl.activeTexture(gl.TEXTURE0 + texture.textureIndex);
|
||||||
|
|
||||||
|
gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
|
||||||
|
|
||||||
|
gl.compressedTexImage2D(
|
||||||
|
gl.TEXTURE_2D,
|
||||||
|
0,
|
||||||
|
textureMetaData.glExtensionFormat,
|
||||||
|
textureMetaData.width,
|
||||||
|
textureMetaData.height,
|
||||||
|
0,
|
||||||
|
textureMetaData.textureData
|
||||||
|
);
|
||||||
|
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
|
||||||
|
|
||||||
|
if (texture.mipmap && PIXI.isPowerOfTwo(texture.width, texture.height))
|
||||||
|
{
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);
|
||||||
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!texture._powerOf2)
|
||||||
|
{
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
|
||||||
|
}
|
||||||
|
texture._dirty[gl.id] = false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates and Creates a WebGL texture for the renderers context.
|
* Updates and Creates a WebGL texture for the renderers context.
|
||||||
*
|
*
|
||||||
|
@ -439,6 +511,9 @@ PIXI.WebGLRenderer.prototype.updateTexture = function(texture)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (texture.source.compressionAlgorithm) {
|
||||||
|
return this.updateCompressedTexture(texture);
|
||||||
|
}
|
||||||
|
|
||||||
var gl = this.gl;
|
var gl = this.gl;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue