CCQuadCommand.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef _CC_QUADCOMMAND_H_
  22. #define _CC_QUADCOMMAND_H_
  23. #include <vector>
  24. #include "renderer/CCTrianglesCommand.h"
  25. #include "renderer/CCGLProgramState.h"
  26. /**
  27. * @addtogroup renderer
  28. * @{
  29. */
  30. NS_CC_BEGIN
  31. /**
  32. Command used to render one or more Quads, similar to TrianglesCommand.
  33. Every QuadCommand will have generate material ID by give textureID, glProgramState, Blend function
  34. if the material id is the same, these QuadCommands could be batched to save draw call.
  35. */
  36. class CC_DLL QuadCommand : public TrianglesCommand
  37. {
  38. public:
  39. /**Constructor.*/
  40. QuadCommand();
  41. /**Destructor.*/
  42. ~QuadCommand();
  43. /** Initializes the command.
  44. @param globalOrder GlobalZOrder of the command.
  45. @param textureID The openGL handle of the used texture.
  46. @param glProgramState The glProgram with its uniform.
  47. @param blendType Blend function for the command.
  48. @param quads Rendered quads for the command.
  49. @param quadCount The number of quads when rendering.
  50. @param mv ModelView matrix for the command.
  51. @param flags to indicate that the command is using 3D rendering or not.
  52. */
  53. void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
  54. const Mat4& mv, uint32_t flags);
  55. /**Deprecated function, the params is similar as the upper init function, with flags equals 0.*/
  56. CC_DEPRECATED_ATTRIBUTE void init(float globalOrder, GLuint textureID, GLProgramState* shader, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
  57. const Mat4& mv);
  58. void init(float globalOrder, Texture2D* textureID, GLProgramState* glProgramState, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
  59. const Mat4& mv, uint32_t flags);
  60. protected:
  61. void reIndex(int indices);
  62. int _indexSize;
  63. std::vector<GLushort*> _ownedIndices;
  64. // shared across all instances
  65. static int __indexCapacity;
  66. static GLushort* __indices;
  67. };
  68. NS_CC_END
  69. /**
  70. end of support group
  71. @}
  72. */
  73. #endif //_CC_QUADCOMMAND_H_