mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +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
|
||||
* Form the WebGL context.
|
||||
*/
|
||||
glContext: null,
|
||||
renderingContext: null,
|
||||
|
||||
/* Utility functions */
|
||||
initRenderComponent: function ()
|
||||
initRenderPassComponent: function ()
|
||||
{
|
||||
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 () {
|
||||
var gl = this.glContext;
|
||||
var gl = this.renderingContext;
|
||||
|
||||
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ADD);
|
||||
|
||||
|
@ -118,7 +121,7 @@ var RenderPass = {
|
|||
},
|
||||
|
||||
setNoBlending: function () {
|
||||
var gl = this.glContext;
|
||||
var gl = this.renderingContext;
|
||||
|
||||
this.setBlendFunc(gl.ONE, gl.ZERO, gl.ADD);
|
||||
|
||||
|
@ -142,7 +145,7 @@ var RenderPass = {
|
|||
|
||||
/* Call this on render pass */
|
||||
dispatchRenderPassState: function () {
|
||||
var gl = this.glContext;
|
||||
var gl = this.renderingContext;
|
||||
var textures = this.textures;
|
||||
var length = textures.length;
|
||||
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'),
|
||||
GetBounds: require('./GetBounds'),
|
||||
Origin: require('./Origin'),
|
||||
RenderPass: require('./RenderPass'),
|
||||
ScaleMode: require('./ScaleMode'),
|
||||
Size: require('./Size'),
|
||||
Texture: require('./Texture'),
|
||||
|
|
|
@ -13,6 +13,7 @@ var DynamicBitmapText = new Class({
|
|||
Components.Size,
|
||||
Components.Texture,
|
||||
Components.Transform,
|
||||
Components.RenderPass,
|
||||
Components.Visible,
|
||||
Render
|
||||
],
|
||||
|
@ -37,6 +38,7 @@ var DynamicBitmapText = new Class({
|
|||
|
||||
this.setTexture(font);
|
||||
this.setPosition(x, y);
|
||||
this.initRenderPassComponent();
|
||||
},
|
||||
|
||||
setDisplayCallback: function (callback)
|
||||
|
|
|
@ -13,6 +13,7 @@ var BitmapText = new Class({
|
|||
Components.Size,
|
||||
Components.Texture,
|
||||
Components.Transform,
|
||||
Components.RenderPass,
|
||||
Components.Visible,
|
||||
Render
|
||||
],
|
||||
|
@ -36,6 +37,7 @@ var BitmapText = new Class({
|
|||
this.setTexture(font);
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin(0, 0);
|
||||
this.initRenderPassComponent();
|
||||
},
|
||||
|
||||
setFontSize: function (size)
|
||||
|
|
|
@ -32,6 +32,7 @@ var Blitter = new Class({
|
|||
Components.Size,
|
||||
Components.Texture,
|
||||
Components.Transform,
|
||||
Components.RenderPass,
|
||||
Components.Visible,
|
||||
BlitterRender
|
||||
],
|
||||
|
@ -50,6 +51,7 @@ var Blitter = new Class({
|
|||
this.renderList = [];
|
||||
|
||||
this.dirty = false;
|
||||
this.initRenderPassComponent();
|
||||
},
|
||||
|
||||
// frame MUST be part of the Blitter texture
|
||||
|
|
|
@ -11,6 +11,7 @@ var Graphics = new Class({
|
|||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.Transform,
|
||||
Components.RenderPass,
|
||||
Components.Visible,
|
||||
Render
|
||||
],
|
||||
|
@ -24,6 +25,7 @@ var Graphics = new Class({
|
|||
this.setPosition(x, y);
|
||||
|
||||
this.commandBuffer = [];
|
||||
this.initRenderPassComponent();
|
||||
},
|
||||
|
||||
arc: function (x, y, radius, startAngle, endAngle, anticlockwise)
|
||||
|
|
|
@ -12,6 +12,7 @@ var Image = new Class({
|
|||
Components.Flip,
|
||||
Components.GetBounds,
|
||||
Components.Origin,
|
||||
Components.RenderPass,
|
||||
Components.ScaleMode,
|
||||
Components.Size,
|
||||
Components.Texture,
|
||||
|
@ -30,6 +31,7 @@ var Image = new Class({
|
|||
this.setPosition(x, y);
|
||||
this.setSizeToFrame();
|
||||
this.setOrigin();
|
||||
this.initRenderPassComponent();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -18,6 +18,7 @@ var Text = new Class({
|
|||
Components.Transform,
|
||||
Components.Visible,
|
||||
Components.Flip,
|
||||
Components.RenderPass,
|
||||
TextRender
|
||||
],
|
||||
|
||||
|
@ -74,6 +75,7 @@ var Text = new Class({
|
|||
{
|
||||
this.updateText();
|
||||
}
|
||||
this.initRenderPassComponent();
|
||||
},
|
||||
|
||||
setText: function (value)
|
||||
|
|
Loading…
Reference in a new issue