Skip to content

Commit efbc256

Browse files
committed
Added target fbo
1 parent 3c7062c commit efbc256

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,24 @@ var WebGLPipeline = new Class({
265265
*/
266266
this.vertexComponentCount = Utils.getComponentCount(this.attributes, this.gl);
267267

268+
/**
269+
* The WebGLFramebuffer this pipeline is targeting, if any.
270+
*
271+
* @name Phaser.Renderer.WebGL.WebGLPipeline#targetFramebuffer
272+
* @type {?WebGLFramebuffer}
273+
* @since 3.50.0
274+
*/
275+
this.targetFramebuffer = null;
276+
277+
/**
278+
* The WebGLTexture this pipeline is targeting, if any.
279+
*
280+
* @name Phaser.GameObjects.Shader#targetTexture
281+
* @type {?WebGLTexture}
282+
* @since 3.50.0
283+
*/
284+
this.targetTexture = null;
285+
268286
/**
269287
* An array of all the WebGLShader instances that belong to this pipeline.
270288
*
@@ -355,7 +373,22 @@ var WebGLPipeline = new Class({
355373
*/
356374
boot: function ()
357375
{
358-
this.setShadersFromConfig(this.config);
376+
var config = this.config;
377+
378+
var target = GetFastValue(config, 'target', null);
379+
380+
if (target)
381+
{
382+
var renderer = this.renderer;
383+
384+
var width = renderer.width;
385+
var height = renderer.height;
386+
387+
this.targetTexture = renderer.createTextureFromSource(null, width, height, 0);
388+
this.targetFramebuffer = renderer.createFramebuffer(width, height, this.targetTexture, false);
389+
}
390+
391+
this.setShadersFromConfig(config);
359392

360393
this.renderer.setVertexBuffer(this.vertexBuffer);
361394

0 commit comments

Comments
 (0)