mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 14:38:30 +00:00
Using direct pipeline calls
This commit is contained in:
parent
17112ecd20
commit
5fdf51ce59
2 changed files with 85 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
var GameObject = require('../../GameObject');
|
||||
var Utils = require('../../../renderer/webgl/Utils');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the WebGL Renderer to the given Camera.
|
||||
|
@ -34,7 +35,29 @@ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera
|
|||
src.dirty = false;
|
||||
}
|
||||
|
||||
this.pipeline.batchText(this, camera, parentMatrix);
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
|
||||
this.pipeline.batchTexture(
|
||||
src,
|
||||
src.canvasTexture,
|
||||
src.canvasTexture.width, src.canvasTexture.height,
|
||||
src.x, src.y,
|
||||
src.canvasTexture.width, src.canvasTexture.height,
|
||||
src.scaleX, src.scaleY,
|
||||
src.rotation,
|
||||
src.flipX, src.flipY,
|
||||
src.scrollFactorX, src.scrollFactorY,
|
||||
src.displayOriginX, src.displayOriginY,
|
||||
0, 0, src.canvasTexture.width, src.canvasTexture.height,
|
||||
getTint(src._tintTL, camera.alpha * src._alphaTL),
|
||||
getTint(src._tintTR, camera.alpha * src._alphaTR),
|
||||
getTint(src._tintBL, camera.alpha * src._alphaBL),
|
||||
getTint(src._tintBR, camera.alpha * src._alphaBR),
|
||||
(src._isTinted && src.tintFill),
|
||||
0, 0,
|
||||
camera,
|
||||
parentMatrix
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = TextWebGLRenderer;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
var GameObject = require('../../gameobjects/GameObject');
|
||||
var Utils = require('../../renderer/webgl/Utils');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the WebGL Renderer to the given Camera.
|
||||
|
@ -29,7 +30,66 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
|||
|
||||
src.cull(camera);
|
||||
|
||||
this.pipeline.batchDynamicTilemapLayer(src, camera);
|
||||
var pipeline = this.pipeline;
|
||||
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
|
||||
var renderTiles = src.culledTiles;
|
||||
var length = renderTiles.length;
|
||||
var tileset = src.tileset;
|
||||
var texture = tileset.glTexture;
|
||||
|
||||
var scrollFactorX = src.scrollFactorX;
|
||||
var scrollFactorY = src.scrollFactorY;
|
||||
|
||||
var alpha = camera.alpha * src.alpha;
|
||||
|
||||
var x = src.x;
|
||||
var y = src.y;
|
||||
|
||||
var sx = src.scaleX;
|
||||
var sy = src.scaleY;
|
||||
|
||||
for (var index = 0; index < length; index++)
|
||||
{
|
||||
var tile = renderTiles[index];
|
||||
|
||||
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
||||
|
||||
if (tileTexCoords === null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var frameWidth = tile.width;
|
||||
var frameHeight = tile.height;
|
||||
|
||||
var frameX = tileTexCoords.x;
|
||||
var frameY = tileTexCoords.y;
|
||||
|
||||
var tw = tile.width * 0.5;
|
||||
var th = tile.height * 0.5;
|
||||
|
||||
var tint = getTint(tile.tint, alpha * tile.alpha);
|
||||
|
||||
pipeline.batchTexture(
|
||||
src,
|
||||
texture,
|
||||
texture.width, texture.height,
|
||||
tw + x + tile.pixelX * sx, th + y + tile.pixelY * sy,
|
||||
tile.width * sx, tile.height * sy,
|
||||
1, 1,
|
||||
tile.rotation,
|
||||
tile.flipX, tile.flipY,
|
||||
scrollFactorX, scrollFactorY,
|
||||
tw, th,
|
||||
frameX, frameY, frameWidth, frameHeight,
|
||||
tint, tint, tint, tint, false,
|
||||
0, 0,
|
||||
camera,
|
||||
null
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = DynamicTilemapLayerWebGLRenderer;
|
||||
|
|
Loading…
Add table
Reference in a new issue