123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- /****************************************************************************
- Copyright (c) 2013-2016 Chukong Technologies Inc.
- Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
- 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 __CCRENDERCOMMAND_H_
- #define __CCRENDERCOMMAND_H_
- #include <stdint.h>
- #include "platform/CCPlatformMacros.h"
- #include "base/ccTypes.h"
- /**
- * @addtogroup renderer
- * @{
- */
- NS_CC_BEGIN
- /** Base class of the `RenderCommand` hierarchy.
- *
- The `Renderer` knows how to render `RenderCommands` objects.
- */
- class CC_DLL RenderCommand
- {
- public:
- /**Enum the type of render command. */
- enum class Type
- {
- /** Reserved type.*/
- UNKNOWN_COMMAND,
- /** Quad command, used for draw quad.*/
- QUAD_COMMAND,
- /**Custom command, used for calling callback for rendering.*/
- CUSTOM_COMMAND,
- /**Batch command, used for draw batches in texture atlas.*/
- BATCH_COMMAND,
- /**Group command, which can group command in a tree hierarchy.*/
- GROUP_COMMAND,
- /**Mesh command, used to draw 3D meshes.*/
- MESH_COMMAND,
- /**Primitive command, used to draw primitives such as lines, points and triangles.*/
- PRIMITIVE_COMMAND,
- /**Triangles command, used to draw triangles.*/
- TRIANGLES_COMMAND
- };
- /**
- Init function, will be called by all the render commands.
- @param globalZOrder The global order of command, used for rendercommand sorting.
- @param modelViewTransform Modelview matrix when submitting the render command.
- @param flags Flag used to indicate whether the command should be draw at 3D mode or not.
- */
- void init(float globalZOrder, const Mat4& modelViewTransform, uint32_t flags);
-
- /** Get global Z order. */
- float getGlobalOrder() const { return _globalOrder; }
- /** Returns the Command type. */
- Type getType() const { return _type; }
-
- /** Returns whether is transparent. */
- bool isTransparent() const { return _isTransparent; }
-
- /** Set transparent flag. */
- void setTransparent(bool isTransparent) { _isTransparent = isTransparent; }
- /**
- Get skip batching status, if a rendering is skip batching, it will be forced to be rendering separately.
- */
- bool isSkipBatching() const { return _skipBatching; }
- /**Set skip batching.*/
- void setSkipBatching(bool value) { _skipBatching = value; }
- /**Whether the command should be rendered at 3D mode.*/
- bool is3D() const { return _is3D; }
- /**Set the command rendered in 3D mode or not.*/
- void set3D(bool value) { _is3D = value; }
- /**Get the depth by current model view matrix.*/
- float getDepth() const { return _depth; }
-
- protected:
- /**Constructor.*/
- RenderCommand();
- /**Destructor.*/
- virtual ~RenderCommand();
- //used for debug but it is not implemented.
- void printID();
- /**Type used in order to avoid dynamic cast, faster. */
- Type _type;
- /** Commands are sort by global Z order. */
- float _globalOrder;
-
- /** Transparent flag. */
- bool _isTransparent;
-
- /**
- QuadCommand and TrianglesCommand could be auto batched if there material ID is the same, however, if
- a command is skip batching, it would be forced to draw in a separate function call, and break the batch.
- */
- bool _skipBatching;
-
- /** Is the command been rendered on 3D pass. */
- bool _is3D;
-
- /** Depth from the model view matrix.*/
- float _depth;
- };
- NS_CC_END
- /**
- end of support group
- @}
- */
- #endif //__CCRENDERCOMMAND_H_
|