1
0

CCQuadCommand.h 3.3 KB

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