|
265 | 265 |
|
266 | 266 | proto.rendering = function () { |
267 | 267 | var node = this._node, locTexture = node._texture; |
268 | | - |
| 268 | + var count = this._batchedCount; |
269 | 269 | var program = this._shaderProgram; |
270 | | - if (locTexture) { |
271 | | - program.use(); |
272 | 270 |
|
273 | | - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); |
274 | | - |
275 | | - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); |
276 | | - //cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); |
| 271 | + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); |
277 | 272 |
|
278 | | - cc.glBindVertexFormat(cc.renderer.vertexFormats[1]); |
279 | | - |
280 | | - gl.drawArrays(gl.TRIANGLE_STRIP, this._firstQuad * 4, 4); |
281 | | - } else { |
282 | | - program.use(); |
| 273 | + var elemBuffer = cc.renderer.buffers[cc.geometryTypes.QUAD].indexBuffer; |
| 274 | + cc.glBindElementBuffer(elemBuffer); |
| 275 | + cc.glBindVertexFormat(cc.renderer.vertexFormats[1]); |
| 276 | + |
| 277 | + program.use(); |
| 278 | + if (locTexture) |
| 279 | + { |
| 280 | + cc.glBindTexture2DN(0, locTexture); |
| 281 | + gl.drawElements(gl.TRIANGLES, count * 6, gl.UNSIGNED_SHORT, this._firstQuad * 6 * 2); |
| 282 | + } |
| 283 | + else |
| 284 | + { |
283 | 285 | program._setUniformForMVPMatrixWithMat4(this._stackMatrix); |
284 | | - |
285 | | - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); |
286 | 286 | cc.glBindTexture2D(null); |
287 | 287 |
|
288 | | - cc.glBindVertexFormat(cc.renderer.vertexFormats[1]); |
289 | | - |
290 | 288 | gl.drawArrays(gl.TRIANGLE_STRIP, this._firstQuad * 4, 4); |
291 | 289 | } |
292 | 290 |
|
|
330 | 328 | if (texture !== otherNode.getTexture()) { |
331 | 329 | break; |
332 | 330 | } |
333 | | - |
334 | | - cmd._batched = true; |
335 | 331 | } |
336 | 332 |
|
337 | 333 | var count = i - myIndex; |
338 | | - |
339 | | - if (count > 1) { |
340 | | - this._batching = true; |
341 | | - this._batchedCount = count; |
342 | | - } |
343 | | - else { |
344 | | - return 1; |
345 | | - } |
| 334 | + this._batchedCount = count; |
346 | 335 |
|
347 | 336 | return count; |
348 | 337 | } |
|
0 commit comments