1
0

CCTechnique.h 2.9 KB

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