CCTechnique.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /****************************************************************************
  2. Copyright (c) 2015-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. Ideas taken from:
  21. - GamePlay3D: http://gameplay3d.org/
  22. - OGRE3D: http://www.ogre3d.org/
  23. - Qt3D: http://qt-project.org/
  24. ****************************************************************************/
  25. #ifndef __cocos2d_libs__CCTechnique__
  26. #define __cocos2d_libs__CCTechnique__
  27. #include <string>
  28. #include "renderer/CCRenderState.h"
  29. #include "renderer/CCPass.h"
  30. #include "base/CCRef.h"
  31. #include "platform/CCPlatformMacros.h"
  32. #include "base/CCVector.h"
  33. NS_CC_BEGIN
  34. class Pass;
  35. class GLProgramState;
  36. class Material;
  37. /// Technique
  38. class CC_DLL Technique : public RenderState
  39. {
  40. friend class Material;
  41. friend class Renderer;
  42. friend class Pass;
  43. friend class MeshCommand;
  44. friend class Mesh;
  45. public:
  46. /** Creates a new Technique with a GLProgramState.
  47. Method added to support legacy code
  48. */
  49. static Technique* createWithGLProgramState(Material* parent, GLProgramState* state);
  50. static Technique* create(Material* parent);
  51. /** Adds a new pass to the Technique.
  52. Order matters. First added, first rendered
  53. */
  54. void addPass(Pass* pass);
  55. /** Returns the name of the Technique */
  56. std::string getName() const;
  57. /** Returns the Pass at given index */
  58. Pass* getPassByIndex(ssize_t index) const;
  59. /** Returns the number of Passes in the Technique */
  60. ssize_t getPassCount() const;
  61. /** Returns the list of passes */
  62. const Vector<Pass*>& getPasses() const;
  63. /** Returns a new clone of the Technique */
  64. Technique* clone() const;
  65. protected:
  66. Technique();
  67. ~Technique();
  68. bool init(Material* parent);
  69. void setName(const std::string& name);
  70. std::string _name;
  71. Vector<Pass*> _passes;
  72. };
  73. NS_CC_END
  74. #endif /* defined(__cocos2d_libs__CCTechnique__) */