public RenderTextureTestDepthStencil()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sprite = new CCSprite("Images/fire");

            sprite.Position = new CCPoint(s.Width * 0.25f, 0);
            sprite.Scale    = 10;

            CCRenderTexture rend = new CCRenderTexture((int)s.Width, (int)s.Height, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, RenderTargetUsage.DiscardContents);

            rend.BeginWithClear(0, 0, 0, 0, 0);

            var save = CCDrawManager.DepthStencilState;

            CCDrawManager.DepthStencilState = new DepthStencilState()
            {
                ReferenceStencil = 1,

                DepthBufferEnable = false,
                StencilEnable     = true,
                StencilFunction   = CompareFunction.Always,
                StencilPass       = StencilOperation.Replace,

                TwoSidedStencilMode             = true,
                CounterClockwiseStencilFunction = CompareFunction.Always,
                CounterClockwiseStencilPass     = StencilOperation.Replace,
            };

            sprite.Visit();

            CCDrawManager.DepthStencilState = new DepthStencilState()
            {
                DepthBufferEnable = false,
                StencilEnable     = true,
                StencilFunction   = CompareFunction.NotEqual,
                StencilPass       = StencilOperation.Keep,
                ReferenceStencil  = 1
            };
            // GL_SRC_ALPHA

            CCDrawManager.BlendFunc(new CCBlendFunc(OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA));

            //! move sprite half width and height, and draw only where not marked
            sprite.Position = sprite.Position + new CCPoint(sprite.ContentSize.Width * sprite.Scale, sprite.ContentSize.Height * sprite.Scale) * 0.5f;

            sprite.Visit();

            CCDrawManager.DepthStencilState = save;

            rend.End();


            rend.Position = new CCPoint(s.Width * 0.5f, s.Height * 0.5f);

            AddChild(rend);
        }
Ejemplo n.º 2
0
 internal void UseMaterial (CCDrawManager drawManager)
 {
     drawManager.BlendFunc(BlendType);
     drawManager.BindTexture(Texture);
 }
Ejemplo n.º 3
0
 internal override void Execute(CCDrawManager drawManager)
 {
     drawManager.BindTexture(Texture.Texture);
     drawManager.BlendFunc(BlendType);
     Texture.DrawQuads();
 }