2014-01-16 08:06:47 +08:00
|
|
|
/****************************************************************************
|
2016-08-05 09:42:15 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2014-01-16 08:06:47 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _CC_BATCHCOMMAND_H_
|
|
|
|
#define _CC_BATCHCOMMAND_H_
|
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "renderer/CCRenderCommand.h"
|
2014-01-16 08:06:47 +08:00
|
|
|
|
2015-03-27 11:54:40 +08:00
|
|
|
/**
|
2015-06-01 13:43:56 +08:00
|
|
|
* @addtogroup renderer
|
2015-03-27 11:54:40 +08:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2014-01-16 08:06:47 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class TextureAtlas;
|
2014-08-29 15:39:52 +08:00
|
|
|
class GLProgram;
|
2015-03-20 09:46:08 +08:00
|
|
|
/**
|
|
|
|
Command used to draw batches in one TextureAtlas.
|
|
|
|
*/
|
2014-07-14 17:02:06 +08:00
|
|
|
class CC_DLL BatchCommand : public RenderCommand
|
2014-01-16 08:06:47 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Constructor.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
BatchCommand();
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Destructor.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
~BatchCommand();
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Init the batch command.
|
|
|
|
@param globalZOrder GlobalZOrder of the render command.
|
|
|
|
@param shader Shader used for draw the texture atlas.
|
|
|
|
@param blendType Blend function for texture atlas.
|
|
|
|
@param textureAtlas Texture atlas, will contain both quads and texture for rendering.
|
|
|
|
@param modelViewTransform Model view transform used for rendering.
|
|
|
|
@param flags Indicate the render command should be rendered in 3D mode or not.
|
|
|
|
*/
|
2015-01-16 06:00:49 +08:00
|
|
|
void init(float globalZOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform, uint32_t flags);
|
2015-03-20 09:46:08 +08:00
|
|
|
/*Deprecated function, you should call upper init function instead.*/
|
2015-01-16 06:00:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void init(float depth, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const Mat4& modelViewTransform);
|
2014-01-16 08:06:47 +08:00
|
|
|
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Execute the command, which will call openGL function to draw the texture atlas.*/
|
2014-01-19 03:35:27 +08:00
|
|
|
void execute();
|
2014-01-16 08:06:47 +08:00
|
|
|
|
|
|
|
protected:
|
2015-03-20 09:46:08 +08:00
|
|
|
//TODO: This member variable is not used. It should be removed.
|
2014-01-16 08:06:47 +08:00
|
|
|
int32_t _materialID;
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Texture ID used for texture atlas rendering.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
GLuint _textureID;
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Shaders used for rendering.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
GLProgram* _shader;
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Blend function for rendering.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
BlendFunc _blendType;
|
2015-03-20 09:46:08 +08:00
|
|
|
/**Texture atlas for rendering.*/
|
2014-01-16 08:06:47 +08:00
|
|
|
TextureAtlas *_textureAtlas;
|
|
|
|
|
2015-03-20 09:46:08 +08:00
|
|
|
/**ModelView transform.*/
|
2014-05-15 01:07:09 +08:00
|
|
|
Mat4 _mv;
|
2014-01-16 08:06:47 +08:00
|
|
|
};
|
|
|
|
NS_CC_END
|
|
|
|
|
2015-03-27 11:54:40 +08:00
|
|
|
/**
|
|
|
|
end of support group
|
|
|
|
@}
|
|
|
|
*/
|
2014-01-16 08:06:47 +08:00
|
|
|
#endif //_CC_BATCHCOMMAND_H_
|