Skip to content

Commit a79da48

Browse files
committed
Added glTexture property
1 parent fc3c93b commit a79da48

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/gameobjects/rendertexture/RenderTexture.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,27 @@ var RenderTexture = new Class({
260260
*/
261261
this.gl = null;
262262

263+
/**
264+
* A reference to the WebGLTexture that is being rendered to in a WebGL Context.
265+
*
266+
* @name Phaser.GameObjects.RenderTexture#glTexture
267+
* @type {WebGLTexture}
268+
* @default null
269+
* @readonly
270+
* @since 3.19.0
271+
*/
272+
this.glTexture = null;
273+
263274
var renderer = this.renderer;
264275

265276
if (renderer.type === CONST.WEBGL)
266277
{
267278
var gl = renderer.gl;
268279

269280
this.gl = gl;
281+
this.glTexture = this.frame.source.glTexture;
270282
this.drawGameObject = this.batchGameObjectWebGL;
271-
this.framebuffer = renderer.createFramebuffer(width, height, this.frame.source.glTexture, false);
283+
this.framebuffer = renderer.createFramebuffer(width, height, this.glTexture, false);
272284
}
273285
else if (renderer.type === CONST.CANVAS)
274286
{
@@ -345,10 +357,14 @@ var RenderTexture = new Class({
345357
this.renderer.deleteTexture(this.frame.source.glTexture);
346358
this.renderer.deleteFramebuffer(this.framebuffer);
347359

348-
this.frame.source.glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false);
349-
this.framebuffer = this.renderer.createFramebuffer(width, height, this.frame.source.glTexture, false);
360+
var glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false);
361+
362+
this.framebuffer = this.renderer.createFramebuffer(width, height, glTexture, false);
363+
364+
this.frame.source.isRenderTexture = true;
350365

351-
this.frame.glTexture = this.frame.source.glTexture;
366+
this.frame.glTexture = glTexture;
367+
this.glTexture = glTexture;
352368
}
353369

354370
this.frame.source.width = width;
@@ -1079,6 +1095,7 @@ var RenderTexture = new Class({
10791095
this.context = null;
10801096
this.framebuffer = null;
10811097
this.texture = null;
1098+
this.glTexture = null;
10821099
}
10831100
}
10841101

0 commit comments

Comments
 (0)