@@ -10,7 +10,35 @@ var Utils = require('./Utils');
1010
1111/**
1212 * @classdesc
13- * [pending] explain the concept behind the pipelines, what they are and how they work.
13+ * WebGLPipeline is a class that describes the way elements will be rendererd
14+ * in WebGL, specially focused on batching vertices (batching is not provided).
15+ * Pipelines are mostly used for describing 2D rendering passes but it's
16+ * flexible enough to be used for any type of rendering including 3D.
17+ * Internally WebGLPipeline will handle things like compiling shaders,
18+ * creating vertex buffers, assigning primitive topology and binding
19+ * vertex attributes.
20+ *
21+ * The config properties are:
22+ * - game: Current game instance.
23+ * - renderer: Current WebGL renderer.
24+ * - gl: Current WebGL context.
25+ * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES.
26+ * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants).
27+ * - vertShader: Source for vertex shader as a string.
28+ * - fragShader: Source for fragment shader as a string.
29+ * - vertexCapacity: The amount of vertices that shall be allocated
30+ * - vertexSize: The size of a single vertex in bytes.
31+ * - vertices: An optional buffer of vertices
32+ * - attributes: An array describing the vertex attributes
33+ *
34+ * The vertex attributes properties are:
35+ * - name : String - Name of the attribute in the vertex shader
36+ * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1
37+ * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT)
38+ * - normalized : boolean - Is the attribute normalized
39+ * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C
40+ * Here you can find more information of how to describe an attribute:
41+ * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
1442 *
1543 * @class WebGLPipeline
1644 * @memberOf Phaser.Renderer.WebGL
@@ -26,7 +54,7 @@ var WebGLPipeline = new Class({
2654 function WebGLPipeline ( config )
2755 {
2856 /**
29- * [pending]
57+ * Name of the Pipeline. Used for identifying
3058 *
3159 * @name Phaser.Renderer.WebGL.WebGLPipeline#name
3260 * @type {string }
@@ -53,7 +81,7 @@ var WebGLPipeline = new Class({
5381 this . view = config . game . canvas ;
5482
5583 /**
56- * [pending]
84+ * Used to store the current game resolution
5785 *
5886 * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution
5987 * @type {number }
@@ -62,7 +90,7 @@ var WebGLPipeline = new Class({
6290 this . resolution = config . game . config . resolution ;
6391
6492 /**
65- * [pending]
93+ * Width of the current viewport
6694 *
6795 * @name Phaser.Renderer.WebGL.WebGLPipeline#width
6896 * @type {number }
@@ -71,7 +99,7 @@ var WebGLPipeline = new Class({
7199 this . width = config . game . config . width * this . resolution ;
72100
73101 /**
74- * [pending]
102+ * Height of the current viewport
75103 *
76104 * @name Phaser.Renderer.WebGL.WebGLPipeline#height
77105 * @type {number }
@@ -89,7 +117,7 @@ var WebGLPipeline = new Class({
89117 this . gl = config . gl ;
90118
91119 /**
92- * [pending]
120+ * How many vertices have been fed to the current pipeline.
93121 *
94122 * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount
95123 * @type {number }
@@ -99,7 +127,7 @@ var WebGLPipeline = new Class({
99127 this . vertexCount = 0 ;
100128
101129 /**
102- * [pending]
130+ * The limit of vertices that the pipeline can hold
103131 *
104132 * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity
105133 * @type {integer }
@@ -117,7 +145,7 @@ var WebGLPipeline = new Class({
117145 this . renderer = config . renderer ;
118146
119147 /**
120- * [pending]
148+ * Raw byte buffer of vertices.
121149 *
122150 * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData
123151 * @type {ArrayBuffer }
@@ -126,7 +154,7 @@ var WebGLPipeline = new Class({
126154 this . vertexData = ( config . vertices ? config . vertices : new ArrayBuffer ( config . vertexCapacity * config . vertexSize ) ) ;
127155
128156 /**
129- * [pending]
157+ * The handle to a WebGL vertex buffer object.
130158 *
131159 * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer
132160 * @type {WebGLBuffer }
@@ -135,7 +163,7 @@ var WebGLPipeline = new Class({
135163 this . vertexBuffer = this . renderer . createVertexBuffer ( ( config . vertices ? config . vertices : this . vertexData . byteLength ) , this . gl . STREAM_DRAW ) ;
136164
137165 /**
138- * [pending]
166+ * The handle to a WebGL program
139167 *
140168 * @name Phaser.Renderer.WebGL.WebGLPipeline#program
141169 * @type {WebGLProgram }
@@ -144,7 +172,7 @@ var WebGLPipeline = new Class({
144172 this . program = this . renderer . createProgram ( config . vertShader , config . fragShader ) ;
145173
146174 /**
147- * [pending]
175+ * Array of objects that describe the vertex attributes
148176 *
149177 * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes
150178 * @type {object }
@@ -153,7 +181,7 @@ var WebGLPipeline = new Class({
153181 this . attributes = config . attributes ;
154182
155183 /**
156- * [pending]
184+ * The size in bytes of the vertex
157185 *
158186 * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize
159187 * @type {integer }
@@ -162,7 +190,7 @@ var WebGLPipeline = new Class({
162190 this . vertexSize = config . vertexSize ;
163191
164192 /**
165- * [pending]
193+ * The primitive topology which the pipeline will use to submit draw calls
166194 *
167195 * @name Phaser.Renderer.WebGL.WebGLPipeline#topology
168196 * @type {integer }
@@ -171,7 +199,8 @@ var WebGLPipeline = new Class({
171199 this . topology = config . topology ;
172200
173201 /**
174- * [pending]
202+ * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources
203+ * to the GPU.
175204 *
176205 * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes
177206 * @type {Uint8Array }
@@ -200,16 +229,16 @@ var WebGLPipeline = new Class({
200229 } ,
201230
202231 /**
203- * [pending]
232+ * Adds a description of vertex attribute to the pipeline
204233 *
205234 * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute
206235 * @since 3.2.0
207236 *
208- * @param {string } name - [pending]
209- * @param {integer } size - [pending]
210- * @param {integer } type - [pending]
211- * @param {boolean } normalized - [pending]
212- * @param {integer } offset - [pending]
237+ * @param {string } name - Name of the vertex attribute
238+ * @param {integer } size - Vertex component size
239+ * @param {integer } type - Type of the attribute
240+ * @param {boolean } normalized - Is the value normalized to a range
241+ * @param {integer } offset - Byte offset to the beginning of the first element in the vertex
213242 *
214243 * @return {Phaser.Renderer.WebGL.WebGLPipeline } [description]
215244 */
@@ -227,7 +256,7 @@ var WebGLPipeline = new Class({
227256 } ,
228257
229258 /**
230- * [pending]
259+ * Check if the current batch of vertices is full.
231260 *
232261 * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush
233262 * @since 3.0.0
@@ -240,7 +269,7 @@ var WebGLPipeline = new Class({
240269 } ,
241270
242271 /**
243- * [pending]
272+ * Resizes the properties used to describe the viewport
244273 *
245274 * @method Phaser.Renderer.WebGL.WebGLPipeline#resize
246275 * @since 3.0.0
@@ -259,7 +288,7 @@ var WebGLPipeline = new Class({
259288 } ,
260289
261290 /**
262- * [pending]
291+ * Binds the pipeline resources, including programs, vertex buffers and binds attributes
263292 *
264293 * @method Phaser.Renderer.WebGL.WebGLPipeline#bind
265294 * @since 3.0.0
@@ -357,7 +386,8 @@ var WebGLPipeline = new Class({
357386 } ,
358387
359388 /**
360- * [pending]
389+ * Uploads the vertex data and emits a draw call
390+ * for the current batch of vertices.
361391 *
362392 * @method Phaser.Renderer.WebGL.WebGLPipeline#flush
363393 * @since 3.0.0
@@ -413,7 +443,7 @@ var WebGLPipeline = new Class({
413443 } ,
414444
415445 /**
416- * [description]
446+ * Set a uniform value of the current pipeline program.
417447 *
418448 * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1
419449 * @since 3.2.0
@@ -430,7 +460,7 @@ var WebGLPipeline = new Class({
430460 } ,
431461
432462 /**
433- * [description]
463+ * Set a uniform value of the current pipeline program.
434464 *
435465 * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2
436466 * @since 3.2.0
@@ -449,7 +479,7 @@ var WebGLPipeline = new Class({
449479 } ,
450480
451481 /**
452- * [description]
482+ * Set a uniform value of the current pipeline program.
453483 *
454484 * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3
455485 * @since 3.2.0
@@ -469,16 +499,16 @@ var WebGLPipeline = new Class({
469499 } ,
470500
471501 /**
472- * [pending]
502+ * Set a uniform value of the current pipeline program.
473503 *
474504 * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4
475505 * @since 3.2.0
476506 *
477- * @param {string } name - [pending]
478- * @param {float } x - [pending]
479- * @param {float } y - [pending]
480- * @param {float } z - [pending]
481- * @param {float } w - [pending]
507+ * @param {string } name - Name of the uniform
508+ * @param {float } x - X component of the uniform
509+ * @param {float } y - Y component of the uniform
510+ * @param {float } z - Z component of the uniform
511+ * @param {float } w - W component of the uniform
482512 *
483513 * @return {Phaser.Renderer.WebGL.WebGLPipeline } [description]
484514 */
@@ -490,7 +520,7 @@ var WebGLPipeline = new Class({
490520 } ,
491521
492522 /**
493- * [description]
523+ * Set a uniform value of the current pipeline program.
494524 *
495525 * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1
496526 * @since 3.2.0
@@ -507,7 +537,7 @@ var WebGLPipeline = new Class({
507537 } ,
508538
509539 /**
510- * [description]
540+ * Set a uniform value of the current pipeline program.
511541 *
512542 * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2
513543 * @since 3.2.0
@@ -525,7 +555,7 @@ var WebGLPipeline = new Class({
525555 } ,
526556
527557 /**
528- * [description]
558+ * Set a uniform value of the current pipeline program.
529559 *
530560 * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3
531561 * @since 3.2.0
@@ -544,16 +574,16 @@ var WebGLPipeline = new Class({
544574 } ,
545575
546576 /**
547- * [pending]
577+ * Set a uniform value of the current pipeline program.
548578 *
549579 * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4
550580 * @since 3.2.0
551581 *
552- * @param {string } name - [pending]
553- * @param {integer } x - [pending]
554- * @param {integer } y - [pending]
555- * @param {integer } z - [pending]
556- * @param {integer } w - [pending]
582+ * @param {string } name - Name of the uniform
583+ * @param {integer } x - X component of the uniform
584+ * @param {integer } y - Y component of the uniform
585+ * @param {integer } z - Z component of the uniform
586+ * @param {integer } w - W component of the uniform
557587 *
558588 * @return {Phaser.Renderer.WebGL.WebGLPipeline } [description]
559589 */
@@ -564,6 +594,7 @@ var WebGLPipeline = new Class({
564594 } ,
565595
566596 /**
597+ * Set a uniform value of the current pipeline program.
567598 * [description]
568599 *
569600 * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2
@@ -582,6 +613,8 @@ var WebGLPipeline = new Class({
582613 } ,
583614
584615 /**
616+ * Set a uniform value of the current pipeline program.
617+ * [description]
585618 * [description]
586619 *
587620 * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3
@@ -600,14 +633,14 @@ var WebGLPipeline = new Class({
600633 } ,
601634
602635 /**
603- * [description]
636+ * Set a uniform value of the current pipeline program.
604637 *
605638 * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4
606639 * @since 3.2.0
607640 *
608- * @param {string } name - [pending]
609- * @param {boolean } transpose - [pending]
610- * @param {Float32Array } matrix - [pending]
641+ * @param {string } name - Name of the uniform
642+ * @param {boolean } transpose - Should the matrix be transpose
643+ * @param {Float32Array } matrix - Matrix data
611644 *
612645 * @return {Phaser.Renderer.WebGL.WebGLPipeline } [description]
613646 */
0 commit comments