Added render pass component to renderable game objects

This commit is contained in:
Felipe Alfonso 2017-03-28 15:16:02 -03:00
parent 439575adda
commit 3e8e6141c8
8 changed files with 24 additions and 8 deletions

View file

@ -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;

View file

@ -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'),

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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();
}
});

View file

@ -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)