From e402f35e7f89c820a25277920528a010442ae036 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 21 Jan 2014 11:13:21 -0800 Subject: [PATCH] BatchCommand API fixes don't pass Texture Id. Instead fetch it from the `TextureAtlas` --- cocos/2d/CCParticleBatchNode.cpp | 1 - cocos/2d/CCSpriteBatchNode.cpp | 1 - cocos/2d/renderer/CCBatchCommand.cpp | 8 ++++++-- cocos/2d/renderer/CCBatchCommand.h | 8 ++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index f54d823b1b..40a7bc471b 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -384,7 +384,6 @@ void ParticleBatchNode::draw(void) _batchCommand.init( _globalZOrder, - _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas, diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index e8dc9cf8cb..e93b462d68 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -358,7 +358,6 @@ void SpriteBatchNode::draw() _batchCommand.init( _globalZOrder, - _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas, diff --git a/cocos/2d/renderer/CCBatchCommand.cpp b/cocos/2d/renderer/CCBatchCommand.cpp index b9b0c7fab9..6b8d77c518 100644 --- a/cocos/2d/renderer/CCBatchCommand.cpp +++ b/cocos/2d/renderer/CCBatchCommand.cpp @@ -26,6 +26,7 @@ #include "renderer/CCBatchCommand.h" #include "ccGLStateCache.h" #include "CCTextureAtlas.h" +#include "CCTexture2D.h" NS_CC_BEGIN @@ -38,10 +39,13 @@ BatchCommand::BatchCommand() _shader = nullptr; } -void BatchCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) +void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) { + CCASSERT(shader, "shader cannot be nill"); + CCASSERT(textureAtlas, "textureAtlas cannot be nill"); + _globalOrder = globalOrder; - _textureID = textureID; + _textureID = textureAtlas->getTexture()->getName(); _blendType = blendType; _shader = shader; diff --git a/cocos/2d/renderer/CCBatchCommand.h b/cocos/2d/renderer/CCBatchCommand.h index 9ac5b346ee..a33f4ad891 100644 --- a/cocos/2d/renderer/CCBatchCommand.h +++ b/cocos/2d/renderer/CCBatchCommand.h @@ -43,19 +43,15 @@ public: BatchCommand(); ~BatchCommand(); - void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); + void init(float depth, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); void execute(); protected: + //Material int32_t _materialID; - - //Maternal GLuint _textureID; - GLProgram* _shader; -// GLuint _shaderID; - BlendFunc _blendType; TextureAtlas *_textureAtlas;