forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderTextureWebGLRenderer.js
More file actions
70 lines (58 loc) · 2.31 KB
/
Copy pathRenderTextureWebGLRenderer.js
File metadata and controls
70 lines (58 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Utils = require('../../renderer/webgl/Utils');
/**
* Renders this Game Object with the WebGL Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method Phaser.GameObjects.RenderTexture#renderWebGL
* @since 3.2.0
* @private
*
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer.
* @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var RenderTextureWebGLRenderer = function (renderer, src, camera, parentMatrix)
{
camera.addToRenderList(src);
var cameraAlpha = camera.alpha;
var renderTarget = src.renderTarget;
var width = renderTarget.width;
var height = renderTarget.height;
var getTint = Utils.getTintAppendFloatAlpha;
var pipeline = renderer.pipelines.set(src.pipeline);
var textureUnit = pipeline.setTexture2D(renderTarget.texture);
renderer.pipelines.preBatch(src);
pipeline.batchTexture(
src,
renderTarget.texture,
width, height,
src.x, src.y,
width, height,
src.scaleX, src.scaleY,
src.rotation,
src.flipX, !src.flipY,
src.scrollFactorX, src.scrollFactorY,
src.displayOriginX, src.displayOriginY,
0, 0, width, height,
getTint(src.tintTopLeft, cameraAlpha * src._alphaTL),
getTint(src.tintTopRight, cameraAlpha * src._alphaTR),
getTint(src.tintBottomLeft, cameraAlpha * src._alphaBL),
getTint(src.tintBottomRight, cameraAlpha * src._alphaBR),
src.tintFill,
0, 0,
camera,
parentMatrix,
true,
textureUnit
);
renderer.resetTextures();
renderer.pipelines.postBatch(src);
};
module.exports = RenderTextureWebGLRenderer;