mirror of
https://github.com/photonstorm/phaser
synced 2025-02-20 16:08:29 +00:00
Added render pass component to renderable game objects
This commit is contained in:
parent
439575adda
commit
3e8e6141c8
8 changed files with 24 additions and 8 deletions
|
@ -37,16 +37,19 @@ var RenderPass = {
|
||||||
/* Needed for getting constant values
|
/* Needed for getting constant values
|
||||||
* Form the WebGL context.
|
* Form the WebGL context.
|
||||||
*/
|
*/
|
||||||
glContext: null,
|
renderingContext: null,
|
||||||
|
|
||||||
/* Utility functions */
|
/* Utility functions */
|
||||||
initRenderComponent: function ()
|
initRenderPassComponent: function ()
|
||||||
{
|
{
|
||||||
var renderingContext = this.state.game.renderer.gl;
|
var renderingContext = this.state.game.renderer.gl;
|
||||||
|
|
||||||
if ((renderingContext instanceof WebGLRenderingContext) || (renderingContext !== null && renderingContext.rawgl !== undefined))
|
if (renderingContext !== undefined &&
|
||||||
|
((renderingContext instanceof WebGLRenderingContext) || (renderingContext !== null && renderingContext.rawgl !== undefined)))
|
||||||
{
|
{
|
||||||
this.glContext = renderingContext;
|
this.renderingContext = renderingContext;
|
||||||
|
this.setDefaultDepthStencilState();
|
||||||
|
this.setNoBlending();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,7 +113,7 @@ var RenderPass = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setDefaultBlending: function () {
|
setDefaultBlending: function () {
|
||||||
var gl = this.glContext;
|
var gl = this.renderingContext;
|
||||||
|
|
||||||
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ADD);
|
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ADD);
|
||||||
|
|
||||||
|
@ -118,7 +121,7 @@ var RenderPass = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setNoBlending: function () {
|
setNoBlending: function () {
|
||||||
var gl = this.glContext;
|
var gl = this.renderingContext;
|
||||||
|
|
||||||
this.setBlendFunc(gl.ONE, gl.ZERO, gl.ADD);
|
this.setBlendFunc(gl.ONE, gl.ZERO, gl.ADD);
|
||||||
|
|
||||||
|
@ -142,7 +145,7 @@ var RenderPass = {
|
||||||
|
|
||||||
/* Call this on render pass */
|
/* Call this on render pass */
|
||||||
dispatchRenderPassState: function () {
|
dispatchRenderPassState: function () {
|
||||||
var gl = this.glContext;
|
var gl = this.renderingContext;
|
||||||
var textures = this.textures;
|
var textures = this.textures;
|
||||||
var length = textures.length;
|
var length = textures.length;
|
||||||
var outputStage = this.outputStage;
|
var outputStage = this.outputStage;
|
||||||
|
@ -184,4 +187,4 @@ var RenderPass = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Render;
|
module.exports = RenderPass;
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
||||||
Flip: require('./Flip'),
|
Flip: require('./Flip'),
|
||||||
GetBounds: require('./GetBounds'),
|
GetBounds: require('./GetBounds'),
|
||||||
Origin: require('./Origin'),
|
Origin: require('./Origin'),
|
||||||
|
RenderPass: require('./RenderPass'),
|
||||||
ScaleMode: require('./ScaleMode'),
|
ScaleMode: require('./ScaleMode'),
|
||||||
Size: require('./Size'),
|
Size: require('./Size'),
|
||||||
Texture: require('./Texture'),
|
Texture: require('./Texture'),
|
||||||
|
|
|
@ -13,6 +13,7 @@ var DynamicBitmapText = new Class({
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
Components.Texture,
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
|
Components.RenderPass,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Render
|
Render
|
||||||
],
|
],
|
||||||
|
@ -37,6 +38,7 @@ var DynamicBitmapText = new Class({
|
||||||
|
|
||||||
this.setTexture(font);
|
this.setTexture(font);
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
|
this.initRenderPassComponent();
|
||||||
},
|
},
|
||||||
|
|
||||||
setDisplayCallback: function (callback)
|
setDisplayCallback: function (callback)
|
||||||
|
|
|
@ -13,6 +13,7 @@ var BitmapText = new Class({
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
Components.Texture,
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
|
Components.RenderPass,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Render
|
Render
|
||||||
],
|
],
|
||||||
|
@ -36,6 +37,7 @@ var BitmapText = new Class({
|
||||||
this.setTexture(font);
|
this.setTexture(font);
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setOrigin(0, 0);
|
this.setOrigin(0, 0);
|
||||||
|
this.initRenderPassComponent();
|
||||||
},
|
},
|
||||||
|
|
||||||
setFontSize: function (size)
|
setFontSize: function (size)
|
||||||
|
|
|
@ -32,6 +32,7 @@ var Blitter = new Class({
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
Components.Texture,
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
|
Components.RenderPass,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
BlitterRender
|
BlitterRender
|
||||||
],
|
],
|
||||||
|
@ -50,6 +51,7 @@ var Blitter = new Class({
|
||||||
this.renderList = [];
|
this.renderList = [];
|
||||||
|
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
|
this.initRenderPassComponent();
|
||||||
},
|
},
|
||||||
|
|
||||||
// frame MUST be part of the Blitter texture
|
// frame MUST be part of the Blitter texture
|
||||||
|
|
|
@ -11,6 +11,7 @@ var Graphics = new Class({
|
||||||
Components.Alpha,
|
Components.Alpha,
|
||||||
Components.BlendMode,
|
Components.BlendMode,
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
|
Components.RenderPass,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Render
|
Render
|
||||||
],
|
],
|
||||||
|
@ -24,6 +25,7 @@ var Graphics = new Class({
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
|
|
||||||
this.commandBuffer = [];
|
this.commandBuffer = [];
|
||||||
|
this.initRenderPassComponent();
|
||||||
},
|
},
|
||||||
|
|
||||||
arc: function (x, y, radius, startAngle, endAngle, anticlockwise)
|
arc: function (x, y, radius, startAngle, endAngle, anticlockwise)
|
||||||
|
|
|
@ -12,6 +12,7 @@ var Image = new Class({
|
||||||
Components.Flip,
|
Components.Flip,
|
||||||
Components.GetBounds,
|
Components.GetBounds,
|
||||||
Components.Origin,
|
Components.Origin,
|
||||||
|
Components.RenderPass,
|
||||||
Components.ScaleMode,
|
Components.ScaleMode,
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
Components.Texture,
|
||||||
|
@ -30,6 +31,7 @@ var Image = new Class({
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setSizeToFrame();
|
this.setSizeToFrame();
|
||||||
this.setOrigin();
|
this.setOrigin();
|
||||||
|
this.initRenderPassComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@ var Text = new Class({
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Components.Flip,
|
Components.Flip,
|
||||||
|
Components.RenderPass,
|
||||||
TextRender
|
TextRender
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ var Text = new Class({
|
||||||
{
|
{
|
||||||
this.updateText();
|
this.updateText();
|
||||||
}
|
}
|
||||||
|
this.initRenderPassComponent();
|
||||||
},
|
},
|
||||||
|
|
||||||
setText: function (value)
|
setText: function (value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue