CCStencilStateManager.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef StencilStateManager_hpp
  23. #define StencilStateManager_hpp
  24. #include "base/ccConfig.h"
  25. #include "platform/CCPlatformMacros.h"
  26. #include "platform/CCGL.h"
  27. /**
  28. * @addtogroup base
  29. * @{
  30. */
  31. NS_CC_BEGIN
  32. class CC_DLL StencilStateManager
  33. {
  34. public:
  35. StencilStateManager();
  36. void onBeforeVisit();
  37. void onAfterDrawStencil();
  38. void onAfterVisit();
  39. void setAlphaThreshold(GLfloat alphaThreshold);
  40. void setInverted(bool inverted);
  41. bool isInverted()const;
  42. GLfloat getAlphaThreshold()const;
  43. private:
  44. CC_DISALLOW_COPY_AND_ASSIGN(StencilStateManager);
  45. static GLint s_layer;
  46. /**draw fullscreen quad to clear stencil bits
  47. */
  48. void drawFullScreenQuadClearStencil();
  49. GLfloat _alphaThreshold;
  50. bool _inverted;
  51. GLboolean _currentStencilEnabled;
  52. GLuint _currentStencilWriteMask;
  53. GLenum _currentStencilFunc;
  54. GLint _currentStencilRef;
  55. GLuint _currentStencilValueMask;
  56. GLenum _currentStencilFail;
  57. GLenum _currentStencilPassDepthFail;
  58. GLenum _currentStencilPassDepthPass;
  59. GLboolean _currentDepthWriteMask;
  60. GLboolean _currentAlphaTestEnabled;
  61. GLenum _currentAlphaTestFunc;
  62. GLclampf _currentAlphaTestRef;
  63. GLint _mask_layer_le;
  64. };
  65. NS_CC_END
  66. // end of base group
  67. /** @} */
  68. #endif /* StencilStateManager_hpp */