mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Bitmap Text renderer now uses tint component values.
This commit is contained in:
parent
fb713ab5ec
commit
7a9f80e4df
2 changed files with 32 additions and 23 deletions
|
@ -15,10 +15,14 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
var cameraScrollY = camera.scrollY * gameObject.scrollFactorY;
|
var cameraScrollY = camera.scrollY * gameObject.scrollFactorY;
|
||||||
var text = gameObject.text;
|
var text = gameObject.text;
|
||||||
var textLength = text.length;
|
var textLength = text.length;
|
||||||
var chars = gameObject.fontData.data.chars;
|
var chars = gameObject.fontData.chars;
|
||||||
var lineHeight = gameObject.fontData.lineHeight;
|
var lineHeight = gameObject.fontData.lineHeight;
|
||||||
var spriteBatch = renderer.spriteBatch;
|
var spriteBatch = renderer.spriteBatch;
|
||||||
var alpha = gameObject.alpha;
|
var alpha = gameObject.alpha;
|
||||||
|
var tintTL = gameObject._tintTL;
|
||||||
|
var tintTR = gameObject._tintTR;
|
||||||
|
var tintBL = gameObject._tintBL;
|
||||||
|
var tintBR = gameObject._tintBR;
|
||||||
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
||||||
var vertexBuffer = vertexDataBuffer.floatView;
|
var vertexBuffer = vertexDataBuffer.floatView;
|
||||||
var vertexBufferU32 = vertexDataBuffer.uintView;
|
var vertexBufferU32 = vertexDataBuffer.uintView;
|
||||||
|
@ -38,7 +42,6 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
var glyphY = 0;
|
var glyphY = 0;
|
||||||
var glyphW = 0;
|
var glyphW = 0;
|
||||||
var glyphH = 0;
|
var glyphH = 0;
|
||||||
var vertexColor = 0xFFFFFFFF;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
var rotation = 0;
|
var rotation = 0;
|
||||||
|
@ -54,14 +57,14 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
var cameraMatrix = camera.matrix.matrix;
|
var cameraMatrix = camera.matrix.matrix;
|
||||||
var mva, mvb, mvc, mvd, mve, mvf, tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3;
|
var mva, mvb, mvc, mvd, mve, mvf, tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3;
|
||||||
var sra, srb, src, srd, sre, srf, cma, cmb, cmc, cmd, cme, cmf;
|
var sra, srb, src, srd, sre, srf, cma, cmb, cmc, cmd, cme, cmf;
|
||||||
var scale = (gameObject.fontSize / gameObject.fontData.data.size);
|
var scale = (gameObject.fontSize / gameObject.fontData.size);
|
||||||
var uta, utb, utc, utd, ute, utf;
|
var uta, utb, utc, utd, ute, utf;
|
||||||
var tempMatrixCharMatrix = tempMatrixChar.matrix;
|
var tempMatrixCharMatrix = tempMatrixChar.matrix;
|
||||||
var renderTarget = gameObject.renderTarget;
|
var renderTarget = gameObject.renderTarget;
|
||||||
|
|
||||||
tempMatrix.applyITRS(
|
tempMatrix.applyITRS(
|
||||||
gameObject.x - cameraScrollX, gameObject.y - cameraScrollY,
|
gameObject.x - cameraScrollX, gameObject.y - cameraScrollY,
|
||||||
-gameObject.rotation,
|
-gameObject.rotation,
|
||||||
gameObject.scaleX, gameObject.scaleY
|
gameObject.scaleX, gameObject.scaleY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -128,10 +131,13 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
|
|
||||||
glyphX = textureX + glyph.x;
|
glyphX = textureX + glyph.x;
|
||||||
glyphY = textureY + glyph.y;
|
glyphY = textureY + glyph.y;
|
||||||
|
|
||||||
glyphW = glyph.width;
|
glyphW = glyph.width;
|
||||||
glyphH = glyph.height;
|
glyphH = glyph.height;
|
||||||
|
|
||||||
x = (indexCount + glyph.xOffset + xAdvance) * scale;
|
x = (indexCount + glyph.xOffset + xAdvance) * scale;
|
||||||
y = (glyph.yOffset + yAdvance) * scale;
|
y = (glyph.yOffset + yAdvance) * scale;
|
||||||
|
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
|
|
||||||
if (lastGlyph !== null)
|
if (lastGlyph !== null)
|
||||||
|
@ -142,13 +148,17 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
|
|
||||||
if (displayCallback)
|
if (displayCallback)
|
||||||
{
|
{
|
||||||
var output = displayCallback({ color: 0xFFFFFF, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data });
|
var output = displayCallback({ tint: { topLeft: tintTL, topRight: tintTR, bottomLeft: tintBL, bottomRight: tintBR }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data });
|
||||||
|
|
||||||
x = output.x;
|
x = output.x;
|
||||||
y = output.y;
|
y = output.y;
|
||||||
scale = output.scale;
|
scale = output.scale;
|
||||||
rotation = output.rotation;
|
rotation = output.rotation;
|
||||||
vertexColor = output.color;
|
|
||||||
|
tintTL = output.tint.topLeft;
|
||||||
|
tintTR = output.tint.topRight;
|
||||||
|
tintBL = output.tint.bottomLeft;
|
||||||
|
tintBR = output.tint.bottomRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
x -= gameObject.scrollX | 0;
|
x -= gameObject.scrollX | 0;
|
||||||
|
@ -202,28 +212,28 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, gameObject, interpolati
|
||||||
vertexBuffer[vertexOffset++] = ty0;
|
vertexBuffer[vertexOffset++] = ty0;
|
||||||
vertexBuffer[vertexOffset++] = umin;
|
vertexBuffer[vertexOffset++] = umin;
|
||||||
vertexBuffer[vertexOffset++] = vmin;
|
vertexBuffer[vertexOffset++] = vmin;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintTL;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx1;
|
vertexBuffer[vertexOffset++] = tx1;
|
||||||
vertexBuffer[vertexOffset++] = ty1;
|
vertexBuffer[vertexOffset++] = ty1;
|
||||||
vertexBuffer[vertexOffset++] = umin;
|
vertexBuffer[vertexOffset++] = umin;
|
||||||
vertexBuffer[vertexOffset++] = vmax;
|
vertexBuffer[vertexOffset++] = vmax;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintBL;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx2;
|
vertexBuffer[vertexOffset++] = tx2;
|
||||||
vertexBuffer[vertexOffset++] = ty2;
|
vertexBuffer[vertexOffset++] = ty2;
|
||||||
vertexBuffer[vertexOffset++] = umax;
|
vertexBuffer[vertexOffset++] = umax;
|
||||||
vertexBuffer[vertexOffset++] = vmax;
|
vertexBuffer[vertexOffset++] = vmax;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintBR;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx3;
|
vertexBuffer[vertexOffset++] = tx3;
|
||||||
vertexBuffer[vertexOffset++] = ty3;
|
vertexBuffer[vertexOffset++] = ty3;
|
||||||
vertexBuffer[vertexOffset++] = umax;
|
vertexBuffer[vertexOffset++] = umax;
|
||||||
vertexBuffer[vertexOffset++] = vmin;
|
vertexBuffer[vertexOffset++] = vmin;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintTR;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
xAdvance += glyph.xAdvance;
|
xAdvance += glyph.xAdvance;
|
||||||
|
|
|
@ -17,11 +17,15 @@ var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPerce
|
||||||
var lineHeight = gameObject.fontData.lineHeight;
|
var lineHeight = gameObject.fontData.lineHeight;
|
||||||
var spriteBatch = renderer.spriteBatch;
|
var spriteBatch = renderer.spriteBatch;
|
||||||
var alpha = gameObject.alpha;
|
var alpha = gameObject.alpha;
|
||||||
|
var tintTL = gameObject._tintTL;
|
||||||
|
var tintTR = gameObject._tintTR;
|
||||||
|
var tintBL = gameObject._tintBL;
|
||||||
|
var tintBR = gameObject._tintBR;
|
||||||
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
||||||
var vertexBuffer = vertexDataBuffer.floatView;
|
var vertexBuffer = vertexDataBuffer.floatView;
|
||||||
var vertexBufferU32 = vertexDataBuffer.uintView;
|
var vertexBufferU32 = vertexDataBuffer.uintView;
|
||||||
var vertexOffset = 0;
|
var vertexOffset = 0;
|
||||||
var srcX = gameObject.x;
|
var srcX = gameObject.x;
|
||||||
var srcY = gameObject.y;
|
var srcY = gameObject.y;
|
||||||
var textureData = gameObject.texture.source[textureFrame.sourceIndex];
|
var textureData = gameObject.texture.source[textureFrame.sourceIndex];
|
||||||
var textureX = textureFrame.cutX;
|
var textureX = textureFrame.cutX;
|
||||||
|
@ -38,15 +42,10 @@ var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPerce
|
||||||
var glyphY = 0;
|
var glyphY = 0;
|
||||||
var glyphW = 0;
|
var glyphW = 0;
|
||||||
var glyphH = 0;
|
var glyphH = 0;
|
||||||
var vertexColor = 0xFFFFFFFF;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
var xw = 0;
|
var xw = 0;
|
||||||
var yh = 0;
|
var yh = 0;
|
||||||
var tx = 0;
|
|
||||||
var ty = 0;
|
|
||||||
var txw = 0;
|
|
||||||
var tyh = 0;
|
|
||||||
var umin = 0;
|
var umin = 0;
|
||||||
var umax = 0;
|
var umax = 0;
|
||||||
var vmin = 0;
|
var vmin = 0;
|
||||||
|
@ -61,8 +60,8 @@ var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPerce
|
||||||
var renderTarget = gameObject.renderTarget;
|
var renderTarget = gameObject.renderTarget;
|
||||||
|
|
||||||
tempMatrix.applyITRS(
|
tempMatrix.applyITRS(
|
||||||
(srcX - cameraScrollX) + textureFrame.x, (srcY - cameraScrollY) + textureFrame.y,
|
(srcX - cameraScrollX) + textureFrame.x, (srcY - cameraScrollY) + textureFrame.y,
|
||||||
-gameObject.rotation,
|
-gameObject.rotation,
|
||||||
gameObject.scaleX, gameObject.scaleY
|
gameObject.scaleX, gameObject.scaleY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -159,28 +158,28 @@ var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPerce
|
||||||
vertexBuffer[vertexOffset++] = ty0;
|
vertexBuffer[vertexOffset++] = ty0;
|
||||||
vertexBuffer[vertexOffset++] = umin;
|
vertexBuffer[vertexOffset++] = umin;
|
||||||
vertexBuffer[vertexOffset++] = vmin;
|
vertexBuffer[vertexOffset++] = vmin;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintTL;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx1;
|
vertexBuffer[vertexOffset++] = tx1;
|
||||||
vertexBuffer[vertexOffset++] = ty1;
|
vertexBuffer[vertexOffset++] = ty1;
|
||||||
vertexBuffer[vertexOffset++] = umin;
|
vertexBuffer[vertexOffset++] = umin;
|
||||||
vertexBuffer[vertexOffset++] = vmax;
|
vertexBuffer[vertexOffset++] = vmax;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintBL;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx2;
|
vertexBuffer[vertexOffset++] = tx2;
|
||||||
vertexBuffer[vertexOffset++] = ty2;
|
vertexBuffer[vertexOffset++] = ty2;
|
||||||
vertexBuffer[vertexOffset++] = umax;
|
vertexBuffer[vertexOffset++] = umax;
|
||||||
vertexBuffer[vertexOffset++] = vmax;
|
vertexBuffer[vertexOffset++] = vmax;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintTR;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
|
|
||||||
vertexBuffer[vertexOffset++] = tx3;
|
vertexBuffer[vertexOffset++] = tx3;
|
||||||
vertexBuffer[vertexOffset++] = ty3;
|
vertexBuffer[vertexOffset++] = ty3;
|
||||||
vertexBuffer[vertexOffset++] = umax;
|
vertexBuffer[vertexOffset++] = umax;
|
||||||
vertexBuffer[vertexOffset++] = vmin;
|
vertexBuffer[vertexOffset++] = vmin;
|
||||||
vertexBufferU32[vertexOffset++] = vertexColor;
|
vertexBufferU32[vertexOffset++] = tintBR;
|
||||||
vertexBuffer[vertexOffset++] = alpha;
|
vertexBuffer[vertexOffset++] = alpha;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue