Skip to content

Commit 88e07a9

Browse files
committed
Render pass fix for setting texture
1 parent cd1ed07 commit 88e07a9

5 files changed

Lines changed: 48 additions & 6 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '905ea200-5ba2-11e7-8485-252c432813f8'
2+
build: '319d5420-5bd7-11e7-bbe2-93fbaa8629f2'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/effectlayer/EffectLayer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ var EffectLayer = new Class({
7070
this.setOrigin(0, 0);
7171
},
7272

73+
setClearAlpha: function (alpha)
74+
{
75+
if (this.dstRenderTarget)
76+
{
77+
this.dstRenderTarget.clearAlpha = alpha;
78+
}
79+
},
80+
7381
renderOffScreen: function ()
7482
{
7583
this.renderTarget = this.dstRenderTarget;

v3/src/gameobjects/renderpass/RenderPass.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var RenderPass = new Class({
4646
this.renderTexture = null;
4747
this.passShader = null;
4848
this.uniforms = {};
49+
this.textures = {};
4950

5051
if (resourceManager !== undefined)
5152
{
@@ -113,6 +114,37 @@ var RenderPass = new Class({
113114
{
114115
this.renderer.setRenderer(this.renderer.spriteBatch, null, null);
115116
this.renderer.spriteBatch.addSprite(gameObject, camera);
117+
for (var key in this.textures)
118+
{
119+
var textureData = this.textures[key];
120+
this.setInt(key, textureData.unit);
121+
gl.activeTexture(gl.TEXTURE0 + textureData.unit);
122+
gl.bindTexture(gl.TEXTURE_2D, textureData.texture);
123+
gl.activeTexture(gl.TEXTURE0);
124+
}
125+
this.renderer.spriteBatch.flush(this.passShader, this.passRenderTarget.framebufferObject);
126+
}
127+
},
128+
129+
renderRect: function (x, y, width, height, camera)
130+
{
131+
var gl = this.renderer.gl;
132+
133+
if (gl)
134+
{
135+
this.renderer.setRenderer(this.renderer.spriteBatch, null, null);
136+
this.renderer.spriteBatch.addTileTextureRect(
137+
null, x, y, width, height, 1.0, 0xFFFFFFFF, this.scrollFactorX, this.scrollFactorY,
138+
width, height, 0, 0, width, height, camera, null
139+
);
140+
for (var key in this.textures)
141+
{
142+
var textureData = this.textures[key];
143+
this.setInt(key, textureData.unit);
144+
gl.activeTexture(gl.TEXTURE0 + textureData.unit);
145+
gl.bindTexture(gl.TEXTURE_2D, textureData.texture);
146+
gl.activeTexture(gl.TEXTURE0);
147+
}
116148
this.renderer.spriteBatch.flush(this.passShader, this.passRenderTarget.framebufferObject);
117149
}
118150
},
@@ -125,10 +157,11 @@ var RenderPass = new Class({
125157
{
126158
/* Texture 1 is reserved for Phasers Main Renderer */
127159
unit = (unit > 0) ? unit : 1;
128-
this.setInt(samplerName, unit);
129-
gl.activeTexture(gl.TEXTURE0 + unit);
130-
gl.bindTexture(gl.TEXTURE_2D, renderTexture.texture);
131-
gl.activeTexture(gl.TEXTURE0);
160+
this.textures[samplerName] = { texture: renderTexture.texture, unit: unit };
161+
//this.setInt(samplerName, unit);
162+
//gl.activeTexture(gl.TEXTURE0 + unit);
163+
//gl.bindTexture(gl.TEXTURE_2D, renderTexture.texture);
164+
//gl.activeTexture(gl.TEXTURE0);
132165
}
133166
},
134167

v3/src/renderer/webgl/WebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ WebGLRenderer.prototype = {
227227
gl.bindFramebuffer(gl.FRAMEBUFFER, renderTarget.framebufferObject);
228228
if (renderTarget.shouldClear)
229229
{
230-
gl.clearColor(0, 0, 0, 0);
230+
gl.clearColor(0, 0, 0, renderTarget.clearAlpha);
231231
gl.clear(gl.COLOR_BUFFER_BIT);
232232
renderTarget.shouldClear = false;
233233
}

v3/src/renderer/webgl/resources/RenderTarget.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var RenderTarget = function (framebufferObject, width, height, colorBuffer, dept
66
this.colorBuffer = colorBuffer;
77
this.depthStencilBuffer = depthStencilBuffer;
88
this.shouldClear = false;
9+
this.clearAlpha = 0.0;
910
};
1011

1112
module.exports = RenderTarget;

0 commit comments

Comments
 (0)