CCPrimitiveCommand.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_PRIMITIVE_COMMAND_H__
  22. #define _CC_PRIMITIVE_COMMAND_H__
  23. #include "renderer/CCPrimitive.h"
  24. #include "renderer/CCRenderCommand.h"
  25. /**
  26. * @addtogroup renderer
  27. * @{
  28. */
  29. NS_CC_BEGIN
  30. class GLProgramState;
  31. /**
  32. Command used to render primitive, similar to QuadCommand.
  33. Every QuadCommand will have generate material ID by give textureID, glProgramState, Blend function.
  34. However, primitive command could not be batched.
  35. */
  36. class CC_DLL PrimitiveCommand : public RenderCommand
  37. {
  38. public:
  39. /**@{
  40. Constructor and Destructor.
  41. */
  42. PrimitiveCommand();
  43. ~PrimitiveCommand();
  44. /**@}*/
  45. /** Initializes the command.
  46. @param globalOrder GlobalZOrder of the command.
  47. @param textureID The openGL handle of the used texture.
  48. @param glProgramState The specified glProgram and its uniform.
  49. @param blendType Blend function for the command.
  50. @param primitive Rendered primitive for the command.
  51. @param mv ModelView matrix for the command.
  52. @param flags to indicate that the command is using 3D rendering or not.
  53. */
  54. void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, Primitive* primitive, const Mat4& mv, uint32_t flags);
  55. CC_DEPRECATED_ATTRIBUTE void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, Primitive* primitive,const Mat4& mv);
  56. /**Get the generated material ID.*/
  57. uint32_t getMaterialID() const { return _materialID; }
  58. /**Get the texture ID used for drawing.*/
  59. GLuint getTextureID() const { return _textureID; }
  60. /**Get the glprogramstate used for drawing.*/
  61. GLProgramState* getGLProgramState() const { return _glProgramState; }
  62. /**Get the blend function for drawing.*/
  63. BlendFunc getBlendType() const { return _blendType; }
  64. /**Get the modelview matrix when draw the primitive.*/
  65. const Mat4& getModelView() const { return _mv; }
  66. /**Execute and draw the command, called by renderer.*/
  67. void execute() const;
  68. protected:
  69. uint32_t _materialID;
  70. GLuint _textureID;
  71. GLProgramState* _glProgramState;
  72. BlendFunc _blendType;
  73. Primitive* _primitive;
  74. Mat4 _mv;
  75. };
  76. NS_CC_END
  77. /**
  78. end of support group
  79. @}
  80. */
  81. #endif //_CC_PRIMITIVE_COMMAND_H__