Skip to content

Commit 5fdf51c

Browse files
committed
Using direct pipeline calls
1 parent 17112ec commit 5fdf51c

2 files changed

Lines changed: 85 additions & 2 deletions

File tree

src/gameobjects/text/static/TextWebGLRenderer.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
var GameObject = require('../../GameObject');
8+
var Utils = require('../../../renderer/webgl/Utils');
89

910
/**
1011
* Renders this Game Object with the WebGL Renderer to the given Camera.
@@ -34,7 +35,29 @@ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera
3435
src.dirty = false;
3536
}
3637

37-
this.pipeline.batchText(this, camera, parentMatrix);
38+
var getTint = Utils.getTintAppendFloatAlpha;
39+
40+
this.pipeline.batchTexture(
41+
src,
42+
src.canvasTexture,
43+
src.canvasTexture.width, src.canvasTexture.height,
44+
src.x, src.y,
45+
src.canvasTexture.width, src.canvasTexture.height,
46+
src.scaleX, src.scaleY,
47+
src.rotation,
48+
src.flipX, src.flipY,
49+
src.scrollFactorX, src.scrollFactorY,
50+
src.displayOriginX, src.displayOriginY,
51+
0, 0, src.canvasTexture.width, src.canvasTexture.height,
52+
getTint(src._tintTL, camera.alpha * src._alphaTL),
53+
getTint(src._tintTR, camera.alpha * src._alphaTR),
54+
getTint(src._tintBL, camera.alpha * src._alphaBL),
55+
getTint(src._tintBR, camera.alpha * src._alphaBR),
56+
(src._isTinted && src.tintFill),
57+
0, 0,
58+
camera,
59+
parentMatrix
60+
);
3861
};
3962

4063
module.exports = TextWebGLRenderer;

src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
var GameObject = require('../../gameobjects/GameObject');
8+
var Utils = require('../../renderer/webgl/Utils');
89

910
/**
1011
* Renders this Game Object with the WebGL Renderer to the given Camera.
@@ -29,7 +30,66 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
2930

3031
src.cull(camera);
3132

32-
this.pipeline.batchDynamicTilemapLayer(src, camera);
33+
var pipeline = this.pipeline;
34+
35+
var getTint = Utils.getTintAppendFloatAlpha;
36+
37+
var renderTiles = src.culledTiles;
38+
var length = renderTiles.length;
39+
var tileset = src.tileset;
40+
var texture = tileset.glTexture;
41+
42+
var scrollFactorX = src.scrollFactorX;
43+
var scrollFactorY = src.scrollFactorY;
44+
45+
var alpha = camera.alpha * src.alpha;
46+
47+
var x = src.x;
48+
var y = src.y;
49+
50+
var sx = src.scaleX;
51+
var sy = src.scaleY;
52+
53+
for (var index = 0; index < length; index++)
54+
{
55+
var tile = renderTiles[index];
56+
57+
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
58+
59+
if (tileTexCoords === null)
60+
{
61+
continue;
62+
}
63+
64+
var frameWidth = tile.width;
65+
var frameHeight = tile.height;
66+
67+
var frameX = tileTexCoords.x;
68+
var frameY = tileTexCoords.y;
69+
70+
var tw = tile.width * 0.5;
71+
var th = tile.height * 0.5;
72+
73+
var tint = getTint(tile.tint, alpha * tile.alpha);
74+
75+
pipeline.batchTexture(
76+
src,
77+
texture,
78+
texture.width, texture.height,
79+
tw + x + tile.pixelX * sx, th + y + tile.pixelY * sy,
80+
tile.width * sx, tile.height * sy,
81+
1, 1,
82+
tile.rotation,
83+
tile.flipX, tile.flipY,
84+
scrollFactorX, scrollFactorY,
85+
tw, th,
86+
frameX, frameY, frameWidth, frameHeight,
87+
tint, tint, tint, tint, false,
88+
0, 0,
89+
camera,
90+
null
91+
);
92+
}
3393
};
3494

3595
module.exports = DynamicTilemapLayerWebGLRenderer;

0 commit comments

Comments
 (0)