1
0

CCStencilStateManager.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies Inc.
  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 StencilStateManager_hpp
  22. #define StencilStateManager_hpp
  23. #include "base/ccConfig.h"
  24. #include "platform/CCPlatformMacros.h"
  25. #include "platform/CCGL.h"
  26. /**
  27. * @addtogroup base
  28. * @{
  29. */
  30. NS_CC_BEGIN
  31. class CC_DLL StencilStateManager
  32. {
  33. public:
  34. StencilStateManager();
  35. void onBeforeVisit();
  36. void onAfterDrawStencil();
  37. void onAfterVisit();
  38. void setAlphaThreshold(GLfloat alphaThreshold);
  39. void setInverted(bool inverted);
  40. bool isInverted()const;
  41. GLfloat getAlphaThreshold()const;
  42. private:
  43. CC_DISALLOW_COPY_AND_ASSIGN(StencilStateManager);
  44. static GLint s_layer;
  45. /**draw fullscreen quad to clear stencil bits
  46. */
  47. void drawFullScreenQuadClearStencil();
  48. GLfloat _alphaThreshold;
  49. bool _inverted;
  50. GLboolean _currentStencilEnabled;
  51. GLuint _currentStencilWriteMask;
  52. GLenum _currentStencilFunc;
  53. GLint _currentStencilRef;
  54. GLuint _currentStencilValueMask;
  55. GLenum _currentStencilFail;
  56. GLenum _currentStencilPassDepthFail;
  57. GLenum _currentStencilPassDepthPass;
  58. GLboolean _currentDepthWriteMask;
  59. GLboolean _currentAlphaTestEnabled;
  60. GLenum _currentAlphaTestFunc;
  61. GLclampf _currentAlphaTestRef;
  62. GLint _mask_layer_le;
  63. };
  64. NS_CC_END
  65. // end of base group
  66. /** @} */
  67. #endif /* StencilStateManager_hpp */