mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Fix rare text sizes failing to render.
If initialized at a power-of-two resolution, then resized to a non-power-of-two resolution, some extra parameters must be updated.
This commit is contained in:
parent
a74f99563b
commit
13d6defb33
3 changed files with 46 additions and 4 deletions
|
@ -70,6 +70,7 @@ The Phaser Input and related classes have been updated to be more consistent wit
|
|||
* When a `Layer` Game Object is destroyed, i.e. from changing or restarting a Scene, it will no longer cause an error when trying to destroy the children on its display list. Fix #6675 (thanks @crockergd @gm0nk)
|
||||
* `DynamicTexture` will now automatically call `setSize(width, height)` for both WebGL and Canvas. Previously it only did it for WebGL. This fixes an issue where DynamicTextures in Canvas mode would have a width and height of -1. Fix #6682 (thanks @samme)
|
||||
* `DynamicTexture.setSize` will now check to see if the `glTexture` bound to the current frame is stale, and if so, destroy it before binding the one from the Render Target. This fixes an issue where constantly destroying and creating Dynamic Textures would cause a memory leak in WebGL. Fix #6669 (thanks @DavidTalevski)
|
||||
* Fix unpredictable text sizes failing to render in WebGL with `mipmapFilter` set. Fix #6721 (thanks @saintflow and @rexrainbow).
|
||||
* Fix MIPmap filters being effectively disabled for compressed textures.
|
||||
* `WebGLRenderer.getCompressedTextures` can now identify BPTC and RGTC support correctly. These were previously skipped.
|
||||
* PVR compressed texture files now support sRGB color space in S3TCSRGB, ETC, and ASTC formats. Fix #6247 (thanks @dominikhalvonik)
|
||||
|
|
|
@ -2955,7 +2955,7 @@ var WebGLRenderer = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY);
|
||||
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3010,17 +3010,38 @@ var WebGLRenderer = new Class({
|
|||
* @param {HTMLCanvasElement} srcCanvas - The Canvas to update the WebGL Texture from.
|
||||
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} dstTexture - The destination WebGLTextureWrapper to update.
|
||||
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
|
||||
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT` (such as for Text objects?)
|
||||
*
|
||||
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The updated WebGLTextureWrapper. This is the same wrapper object as `dstTexture`.
|
||||
*/
|
||||
updateCanvasTexture: function (srcCanvas, dstTexture, flipY)
|
||||
updateCanvasTexture: function (srcCanvas, dstTexture, flipY, noRepeat)
|
||||
{
|
||||
if (flipY === undefined) { flipY = false; }
|
||||
if (noRepeat === undefined) { noRepeat = false; }
|
||||
|
||||
var gl = this.gl;
|
||||
var minFilter = gl.NEAREST;
|
||||
var magFilter = gl.NEAREST;
|
||||
|
||||
var width = srcCanvas.width;
|
||||
var height = srcCanvas.height;
|
||||
|
||||
dstTexture.update(srcCanvas, width, height, flipY);
|
||||
var wrapping = gl.CLAMP_TO_EDGE;
|
||||
|
||||
var pow = IsSizePowerOfTwo(width, height);
|
||||
|
||||
if (!noRepeat && pow)
|
||||
{
|
||||
wrapping = gl.REPEAT;
|
||||
}
|
||||
|
||||
if (this.config.antialias)
|
||||
{
|
||||
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
|
||||
magFilter = gl.LINEAR;
|
||||
}
|
||||
|
||||
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
|
||||
|
||||
return dstTexture;
|
||||
},
|
||||
|
|
|
@ -319,8 +319,12 @@ var WebGLTextureWrapper = new Class({
|
|||
* @param {number} width - The new width of the WebGLTexture.
|
||||
* @param {number} height - The new height of the WebGLTexture.
|
||||
* @param {boolean} [flipY] - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
|
||||
* @param {number} [wrapS] - The new wrapping mode for the WebGLTexture.
|
||||
* @param {number} [wrapT] - The new wrapping mode for the WebGLTexture.
|
||||
* @param {number} [minFilter] - The new minification filter for the WebGLTexture.
|
||||
* @param {number} [magFilter] - The new magnification filter for the WebGLTexture.
|
||||
*/
|
||||
update: function (source, width, height, flipY)
|
||||
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter)
|
||||
{
|
||||
if (width === 0 || height === 0)
|
||||
{
|
||||
|
@ -332,6 +336,10 @@ var WebGLTextureWrapper = new Class({
|
|||
this.width = width;
|
||||
this.height = height;
|
||||
this.flipY = flipY;
|
||||
this.wrapS = wrapS;
|
||||
this.wrapT = wrapT;
|
||||
this.minFilter = minFilter;
|
||||
this.magFilter = magFilter;
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
|
@ -348,11 +356,23 @@ var WebGLTextureWrapper = new Class({
|
|||
|
||||
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
|
||||
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
|
||||
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
|
||||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
|
||||
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
||||
|
||||
// Should we generate mipmaps?
|
||||
var pixels = this.pixels;
|
||||
if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array))
|
||||
{
|
||||
gl.generateMipmap(gl.TEXTURE_2D);
|
||||
}
|
||||
|
||||
// Restore previous texture bind.
|
||||
if (currentTexture)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue