@@ -374,6 +374,15 @@ this.createjs = this.createjs||{};
374374 */
375375 this . _alphaAttribute = null ;
376376
377+ /**
378+ * All the different vertex attribute sets that can be used with the render buffer. Currently only internal,
379+ * if/when alternate main shaders are possible, they'll register themselves here.
380+ * @property _attributeConfig
381+ * @protected
382+ * @type {Object }
383+ */
384+ this . _attributeConfig = { } ;
385+
377386 /**
378387 * One of the major render buffers used in composite blending drawing. Do not expect this to always be the same object.
379388 * "What you're drawing to", object occasionally swaps with concat.
@@ -2128,7 +2137,7 @@ this.createjs = this.createjs||{};
21282137 p . _createBuffers = function ( ) {
21292138 var gl = this . _webGLContext ;
21302139 var groupCount = this . _maxBatchVertexCount ;
2131- var groupSize , i , l ;
2140+ var groupSize , i , l , config , atrBuffer , stride ;
21322141
21332142 // INFO:
21342143 // all buffers are created using this pattern
@@ -2155,37 +2164,46 @@ this.createjs = this.createjs||{};
21552164 // }
21562165 // TODO benchmark and test using unified buffer
21572166
2167+ config = this . _attributeConfig [ "default" ] = { } ;
2168+ stride = 0 ;
2169+
21582170 // the actual position information
2159- var vertexPositionBuffer = this . _vertexPositionAttribute = gl . createBuffer ( ) ;
2160- gl . bindBuffer ( gl . ARRAY_BUFFER , vertexPositionBuffer ) ;
2161- groupSize = 2 ;
2171+ atrBuffer = this . _vertexPositionAttribute = gl . createBuffer ( ) ;
2172+ gl . bindBuffer ( gl . ARRAY_BUFFER , atrBuffer ) ;
2173+ stride += 4 * ( groupSize = 2 ) ;
21622174 var vertices = this . _vertices = new Float32Array ( groupCount * groupSize ) ;
21632175 for ( i = 0 , l = vertices . length ; i < l ; i += groupSize ) { vertices [ i ] = vertices [ i + 1 ] = 0 ; }
21642176 gl . bufferData ( gl . ARRAY_BUFFER , vertices , gl . DYNAMIC_DRAW ) ;
2177+ config [ "position" ] = { array : vertices , buffer : atrBuffer , offset : 0 , size : groupSize } ;
21652178
21662179 // where on the texture it gets its information
2167- var uvPositionBuffer = this . _uvPositionAttribute = gl . createBuffer ( ) ;
2168- gl . bindBuffer ( gl . ARRAY_BUFFER , uvPositionBuffer ) ;
2169- groupSize = 2 ;
2180+ atrBuffer = this . _uvPositionAttribute = gl . createBuffer ( ) ;
2181+ gl . bindBuffer ( gl . ARRAY_BUFFER , atrBuffer ) ;
2182+ stride += 4 * ( groupSize = 2 ) ;
21702183 var uvs = this . _uvs = new Float32Array ( groupCount * groupSize ) ;
21712184 for ( i = 0 , l = uvs . length ; i < l ; i += groupSize ) { uvs [ i ] = uvs [ i + 1 ] = 0 ; }
21722185 gl . bufferData ( gl . ARRAY_BUFFER , uvs , gl . DYNAMIC_DRAW ) ;
2186+ config [ "uv" ] = { array : uvs , buffer : atrBuffer , offset : 0 , size : groupSize } ;
21732187
21742188 // what texture it should use
2175- var textureIndexBuffer = this . _textureIndexAttribute = gl . createBuffer ( ) ;
2176- gl . bindBuffer ( gl . ARRAY_BUFFER , textureIndexBuffer ) ;
2177- groupSize = 1 ;
2189+ atrBuffer = this . _textureIndexAttribute = gl . createBuffer ( ) ;
2190+ gl . bindBuffer ( gl . ARRAY_BUFFER , atrBuffer ) ;
2191+ stride += 4 * ( groupSize = 1 ) ;
21782192 var indices = this . _indices = new Float32Array ( groupCount * groupSize ) ;
21792193 for ( i = 0 , l = indices . length ; i < l ; i ++ ) { indices [ i ] = 0 ; }
21802194 gl . bufferData ( gl . ARRAY_BUFFER , indices , gl . DYNAMIC_DRAW ) ;
2195+ config [ "texture" ] = { array : indices , buffer : atrBuffer , offset : 0 , size : groupSize } ;
21812196
21822197 // what alpha it should have
2183- var alphaBuffer = this . _alphaAttribute = gl . createBuffer ( ) ;
2184- gl . bindBuffer ( gl . ARRAY_BUFFER , alphaBuffer ) ;
2185- groupSize = 1 ;
2198+ atrBuffer = this . _alphaAttribute = gl . createBuffer ( ) ;
2199+ gl . bindBuffer ( gl . ARRAY_BUFFER , atrBuffer ) ;
2200+ stride += 4 * ( groupSize = 1 ) ;
21862201 var alphas = this . _alphas = new Float32Array ( groupCount * groupSize ) ;
2187- for ( i = 0 , l = alphas . length ; i < l ; i ++ ) { alphas [ i ] = 1 ; }
2202+ for ( i = 0 , l = alphas . length ; i < l ; i ++ ) { alphas [ i ] = 1.0 ; }
21882203 gl . bufferData ( gl . ARRAY_BUFFER , alphas , gl . DYNAMIC_DRAW ) ;
2204+ config [ "alpha" ] = { array : alphas , buffer : atrBuffer , offset : 0 , size : groupSize } ;
2205+
2206+ config [ "_shared_" ] = { stride : stride } ;
21892207 } ;
21902208
21912209 /**
0 commit comments