@@ -10,7 +10,7 @@ var Class = require('../../utils/Class');
1010 * @classdesc
1111 * A Render Target encapsulates a WebGL framebuffer and the WebGL Texture that displays it.
1212 *
13- * Instances of this class belong WebGL Pipelines.
13+ * Instances of this class are created by, and belong to WebGL Pipelines.
1414 *
1515 * @class RenderTarget
1616 * @memberof Phaser.Renderer.WebGL
@@ -20,14 +20,15 @@ var Class = require('../../utils/Class');
2020 * @param {Phaser.Renderer.WebGL.WebGLPipeline } pipeline - The WebGLPipeline to which this Render Target belongs.
2121 * @param {number } width - The width of the WebGL Pipeline.
2222 * @param {number } height - The height of the WebGL Pipeline.
23- * @param {number } scale - The scale of the Render Target. This is a scale factor applied to the pipeline size.
24- * @param {boolean } autoClear - Automatically gl clear this framebuffer during render?
23+ * @param {number } scale - A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer.
24+ * @param {number } minFilter - The minFilter mode of the texture when created. 0 is `LINEAR`, 1 is `NEAREST`.
25+ * @param {boolean } autoClear - Automatically clear this framebuffer when bound?
2526 */
2627var RenderTarget = new Class ( {
2728
2829 initialize :
2930
30- function RenderTarget ( pipeline , width , height , scale , autoClear )
31+ function RenderTarget ( pipeline , width , height , scale , minFilter , autoClear )
3132 {
3233 /**
3334 * A reference to the WebGLPipeline that owns this Render Target.
@@ -50,7 +51,9 @@ var RenderTarget = new Class({
5051 this . renderer = pipeline . renderer ;
5152
5253 /**
53- * The WebGLFramebuffer this pipeline is targeting, if any.
54+ * The WebGLFramebuffer of this Render Target.
55+ *
56+ * This is created in the `RenderTarget.resize` method.
5457 *
5558 * @name Phaser.Renderer.WebGL.RenderTarget#framebuffer
5659 * @type {WebGLFramebuffer }
@@ -59,7 +62,9 @@ var RenderTarget = new Class({
5962 this . framebuffer = null ;
6063
6164 /**
62- * The WebGLTexture this pipeline is targeting, if any.
65+ * The WebGLTexture of this Render Target.
66+ *
67+ * This is created in the `RenderTarget.resize` method.
6368 *
6469 * @name Phaser.Renderer.WebGL.RenderTarget#texture
6570 * @type {WebGLTexture }
@@ -68,22 +73,31 @@ var RenderTarget = new Class({
6873 this . texture = null ;
6974
7075 /**
71- * The dimensions of this Render Target are based on the scale of the WebGLRenderer .
76+ * A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer .
7277 *
73- * This value controls how much those dimensions are scaled .
78+ * A value of 1 matches it. 0.5 makes the Render Target half the size of the renderer, etc .
7479 *
7580 * @name Phaser.Renderer.WebGL.RenderTarget#scale
7681 * @type {number }
7782 * @since 3.50.0
7883 */
7984 this . scale = scale ;
8085
86+ /**
87+ * The minFilter mode of the texture. 0 is `LINEAR`, 1 is `NEAREST`.
88+ *
89+ * @name Phaser.Renderer.WebGL.RenderTarget#minFilter
90+ * @type {number }
91+ * @since 3.50.0
92+ */
93+ this . minFilter = minFilter ;
94+
8195 /**
8296 * Controls if this Render Target is automatically cleared (via `gl.COLOR_BUFFER_BIT`)
83- * during the `WebGLPipeline.postBind ` method.
97+ * during the `RenderTarget.bind ` method.
8498 *
8599 * If you need more control over how, or if, the target is cleared, you can disable
86- * this via the config, or even directly at runtime.
100+ * this via the config on creation , or even toggle it directly at runtime.
87101 *
88102 * @name Phaser.Renderer.WebGL.RenderTarget#autoClear
89103 * @type {boolean }
@@ -121,25 +135,20 @@ var RenderTarget = new Class({
121135 width *= this . scale ;
122136 height *= this . scale ;
123137
124- this . texture = renderer . createTextureFromSource ( null , width , height , 0 ) ;
138+ this . texture = renderer . createTextureFromSource ( null , width , height , this . minFilter ) ;
125139
126140 this . framebuffer = renderer . createFramebuffer ( width , height , this . texture , false ) ;
127141
128142 return this ;
129143 } ,
130144
131145 /**
132- * Sets the program this shader uses as being the active shader in the WebGL Renderer .
146+ * Pushes this Render Target as the current frame buffer of the renderer .
133147 *
134- * This method is called every time the parent pipeline is made the current active pipeline .
148+ * If `autoClear` is set, then clears the texture .
135149 *
136- * @method Phaser.Renderer.WebGL.WebGLShader #bind
150+ * @method Phaser.Renderer.WebGL.RenderTarget #bind
137151 * @since 3.50.0
138- *
139- * @param {boolean } [setAttributes=false] - Should the vertex attribute pointers be set?
140- * @param {boolean } [flush=false] - Flush the pipeline before binding this shader?
141- *
142- * @return {this } This WebGLShader instance.
143152 */
144153 bind : function ( )
145154 {
@@ -155,19 +164,30 @@ var RenderTarget = new Class({
155164 }
156165 } ,
157166
167+ /**
168+ * Unbinds this Render Target.
169+ *
170+ * @name Phaser.Renderer.WebGL.RenderTarget#unbind
171+ * @since 3.50.0
172+ */
158173 unbind : function ( )
159174 {
160175 this . renderer . popFramebuffer ( ) ;
161176 } ,
162177
178+ /**
179+ * Draws a quad to the pipeline, using this Render Target texture,
180+ * sized so that it fills the renderer.
181+ *
182+ * @name Phaser.Renderer.WebGL.RenderTarget#draw
183+ * @since 3.50.0
184+ */
163185 draw : function ( )
164186 {
165- var texture = this . texture ;
166-
167- var width = texture . width ;
168- var height = texture . height ;
187+ var width = this . renderer . width ;
188+ var height = this . renderer . height ;
169189
170- this . pipeline . drawFillRect ( 0 , 0 , width , height , 0x0 , 1 , texture , true ) ;
190+ this . pipeline . drawFillRect ( 0 , 0 , width , height , 0 , 1 , this . texture ) ;
171191 } ,
172192
173193 /**
0 commit comments