mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Testing RenderTexture updates to allow any GameObject to be drawn to it
This commit is contained in:
parent
a4db967b19
commit
94e4411ac1
2 changed files with 38 additions and 13 deletions
|
@ -4,6 +4,7 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Camera = require('../../cameras/2d/Camera');
|
||||
var CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var Class = require('../../utils/Class');
|
||||
var Components = require('../components');
|
||||
|
@ -30,7 +31,6 @@ var RenderTextureWebGL = require('./RenderTextureWebGL');
|
|||
* @extends Phaser.GameObjects.Components.Flip
|
||||
* @extends Phaser.GameObjects.Components.GetBounds
|
||||
* @extends Phaser.GameObjects.Components.Mask
|
||||
* @extends Phaser.GameObjects.Components.MatrixStack
|
||||
* @extends Phaser.GameObjects.Components.Origin
|
||||
* @extends Phaser.GameObjects.Components.Pipeline
|
||||
* @extends Phaser.GameObjects.Components.ScaleMode
|
||||
|
@ -76,8 +76,6 @@ var RenderTexture = new Class({
|
|||
|
||||
GameObject.call(this, scene, 'RenderTexture');
|
||||
|
||||
// this.initMatrixStack();
|
||||
|
||||
/**
|
||||
* A reference to either the Canvas or WebGL Renderer that the Game instance is using.
|
||||
*
|
||||
|
@ -137,7 +135,11 @@ var RenderTexture = new Class({
|
|||
*/
|
||||
this.framebuffer = null;
|
||||
|
||||
this.currentMatrix = new Components.TransformMatrix();
|
||||
this.camera = new Camera(0, 0, width, height);
|
||||
|
||||
this.camera.setScene(scene);
|
||||
|
||||
// this.currentMatrix = new Components.TransformMatrix();
|
||||
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
|
|
|
@ -87,9 +87,6 @@ var RenderTextureWebGL = {
|
|||
*/
|
||||
draw: function (stamp, x, y, tint)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
|
||||
if (!Array.isArray(stamp))
|
||||
{
|
||||
stamp = [ stamp ];
|
||||
|
@ -97,19 +94,22 @@ var RenderTextureWebGL = {
|
|||
|
||||
this.renderer.setFramebuffer(this.framebuffer);
|
||||
|
||||
this.camera.preRender(1, 1, 1);
|
||||
|
||||
var pipeline = this.pipeline;
|
||||
|
||||
pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0);
|
||||
|
||||
for (var i = 0; i < stamp.length; i++)
|
||||
{
|
||||
if (stamp[i].frame)
|
||||
{
|
||||
// if (stamp[i].frame)
|
||||
// {
|
||||
this.drawGameObject(stamp[i], x, y);
|
||||
}
|
||||
{
|
||||
this.drawFrame(stamp[i], x, y, tint);
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.drawFrame(stamp[i], x, y, tint);
|
||||
// }
|
||||
}
|
||||
|
||||
pipeline.flush();
|
||||
|
@ -123,6 +123,26 @@ var RenderTextureWebGL = {
|
|||
|
||||
drawGameObject: function (gameObject, x, y)
|
||||
{
|
||||
if (x === undefined) { x = gameObject.x; }
|
||||
if (y === undefined) { y = gameObject.y; }
|
||||
|
||||
var prevX = gameObject.x;
|
||||
var prevY = gameObject.y;
|
||||
|
||||
this.renderer.setBlendMode(gameObject.blendMode);
|
||||
|
||||
gameObject.setPosition(x, y);
|
||||
|
||||
gameObject.renderWebGL(this.renderer, gameObject, 0, this.camera, null);
|
||||
|
||||
gameObject.setPosition(prevX, prevY);
|
||||
},
|
||||
|
||||
NEWdrawGameObject: function (gameObject, x, y)
|
||||
{
|
||||
if (x === undefined) { x = gameObject.x; }
|
||||
if (y === undefined) { y = gameObject.y; }
|
||||
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
|
||||
this.pipeline.batchTextureFrame(
|
||||
|
@ -145,6 +165,9 @@ var RenderTextureWebGL = {
|
|||
|
||||
drawFrame: function (frame, x, y, tint)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
|
||||
if (tint === undefined)
|
||||
{
|
||||
tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16);
|
||||
|
|
Loading…
Add table
Reference in a new issue