GAF Library
Generic Animation Format
 All Classes Functions Pages
GAFStencilMaskSprite.h
1 #pragma once
2 
3 #ifndef __GAF_STENCIL_MASK_SPRITE__
4 #define __GAF_STENCIL_MASK_SPRITE__
5 
6 #include "GAFSprite.h"
7 
8 #define kGAFStencilMaskAlphaFilterProgramCacheKey "kGAFScrollLayerAlphaFilterProgramCacheKey"
9 
10 namespace cocos2d
11 {
12  class __Array;
13 }
14 
16 {
17 private:
18  struct StencilState
19  {
20  GLboolean currentStencilEnabled;
21  GLuint currentStencilWriteMask;
22  GLenum currentStencilFunc;
23  GLint currentStencilRef;
24  GLuint currentStencilValueMask;
25  GLenum currentStencilFail;
26  GLenum currentStencilPassDepthFail;
27  GLenum currentStencilPassDepthPass;
28  } m_stencilState;
29 
30 public:
31  GAFStencilMaskSprite(int stencilLayer);
33  virtual bool initWithTexture(cocos2d::Texture2D *pTexture, const cocos2d::Rect& rect, bool rotated);
34  static cocos2d::GLProgram * programShaderForMask();
35  virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
36  virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
37 
38  void invalidateMaskedObjectsOrder();
39 
40  static void updateMaskContainerOf(cocos2d::Node * node);
41 
42  void addMaskedObject(cocos2d::Node * anObject);
43  void removeMaskedObject(cocos2d::Node * anObject);
44  void updateStencilLayer(int newLayer);
45 protected:
46  void sortAllMaskedObjects();
47 private:
48  int m_stencilLayer;
49  cocos2d::__Array * _maskedObjects;
50  bool _isReorderMaskedObjectsDirty;
51  void _disableStencil();
52 };
53 
54 #endif // __GAF_STENCIL_MASK_SPRITE__
Definition: GAFStencilMaskSprite.h:15
Definition: GAFSprite.h:23