12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include "renderer/CCBatchCommand.h"
- #include "renderer/ccGLStateCache.h"
- #include "renderer/CCTextureAtlas.h"
- #include "renderer/CCTexture2D.h"
- #include "renderer/CCGLProgram.h"
- NS_CC_BEGIN
- BatchCommand::BatchCommand()
- : _textureID(0)
- , _blendType(BlendFunc::DISABLE)
- , _textureAtlas(nullptr)
- {
- _type = RenderCommand::Type::BATCH_COMMAND;
- _shader = nullptr;
- }
- void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform, uint32_t flags)
- {
- CCASSERT(shader, "shader cannot be null");
- CCASSERT(textureAtlas, "textureAtlas cannot be null");
-
- RenderCommand::init(globalOrder, modelViewTransform, flags);
- _textureID = textureAtlas->getTexture()->getName();
- _blendType = blendType;
- _shader = shader;
-
- _textureAtlas = textureAtlas;
-
- _mv = modelViewTransform;
- }
- void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform)
- {
- init(globalOrder, shader, blendType, textureAtlas, modelViewTransform, 0);
- }
- BatchCommand::~BatchCommand()
- {
- }
- void BatchCommand::execute()
- {
-
- _shader->use();
- _shader->setUniformsForBuiltins(_mv);
- GL::bindTexture2D(_textureID);
- GL::blendFunc(_blendType.src, _blendType.dst);
-
- _textureAtlas->drawQuads();
- }
- NS_CC_END
|