diff --git a/v3/src/components/RenderPass.js b/v3/src/components/RenderPass.js index 18bbb7ca0..bd7c3c642 100644 --- a/v3/src/components/RenderPass.js +++ b/v3/src/components/RenderPass.js @@ -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; diff --git a/v3/src/components/index.js b/v3/src/components/index.js index 57c70859c..9e0b46af5 100644 --- a/v3/src/components/index.js +++ b/v3/src/components/index.js @@ -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'), diff --git a/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js b/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js index c7eca6f6f..fb52c7bc2 100644 --- a/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js +++ b/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js @@ -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) diff --git a/v3/src/gameobjects/bitmaptext/static/BitmapText.js b/v3/src/gameobjects/bitmaptext/static/BitmapText.js index 3cc4139e2..699eb32db 100644 --- a/v3/src/gameobjects/bitmaptext/static/BitmapText.js +++ b/v3/src/gameobjects/bitmaptext/static/BitmapText.js @@ -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) diff --git a/v3/src/gameobjects/blitter/Blitter.js b/v3/src/gameobjects/blitter/Blitter.js index a18006a09..7b743cfc9 100644 --- a/v3/src/gameobjects/blitter/Blitter.js +++ b/v3/src/gameobjects/blitter/Blitter.js @@ -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 diff --git a/v3/src/gameobjects/graphics/Graphics.js b/v3/src/gameobjects/graphics/Graphics.js index 8deae7c85..3c2d341e6 100644 --- a/v3/src/gameobjects/graphics/Graphics.js +++ b/v3/src/gameobjects/graphics/Graphics.js @@ -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) diff --git a/v3/src/gameobjects/image/Image.js b/v3/src/gameobjects/image/Image.js index 8c319ce2d..c62a742eb 100644 --- a/v3/src/gameobjects/image/Image.js +++ b/v3/src/gameobjects/image/Image.js @@ -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(); } }); diff --git a/v3/src/gameobjects/text/static/Text.js b/v3/src/gameobjects/text/static/Text.js index b58d8da73..8eac0478a 100644 --- a/v3/src/gameobjects/text/static/Text.js +++ b/v3/src/gameobjects/text/static/Text.js @@ -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)